2017-06-15 147 views
0

我這是在爲「Adobe Flash Professional CS5中」開發一個FLA文件。它使用動作腳本2.0遷移動作腳本2.0代碼到行動腳本3.0

現在我必須遷移該FLA文件的「Adobe動畫CC 2017年」。當在IDE中加載fla文件併發布時,我遇到了下面的錯誤。

符號「AAAA」,層「的定義」,第1幀,第20行,第8欄1061:通過與靜態類型類的引用調用可能未定義的方法的registerClass。

下面

是,您可以根據您的AS2代碼的一些假設的代碼片段

// The default value for Severity parameter must be negative. 
function AAAAClass() { 
    this.setID(this.mID); 
    this.setStatus(this.mStatus); 
} 

AAAAClass.prototype = new MovieClip(); 

AAAAClass.prototype.setID = function(variable) { 
    this.ID.text = variable; 
}; 

AAAAClass.prototype.setStatus = function(variable) { 
    this.Status.text = variable; 
    this.Status._visible = false; 
}; 

Object.registerClass("AAAA", AAAAClass); // Compiler shows error at this statement 
+1

as2.0不支持正確的類,因此'Object.registerClass',而是創建一個[as3.0類](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3 /Class.html)命名爲'AAAA',並在上面的代碼中定義'AAAAClass'的方法/屬性(例如'setID()','setStatus()') –

+0

感謝您的幫助! –

+0

有什麼工具可以幫助將AS2.0轉換爲3.0?我在哪裏可以找到AS 3.0的有用文檔? –

回答

1

// The default value for Severity parameter must be negative. 
function AAAAClass() {          //this is the "constructor" 
    this.setID(this.mID);      
    this.setStatus(this.mStatus); 
} 

AAAAClass.prototype = new MovieClip();      //this means the class extends MovieClip (probably a Movie Clip Exported for Actionscript in the .fla file's Library) 

AAAAClass.prototype.setID = function(variable) {    
    this.ID.text = variable;        //from this line we can deduce the ID isn't an int (as intuituion might point to), but a String and the clip must contain a Dynamic TextField named ID 
}; 

AAAAClass.prototype.setStatus = function(variable) { 
    this.Status.text = variable;       //from this line we can deduce the Statusi is also a String and the clip must contain a Dynamic TextField named Status 
    this.Status._visible = false; 
}; 

Object.registerClass("AAAA", AAAAClass); // Compiler shows error at this statement 

這可以推斷出一個像這樣3.0類:

package { 

    import flash.display.MovieClip; 
    import flash.text.TextField; 

    public class AAAA extends MovieClip { 

     private var mID:String = "default ID"; 
     private var mStatus:String = "default status"; 

     //private var ID:TextField; 
     //private var Status:TextField; 

     public function AAAA(){ 
      this.setID(this.mID); 
      this.setStatus(this.mStatus); 

      //ID = new TextField(); 
      //Status = new TextField(); 
     } 

     public function setID(variable:String):void{ 
      this.mID = variable; 
      this.ID.text = this.mID; 
     }; 

     public function setStatus(variable:String):void{ 
      this.mStatus = variable; 
      this.Status.text = this.mStatus; 
      this.Status.visible = false; 
     }; 

     override public function toString():String{ 
      return "[AAAA mID=" + mID + " mStatus=" + mStatus + " ]"; 
     } 

    } 

} 

注意到註釋掉了TextFields?我無法猜測結構,但我的猜測是,在您爲2.0的項目有在掛有兩個TextFields的AAAAClass庫的MovieClip:IDStatus

有很多從AS2到AS3 AS3和遷移方面覆蓋。 我推薦閱讀Trevor McCauley's Getting Started with ActionScript 3.0 in Adobe Flash CS3詳盡文章和​​Dan Carr's Migrating from ActionScript 2 to ActionScript 3: Key concepts and changes文章。

如果你是新來的AS3可能實行的概念在最小的新的Flash項目的文章這樣解釋這一切都簡單,易於消化,然後再返回到你的項目和應用你學到的東西。