> > Tutorials > T1025

MouseOver in ActionScript.

Create an object that appears when the user moves mouse cursor over some area.

prompt text

  1. Launch Flash Designer and choose “Blank Animation”. Choose “Frame” > “Frame Size” to set movie dimensions. Enter 300 x 300 and click OK.
  2. Choose “Rectangle” tool and draw 2 rectangles inside the frame. First rectangle will become active area, second rectangle will be hidden and appear on mouseover.
  3. Make sure the second rectangle remains selected. Choose “Item” > “Fill Color” and change the color to R:255 G:255 B:192, opacity to 80%. Click OK.
  4. Choose “Edit” > “Convert to Sprite”. You should see “Sprite3” as the name of the rectangle.
  5. Choose “Item” > “Placement properties” and check “ActionScript” target. If necessary rename the sprite to Sprite3. Click OK.
  6. Choose “Select” tool and select the first rectangle.
  7. Choose “Action” > “OnOver”, select “ActionScript” and enter the code:Sprite3._visible = 1;
  8. Choose “Action” > “OnOut”, select “ActionScript” and enter the code:Sprite3._visible = 0;
  9. Sprite3 must be initially invisible. To hide it choose “Frame” > “ActionScript” and enter the code to execute on frame entry:Sprite3._visible = 0;
  10. Choose “Frame” > “Frame Delay” and check “Stop” options to create static frame. Click OK.
  11. Press F9 to play the file. Hit “Alt+F4” to close preview.

Double click “Sprite3” object and add text to the sprite with the text tool. To quit the sprite choose “Movie” > “Go to Main Thread”

Download source project (1 kb)

get flash