Mouse X, Y position
Submited in: Flash
| Total Views: 78234
In this easy, detailed Flash lesson, I will show you how to create X and Y mouse position using the action script code.
Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the width and the height of your document as whaterver you like. Select any color as background color. Set your Flash movie's frame rate to 24 and click ok.
Take now the Text Tool (A) and type somewhere on the stage X and Y. See the picture below.
Takle the Text Tool (A) and go to the Properties Panel again (Ctrl+F3) and select the following options:
a) Select a Dynamic Text field.
b) Select any font.
c) Choose any size for font.
d) Select any color for font.
e) As the rendering option, select Anti - alias for readability.
f) for Var type: xvalue
Then, draw a rectangle on the right side of X letter. See the picture below.
Do this also for letter Y, but for Var type: yvalue
Create a new layer above the layer 1 (layer 2).
Select layer 2, take the Rectangle Tool (R) and draw a vertical rectangle line like it is shown on the picture below.
While the vertical line is still selected, press F8 key (Convert to Symbol) to convert this vertical line into a Movie Clip Symbol. See the picture below.
Take now the Selection Tool (V), click once on the vertical line and go to the Action Script Panel (F9). Then, enter this code inside the actions panel:
this._x = _root.xvalue = _root._xmouse;
Take now again the Rectangle Tool (R) and draw a horizontal line.
While the horizontal line is still selected, press again F8 key (Convert to Symbol) to convert this horizontal line into a Movie Clip Symbol.
Select that horizontal line using the Selection Tool (V) and go again to the A.S. panel and enter this code inside the actions panel:
this._y = _root.yvalue = _root._ymouse;
Test your movie and enjoy!