Question

I'm just trying to remove a movie clip from the stage upon double clicking

package  {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import fl.motion.MotionEvent;

    public class Main extends MovieClip{

        var thingeh:Things;

        public function Main() {
            thingeh = new Things;
            stage.addEventListener(MouseEvent.CLICK, onClick);
            stage.addEventListener(MouseEvent.DOUBLE_CLICK, onDouble);

        }

        public function onClick(event:MouseEvent)
        {
            addChild(thingeh);

        }
        public function onDouble(event:MouseEvent)
        {
            if(thingeh)
            removeChild(thingeh);

        }
    }

}
Was it helpful?

Solution

public function onDouble(event:MouseEvent)
{
    if( thingeh && contains(thingeh) )
    {
        removeChild(thingeh);
    }
}

Also, You may want doubleClickEnabled = true within your constructor.

Do note, MouseEvent.CLICK gets fired TWICE along with a MouseEvent.DOUBLE_CLICK event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top