Mouse Event Hierarchy : MouseEvent « Development « Flash / Flex / ActionScript






Mouse Event Hierarchy

 
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class Main extends Sprite
{
    private var firstListener:Sprite = new Sprite();
    private var secondListener:Sprite = new Sprite();

    public function Main(){
        firstListener.graphics.beginFill(0x0000ff, 1);
        firstListener.graphics.drawCircle(0, 0, 100);
        firstListener.graphics.endFill();

        secondListener.graphics.beginFill(0x00ff00, 1);
        secondListener.graphics.drawCircle(0, 0, 30);
        secondListener.graphics.endFill();
        addChild(firstListener);
        addChild(secondListener);
        firstListener.y = 300;
        secondListener.y = 250;
        this.stage.addEventListener(MouseEvent.MOUSE_DOWN, mainMouseDown);
        firstListener.addEventListener(MouseEvent.MOUSE_DOWN, firstMouseDown);
        secondListener.addEventListener(MouseEvent.MOUSE_DOWN, secondMouseDown);

        this.stage.addEventListener(MouseEvent.MOUSE_MOVE, mainMouseMove);
        firstListener.addEventListener(MouseEvent.MOUSE_MOVE, firstMouseMove);
        secondListener.addEventListener(MouseEvent.MOUSE_MOVE, secondMouseMove);
    }

    private function mainMouseMove(me:MouseEvent):void
    {
        trace(" stage move ");
    }

    private function firstMouseMove(me:MouseEvent):void
    {
        trace("first move ");
    }

    private function secondMouseMove(me:MouseEvent):void
    {
        trace("second move");
    }

    private function mainMouseDown(me:MouseEvent):void
    {
        trace(" stage down ");
    }

    private function firstMouseDown(me:MouseEvent):void
    {
        trace("first down ");
    }

    private function secondMouseDown(me:MouseEvent):void
    {

        trace("second down ");
    }
}
}

        








Related examples in the same category

1.Responding to Mouse and Key Events
2.Mouse Events and Overlapping Display Objects
3.mouseEnabled = false
4.Finding the mouse pointer's position
5.A custom mouse pointer
6.Handling Mouse Events "Globally"
7.Global Mouse Down Sensor
8.Mouse Events and Modifier Keys
9.All types of mouse event
10.Using MouseEvent in Conjunction with the Mouse
11.Add mouse listener to state
12.Creating Mouse Interactions
13.Add mouse move listener
14.Add mouse up and down listener
15.Rollover Test
16.Click Test
17.Post-Event Screen Updates