2011-01-07 34 views

回答

2

幾年前我需要這個,幸運的是Tink已經寫了一個擴展/ JSFL腳本:Copy Fill as AS3

我記得在漸變方面存在一些小問題,這取決於選擇,但忘記了那是什麼。如果分機不能正常工作,這是我的些許變化版本:

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'); 
} 

如果您保存此爲拷貝到Flash的命令文件夾作爲填充AS3.jsfl,它應該在命令菜單彈出在IDE中。

HTH

3

看看克勞斯Wahlers寫的外觀極好庫as3swf,從至極可以

解析,創建,修改和發佈的SWF文件

+0

這是一個了不起的圖書館,謝謝! – erkmene 2011-01-07 11:35:27

+0

似乎真的很整潔,但我有點緊張,這取決於仍在alpha版中的圖書館。 – 2011-01-08 08:17:20

1

Sothink Decompiler允許您反編譯swf,以便獲得原始FLA。它已付款,但他們有免費試用。

不記得您是否可以在試驗中輸出到fla。