July 2003
Intermediate to advanced
896 pages
45h 43m
English
You want to check whether the mouse pointer is over a movie clip.
Use the onRollover( ) event
handler,
or
use the hitTest( ) method within an
onEnterFrame( ) method.
In many cases, the onRollOver( ) and
onRollOut( ) event handler methods, as shown in
Recipe 7.5, are the easiest way to
respond to the mouse pointer rolling over a movie clip. However, this
technique fails when you drag one clip over another, such as when
using a clip as a custom mouse pointer. Here is an example to
illustrate the point:
// Include theDrawingMethods.asfile from Chapter 4 for itsdrawRectangle( )and //drawCircle( )methods. #include "DrawingMethods.as" // Create arectangle_mcmovie clip on the Stage. _root.createEmptyMovieClip("rectangle_mc", 1); rectangle_mc.lineStyle(1, 0x000000, 100); rectangle_mc.beginFill(0, 100); rectangle_mc.drawRectangle(100, 200, 10); rectangle_mc.endFill( ); rectangle_mc._x = 100; rectangle_mc._y = 100; // CreateonRollOver( )andonRollOut( )methods such that when the mouse rolls on and // off the movie clip, it goes to 50% transparency and back. rectangle_mc.onRollOver = function ( ) { this._alpha = 50; }; rectangle_mc.onRollOut = function ( ) { this._alpha = 100; }; // Create acircle_mcmovie clip. _root.createEmptyMovieClip("circle_mc", 2); circle_mc.lineStyle(1, 0x000000, 100); circle_mc.beginFill(0xFFFFFF, 100); circle_mc.drawCircle(50); circle_mc.endFill( ); // CreateonPress( )andonRelease( )methods such ...
Read now
Unlock full access