将Action Script 2.0代码迁移到Action脚本3.0

时间:2017-06-15 08:06:22

标签: flash adobe animate.css

我有一个fla文件是在" Adob​​e Flash Professional CS5"上开发的。它使用动作脚本2.0

现在我必须将此fla文件迁移到" Adob​​e Animate CC 2017"。当在IDE中加载fla文件并发布时,我遇到错误。

符号' AAAA',图层'定义',第1帧,第20行,第8列1061:通过带有静态类型Class的引用调用可能未定义的方法registerClass。

下面的

是代码段

// 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 个答案:

答案 0 :(得分:1)

您可以根据您的as2代码做出一些假设:

// 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项目中,链接到AAAAClass的库中有一个MovieClip,它有两个TextField:IDStatus。< / p>

as3和从as2到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项目文章中解释的概念,这样简单易懂,然后回到你的项目并运用你学到的东西。