Each timeline has an
within its coordinate system. The position is always relative to the registration point. For the
main timeline (
_level0
registration point depends on the registration point set when the clip was created or its
placement on the Stage.
The
and
_xmouse
_ymouse
The following procedure shows several ways to get the pointer position within the main
timeline or within a movie clip.
To get the current pointer position:
1.
Create two dynamic text fields, and name them box1_txt and box2_txt.
2.
Add labels for the text boxes: x position and y position, respectively.
3.
Select Window > Actions to open the Actions panel if it is not already open.
4.
Add the following code to the script pane:
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
// returns the X and Y position of the mouse
box1_txt.text = _xmouse;
box2_txt.text = _ymouse;
};
Mouse.addListener(mouseListener);
5.
Select Control > Test Movie to test the Flash movie. The box1_txt and box2_txt fields
show the position of the pointer while you move it over the Stage.
For more information about the
(MovieClip._xmouse property) and _ymouse (MovieClip._ymouse property) in the
ActionScript 2.0 Language Reference.
568
Creating Interaction with ActionScript
and
_xmouse
_ymouse
), the registration point is the upper left corner. For a movie clip, the
properties within the main timeline and a movie clip timeline
_xmouse
property that returns the location of the pointer
and
properties, see _xmouse
_ymouse
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?
Questions and answers