Now: Tutorial for Web and Software Design > Flash > Flash Video > Flash Content
> onMouseMove, onMouseDown, onMouseUp in ActionScript [Bookmark it]
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.


[Bookmark][Print] [Close][To Top]
  • Prev Article-Flash:

  • Next Article-Flash:
  • Related Materias
    Motion Animations
    Shape Transformations
    Effects on Animations
    Generating and Publishing 
    Introduction to ActionScri
    Examples of ActionScript 2
    Handwriting Flash Movie
    Movie Clips
    Buttons in Flash
    Attaching Movie Clips usin
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial