# Custom events are driving me mad! :'(

**URL:** <https://forum.kirupa.com/t/custom-events-are-driving-me-mad/250376>\
**Category:** flash\
**Created:** [January 29, 2008, 2:55am UTC](https://forum.kirupa.com/t/custom-events-are-driving-me-mad/250376 "2008-01-29T02:55:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![black\_angel082](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@black\_angel082](https://forum.kirupa.com/u/black_angel082)\
**Post date:** [January 29, 2008, 2:55am UTC](https://forum.kirupa.com/t/custom-events-are-driving-me-mad/250376/1 "2008-01-29T02:55:17Z")

</div>

I need to start really getting into AS3 events, but I’m really confused… I have read a lot on custom events but I still can’t make them work…

Custom Event:

```auto
package Game{
    import flash.events.Event;
    import flash.geom.Point;
    public class MouseSelection extends Event {
        public static const SELECTION:String="selection";
        public var StartingPoint:Point;
        public function MouseSelection(type:String,bubbles:Boolean=false,cancelable:Boolean=false) {
            super(type,bubbles,cancelable);
        }
        public override function clone():Event {
            return new MouseSelection(type, bubbles, cancelable);
        }
        public override function toString():String {
            return formatToString("MouseSelection","StartingPoint","type","bubbles","cancelable");
        }
    }
}

```

Main Class :

```auto
package Game{
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.geom.Point;
    import flash.display.Shape;
    import Game.MouseSelection;
    public class Main extends MovieClip {
        private var StartingMousePoint:Point;
        private var MouseIsDown:Boolean=false;
        private var MouseSelectionRect:Shape=new Shape ;
        function Main() {
            var Exemple:Character=new Character();
            Exemple.x=50;
            Exemple.y=50;
            addChild(Exemple);
            addChild(MouseSelectionRect);
            stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
            stage.addEventListener(MouseSelection.SELECTION,mouseSel);
        }
        public function mouseSel(event:MouseSelection) {
            trace(event); // DOES NOT WORKS
        }
        public function mouseDownHandler(event:MouseEvent):void {
            MouseIsDown=true; // WORKS
            StartingMousePoint=new Point(event.stageX,event.stageY);
            var MouseSelectionEvent:MouseSelection=new MouseSelection(MouseSelection.SELECTION);
            MouseSelectionEvent.StartingPoint=StartingMousePoint;
            dispatchEvent(MouseSelectionEvent);
            trace("Dispatch!");
        }
    }
}

```

I have no idea what I have done wrong… but it just doesn’t work! Also, eventually this will need to be in another class (display object) than the main class, it’s just easier to work all in the main class at first.
