That's right! onPress,onRelease,onRollOver and onRollOut have been removed.
Now, by now it should be clear, it's the DispatchEvent class to manage everything.
As usual:
you add a listener to the clip the mouse should interact with
you manage the code so that it executes the events within the methods called by the listener
The class I've developed creates a Sprite at runtime and associates the mouse events
Here is the class I've written:
Code:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
public class NoMoreOnPress extends MovieClip
{
private var size:Number=100;
public function NoMoreOnPress()
{
this.createClip();
}
public function createClip():void
{
var coke:Sprite=new Sprite();
coke.graphics.beginFill(0xFF6600);
coke.graphics.drawRect(0,0,this.size,this.size);
coke.graphics.endFill();
coke.x=stage.stageWidth/2-coke.width/2;
coke.y=stage.stageHeight/2-coke.height/2;
this.addChild(coke);
this.addCokeListeners(coke);
}
public function addCokeListeners(coke:Sprite):void
{
coke.addEventListener(MouseEvent.MOUSE_OVER,mouseIsOver);
coke.addEventListener(MouseEvent.MOUSE_OUT,mouseIsOut);
coke.addEventListener(MouseEvent.MOUSE_DOWN,mouseIsDown);
coke.addEventListener(MouseEvent.MOUSE_UP,mouseIsUp);
}
public function mouseIsOver(event:Event):void
{
trace('il mouse mi è sopra');
}
public function mouseIsOut(event:Event):void
{
trace('il mouse non mi tocca');
}
public function mouseIsDown(event:Event):void
{
trace('il mouse mi ha cliccato sopra');
}
public function mouseIsUp(event:Event):void
{
trace('il mouse è stato rilasciato sopra di me');
}
}
}
cya!
Bookmarks