Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials onMouseMove, onMouseDown, onMouseUp in ActionScript
Your Ad Here

onMouseMove, onMouseDown, onMouseUp in ActionScript


This tutorial was written for the Flash Designer software, which allows you to create flash animations in a much easier way than by using Macromedia Flash. You may get Flash Designer here.

The following tutorial illustrates how to handle onMouseMove, onMouseDown, onMounseUp events.

NOTE: Minimum Flash Designer version 5.0.17

1. Launch Flash Designer and choose "Blank document" from the startup screen.

2. Choose "Edit Field tool" and draw a rectangle to create edit text object. Edit field should appear as "Edit1".

3. Choose "Text Tool", click on the frame, type the text "CLICK!" and click OK to create text object. Choose "Edit" > "Convert to Sprite", the text should appear as "Sprite3".

4. Choose "Item" > "Placement Properties" and check "ActionScript Target" (for Sprite3 object), click OK. (This step is necessary to access Sprite3 in ActionScript code, for example Sprite3._visible = false)

5. Choose "Frame" > "Frame Delay", check "Stop" and click OK.

6. Choose "Frame" > "ActionScript", type the following code and click OK:

onMouseMove = function()
{
// fill Edit1 with current x and y position
Edit1 = "x: " + _xmouse + " y: " + _ymouse;
};
onMouseDown = function()
{
Sprite3._visible = true; // show "click!" text
};
onMouseUp = function()
{
Sprite3._visible = false; // hide "click!" text
};
Sprite3._visible= false; // init Sprite3 invisible

Press F9 to preview in Flash player.

Hit "Esc" to quit preview.

To export Flash file choose "File" > "Export SWF File". Type the file name and click OK. To insert Flash in your web page choose "File" > "View HTML Code". Select entire HTML code, right click mouse button and choose "Copy" from the popup menu. Click Close. Paste the code to your HTML page.



Author's URL: Selteco.com
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "onMouseMove, onMouseDown, onMouseUp in ActionScript"

Only registered users can write comment

No comments yet...