PROGRAMMING COURSES ADMIN VIDEO TUTORIALS COMMUNITY RESOURCES |
Each object created through code or manually created and given instance name on stage in ActionScript 3.0, has certain properties and methods associated with it for the particular data type the object may happen to be.
Properties Once an object is created and defined we can access certain characteristics known as properties of that object using Dot ( . ) syntax. The dot follows directly after the object's instance name and opens a doorway to the properties and methods of that object. To better convey the idea and functionality lets show a code example. Drag a rectangle out to stage, right click it, convert to movieclip symbol, then give it an instance name of "myBox". ![]() var boxW:int = myBox.width; 201 136 162 70 true As you can see you in the example above you have just accessed and more importantly, adjusted a few of the properties of that button object using its instance name. Here is another example of accessing the properties of a simple string variable. ![]() var carMaker:String = "TOYOTA"; String object has 6 characters Methods Methods are more like actions that can be performed by an object. When we create movieclips we can access their methods using the Dot ( . ) operator like we do for accessing properties. The data type determines what methods are associated and can be used on that object. To best demonstrate this to yourself create a movieclip with an instance name of "myClip". Make a timeline animation play over 20 frames with a low frame rate. Use the following code to make the animation stop on command by accessing those methods for the object. play() works as well. ![]() if (myClip.currentFrame == 10) { In the example above we checked the movieclip's currentFrame property, and then used one of that data types methods( stop() ) to have actions apply to it that we want. gotoAndPlay() and gotoAndStop() are methods that can be applied to timelines of movieclips as well.
|
|||||||||||
|
|
DevelopPHP Requires Flash Player
___________________________________________
|
||||||||