|I l @ ve RuBoard|
If you use Flash's default movie dimensions, the bottom-right corner will be at 550, 400. That is, horizontally 550 pixels from the left side and 400 pixels down from the top.
Every spot in the work area can be identified as a position. For instance, the exact center of the area is 225, 200. Figure 7.1 shows the work area with several spots labeled.
Figure 7.1. The work area with several positions .
Another name for the horizontal coordinate of a position is x. The vertical coordinate of a position is y. A position is then expressed in x, y coordinates.
To examine the position of a movie clip, you need to use the _x and _y properties. For instance, if you have a movie clip named myClip, you could use the following lines to send the x and y coordinates of that clip to the Output window:
You can also see the location of a movie clip by selecting it in the work area and bringing up the Info panel. You can do this by choosing Window, Info or by using the keyboard shortcut Command+I on the Mac or Ctrl+I in Windows. Figure 7.2 shows this panel.
Figure 7.2. The Info panel shows the position of the movie clip selected. The second X and Y readings at the bottom show the mouse location.
To change the position of a movie clip when the movie is running, all you need to do is set the _x and _y properties of the movie clip. Here is an example:
myClip._x = 200; myClip._y = 250;
You can alter the _x and _y properties in the same way that you alter variables . You can use += , -= , ++ , and -- to make changes based on the original value of the property. For instance, to move a movie clip five pixels to the right, you could do this:
myClip._x += 5;
If you want to move a movie clip one pixel down, you could do this:
If you want to refer to the _x or _y property of the current movie clip, the one that contains your code, you can refer to _x or _y without a prefix, or you can use this as the object reference. So either of these will work to increase the horizontal position of a movie clip, if the code is attached to that clip:
|I l @ ve RuBoard|