Accès à via AS3 (pour l'exportation) le gradient d'un rectangle créé dans l'éditeur de Flash
-
30-09-2019 - |
Question
Je dois exporter les paramètres de dégradé d'un rectangle créé avec l'éditeur Flash. Notre artiste crée un rectangle avec le dégradé dans un fla. Est-il possible de récupérer les paramètres de gradient de la .swf ou d'un plugin flash que je pourrais écrire?
La solution
Je besoin ce, il y a quelques années, heureusement Tink a déjà écrit une extension / script JSFL: Copier Remplir comme AS3.
Je me souviens d'avoir de petits problèmes avec des gradients en fonction de la sélection, mais il a oublié ce qui était que tout. Si l'extension ne fonctionne pas correctement, voici ma version légèrement modifiée:
document = fl.getDocumentDOM();
selection = document.getSelectionRect();
selection.left != undefined ? useSelection = true : useSelection = false;
useSelection ? fill = document.getCustomFill( "selection" ) : fill = document.getCustomFill( "toolbar" );
fl.outputPanel.clear();
var output = "";
if(fill.style != "noFill"){
if( fill.style == "solid" )
{
if( fill.color.length == 9 )
{
a = Math.round( ( parseInt( "0x" + fill.color.substr( 7, 2 ) ) / 255 ) * 100 ) / 100;
output += "beginFill( 0x" + fill.color.substr( 1, 6 ).toUpperCase() + ", " + a + " );";
}
else
{
output += "beginFill( 0x" + fill.color.substr( 1, 6 ).toUpperCase() + ", 1 );";
}
}
else if( fill.style == "linearGradient" )
{
output += "beginGradientFill( GradientType.LINEAR, ";
}
else if( fill.style == "radialGradient" )
{
output += "beginGradientFill( GradientType.RADIAL, ";
}
if( fill.style != "solid" )
{
c = new Array();
a = new Array()
for( i = 0; i < fill.colorArray.length; i++ )
{
if(fill.colorArray){
if( fill.colorArray[ i ].length == 9 )
{
c.push( "0x" + fill.colorArray[ i ].substr( 1, 6 ).toUpperCase() );
a.push( Math.round( ( parseInt( "0x" + fill.colorArray[ i ].substr( 7, 2 ) ) / 255 ) * 100 ) / 100 );
}
else
{
c.push( "0x" + fill.colorArray[ i ].substr( 1, 6 ).toUpperCase() );
a.push( 1 );
}
}
}
document.setSelectionRect({left:0,top:0,right:0,bottom:0},true);
document.setSelectionRect(selection,true);
localX = fill.matrix.tx - selection.left;
localY = fill.matrix.ty - selection.top
if(localX < 0 || localY < 0) error = true;
else error = false;
if(useSelection)
{
matrix = 'new Matrix(' + fill.matrix.a + ', ' + fill.matrix.b + ', ' + fill.matrix.c + ', ' + fill.matrix.d + ', ' + localX + ', ' + localY + ')';
}
else
{
matrix = 'new Matrix(' + fill.matrix.a + ', ' + fill.matrix.b + ', ' + fill.matrix.c + ', ' + fill.matrix.d + ', ' + fill.matrix.tx + ', ' + fill.matrix.ty + ')';
}
switch(fill.overflow){
case "Extend":
spreadMethod = "SpreadMethod.PAD";
break;
case "Repeat":
spreadMethod = "SpreadMethod.REPEAT";
break;
case "Reflect":
spreadMethod = "SpreadMethod.REFLECT";
break;
}
!fill.linearRGB ? interpolationMethod = 'InterpolationMethod.RGB' : interpolationMethod = 'InterpolationMethod.LINEAR_RGB';
if(fill.focalPoint != 0) output += "[ " + c.join( ", " ) + " ], [ " + a.join( ", " ) + " ], [ " + fill.posArray.join( ", " ) + " ], " + matrix + ", " + spreadMethod + ", " + interpolationMethod + ", " + fill.focalPoint + "); ";
else output += "[ " + c.join( ", " ) + " ], [ " + a.join( ", " ) + " ], [ " + fill.posArray.join( ", " ) + " ], " + matrix + ", " + spreadMethod + ", " + interpolationMethod + "); ";
}
if(error)
{
fl.trace("You have moved your selection!Please re-select the shape and run this command again");
}else
{
fl.clipCopyString( output );
fl.trace( output );
}
}else{
fl.trace( 'No Fill is Selected' );
}
Si vous enregistrez cette Copier Fill comme AS3.jsfl de flash Commandes dossier , il devrait apparaître dans le menu Commandes dans l'IDE.
HTH
Autres conseils
Jetez un oeil à la bibliothèque as3swf écrit par Claus Wahlers, vous pouvez Wich de
Parse, créer, modifier et publier des fichiers SWF
.
Sothink Decompiler vous permet de décompiler le swf et vous obtenez la FLA originale. http://www.sothink.com/product/flashdecompiler/ il est payé, mais ils ont un essai gratuit.
ne se souvenaient pas si vous pouvez exporter vers fla dans le procès.