Thursday, March 10, 2011

Marithè Francois Girbaud Outlet

Moving an object in Flash using the mouse wheel (mouse wheel event)

In this tutorial we'll see how you can move an object (in this example a movie clip) by using the mouse wheel (event in jargon called the "mouse wheel").

Given a movie clip on the Stage (called "clip_mc"), the first frame we write the following code:

stage.addEventListener (MouseEvent.MOUSE_WHEEL, MOVEit)

MOVEit function (evt: MouseEvent)

{if (evt.delta> 0) {

clip_mc.y + = 2;} else {

clip_mc.y-= 2;}

} As you can see the key to whether we are moving the mouse in one direction or another is the property "delta" of the MouseEvent class. If it is negative the clip down (clip_mc.y + = 2) on the contrary, salt.

0 comments:

Post a Comment