Thursday, February 5, 2009

Properties of MovieClips

Properties
Understanding MovieClip Properties

This tutorial is about the most important and commonly used properties of movieclips.

_x and _y
Every movieclip on screen has an x and y location that can be called or changed. These coordinates are measured in pixels from the top left corner of the screen. x is left and right, while y is up and down.

For example, on a 550 by 400 flash--
Top Left 0X , 0Y
Top Right 550X , 0Y
Bottom Left 0X , 400Y
Bottom Right 550X , 400Y



To find out what a movieclip's _x or _y location is use.

myvar = ball._x
myvar2 = ball._y
This sets the variable myvar equal to ball._x(the ball's x location), and myvar2 equal to ball._y(the ball's x location),.


To change a movieclip's location on screen.

ball._x = 200
This moves the ball to an _x position 200 pixels from the left side of the screen.

ball._x += 50
This moves the ball to an _x position 50 pixels to the right of where is was before.



_height and _width

Every movieclip also has a height and width. They are pretty self-explanatory. You can change them or find out what they are by doing this.

yourvariable = ball._width
This sets yourvariable equal to ball._width(the ball's width).

myvariable = ball._height
This sets myvariable equal to ball._height(the ball's height).



You can stretch or shrink a movieclip also.

ball._width = 38
Sets the ball’s width to 38 pixels.

ball._width += 20
Adds 20 to the ball’s current width.




_alpha

The _alpha property is how opaque or transparent a movieclip is. It has a range of 0 to 100 with 0 being invisible and 100 being opaque. Be careful when using it on moving objects because it can cause bad lag and slow frame rates on many computers.

ball._alpha = 50
Makes the ball somewhat transparent.


ball._alpha -= 5
If you put this in the onEnterFrame function so that it runs repeatedly, it will make the ball slowly fade then disappear.


Visit our site pogollama.com for free flash games and highscore tables.

No comments:

Post a Comment