Acceso a través de AS3 (para la exportación) el gradiente de un rectángulo creado en el editor de Flash

StackOverflow https://stackoverflow.com/questions/4622695

Pregunta

necesito para exportar la configuración de gradiente de un rectángulo creado con el editor de Flash. Nuestro artista crea un rectángulo con el gradiente en un fla. ¿Es posible recuperar los parámetros de degradado en el .swf o de un plugin de flash podría escribir?

¿Fue útil?

Solución

Yo necesitaba esto hace un par de años, por suerte Tink ya escribió un script de extensión / JSFL: Copia de relleno como AS3 .

Recuerdo haber tenido pequeños problemas con gradientes en función de la selección, pero se olvidó de lo que fue todo eso. Si la extensión no funciona correctamente, aquí está mi versión ligeramente cambiado:

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 salva esto como Copia de relleno como AS3.jsfl en cuestión de inflamación Comandos carpeta, debe aparecer en el menú de comandos en el IDE.

HTH

Otros consejos

Tome un vistazo a la biblioteca excelente as3swf escrito por Noel Wahlers, desde los que se puede

  

de análisis, crear, modificar y publicar los archivos SWF

.

Sothink Decompiler le permite descompilar el SWF para que pueda obtener la FLA originales. http://www.sothink.com/product/flashdecompiler/ se paga pero tienen una prueba gratuita.

No podía recordar si se pudiera exportar a fla en el ensayo.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top