> > Tutorials > T1028

onMouseMove, onMouseDown, onMouseUp in ActionScript.

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

NOTE: Minimum Flash Designer version 5.0.17 (verify revision number under "Help" > "About...", download update if required)

  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 "Alt+F4" to close preview.

To export Flash file choose "File" > "Export Flash 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.

Products | Purchase | Downloads | Support | Flash Tutorials | Contact
Copyright © 1999-2017 Selteco Software, Inc., ph: +1 810 377 5778