0
votes

I have a fla file which was developed on "Adobe Flash Professional CS5". It uses action script 2.0

Now I have to migrate this fla file to "Adobe Animate CC 2017". When load fla file in the IDE and publish, I Encounter below error.

Symbol 'AAAA', Layer 'Definition', Frame 1, Line 20, Column 8 1061: Call to a possibly undefined method registerClass through a reference with static type Class.

below is the code snippet

// 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 didn't support proper classes, hence Object.registerClass, instead, create an as3.0 class named AAAA and define the methods/properties of AAAAClass in the code above(e.g. setID(), setStatus()) - George Profenza
Thanks for the Help!!! - Praveer Kumar
Is there any tool which can help to convert AS2.0 to 3.0 ?Where can I find the useful document for AS 3.0 ? - Praveer Kumar

1 Answers

1
votes

You can make some assumption based on your as2 code:

// 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

This can be extrapolated to an as 3.0 class like this:

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 + " ]";
        }

    }

}

Notice the commented out TextFields ? I won't be able to guess the structure, but my guess is that in your as 2.0 project there is a MovieClip in the libraries linked to the AAAAClass which has two TextFields: ID and Status.

There is a lot to cover in terms of as3 and migration from as2 to as3. I recommend reading Trevor McCauley's Getting Started with ActionScript 3.0 in Adobe Flash CS3 exhaustive article and Dan Carr's Migrating from ActionScript 2 to ActionScript 3: Key concepts and changes article.

If you're new to as3 probably practice the concepts explained in the articles in minimal new flash projects so it's all simple and easy to digest, then go back to your project and apply what you've learned.