ActionScript 101 - Working with Properties
(Page 2 of 5 )
Properties define certain characteristics of Symbols in Flash. Using ActionScript, we can change these properties to create some pretty cool effects. In this tutorial, we will learn to do just that.
Below is a table listing the Symbol Properties.
Property | What it Does |
X. Y Coordinates | The coordinates of an object indicate where it is located on the stage |
Width/Height Measures | The width and height of an object |
Xscale, Yscale | Adjusts the object size |
Visible | Makes an object visible or invisible |
Rotation | Sets the object's degree of rotation; i.e. by how much to rotate a ball |
Quality | Used to change the quality of a scene (and therefore every object in the scene) |
Name | Used to read or change the name of an object |
Alpha | Affects the transparency of an object |
Xmouse, Ymouse | Gives you the coordinates at which a user clicks their mouse |
CurrentFrame | Tells you which layer in a movie is presently playing |
TotalFrame | Tells you the total amount of frames in a movie |
URL | Returns the URL of the SWF file the movie was downloaded from |
Target | Returns the path of a movie clip |
DropTarget | *Discussed in-depth later |
FocusRect | Boolean that lets you know if a keyboard has focus |
FramesLoaded | Tells you the total frames of a movie that were downloaded |
SoundBufTime | *Discussed in-depth later. |
X, Y Coordinates
As described above, X and Y represent the coordinates of an object. The best way to explain this is to actually work with the properties. Open up Flash and draw a shape on your stage. Change the shape to a symbol (press the F8 key) and name the image something like Mov_Rect or something along those lines. Set its Behavior as a Movie Clip and press the OK button.
Next, select the shape you created and look at your Properties Pane (this should be located at the bottom of your window, below the stage). Where it says Instance Name, erase what is there and type in Rectangle.
Finally, right-click the frame in the Timeline and choose Actions from the pop-up menu. Being sure that you have turned off the Script Assistant, type in the following code:
onClipEvent (mouseDown) {
setProperty("", _x, "250");
setProperty("", _y, "250");
}
Now test the movie. If you click on the Rectangle object (or whatever object you created), its position on the stage will relocate. If you go back and change the coordinates to say, 300, and test the movie again, you the object will move to a new location once you click it.
Next: Width/Height >>
More Flash Articles
More By James Payne