< Day Day Up > |
In order for error handling to work in ActionScript 2.0, it is essential that we specify the data type (or the class) of all Objects, including visual Objects, at the beginning of the class file or at the top of the timeline code: var myArray :Array = new Array(); var myObject :Object = new Object(); var myColor :Color = new Color(); var myCombo :mx.control.ComboBox; var myMovieClip :MovieClip; It is also important to specify what type of data a function returns: function getArray () :Array { return myArray; } Specifying a data type causes ActionScript 2.0 to perform type checking and display detailed error messages to the developer which greatly helps with debugging. If a function does not return any data, we should type that function as Void : function setArray (passedArray :Array) :Void { this.myArray = passedArray; }
|
< Day Day Up > |