ActionScript3:Migrating from ActionScript 2

From virtualMV2015wiki
Jump to: navigation, search
 Home  Flash10 (CS4) | Flash11 (CS5) <


Icon Objective.png


By the end of this exercise you should:

  • Have a Table of ActionScript 2 and 3 code differences to help you migrate between the two languages
  • Have a reference to understand the difference in variable naming between the two languages
  • Be able to attach an external .as file

Table of Code

Global Functions:
gotoAndPlay() flash.display.MovieClip.gotoAndPlay() movieClipName.gotoAndPlay("frameLabel", "Scene Name");
gotoAndStop() flash.display.MovieClip.gotoAndStop() movieClipName.gotoAndStop("frameLabel","Scene Name");
length String.length trace(myString.length.toString());
loadMovie() flash.display.Loader loader.load(new URLRequest("newMovie.swf");
loadMovieNum() flash.display.Loader loader.load(new URLRequest("newMovie.swf");
onClipEvent() object.addEventListener("enterFrame",enterFrame_handler);
startDrag() flash.display.Sprite.startDrag()
stop(); flash.display.MovieClip.stop() this.stop();
stopDrag() flash.display.Sprite.stopDrag()
unloadMovie() flash.display.Loader.unload()

Variable Naming ActionScript 3

ActionScript 3 requires that you now declare a variable type. With ActionScript 2 you could get away not using a var statement or even a type. The following list declares variables and some common types:

  • var myVarName:Int;
  • var myVarName:String;
  • var myVarName:MovieClip;
  • var myVarName:Number;
  • var myVarName:Sound;
  • var myVarName:StyleSheet;
  • var myVarName:URLLoader;
  • var myVarName:XML;

There are many more, the code hints in the Actions Frame will help when declaring the variable type and offer a large list of options. You can now store not only simple data types such a numbers and strings, but also complex data types such as sounds and objects. To use a class object you must create a new instance of the object and save it as a variable eg:

var myNewMovieClip:MovieClip = new MovieClip();

Icon References.png References


Day, S. (2010). ActionScript3:Migrating from ActionScript 2. Retrieved January 19, 2018, from