# Custom Event Capturing Problem

**URL:** <https://forum.kirupa.com/t/custom-event-capturing-problem/280269>\
**Category:** flash\
**Created:** [January 25, 2009, 11:27am UTC](https://forum.kirupa.com/t/custom-event-capturing-problem/280269 "2009-01-25T11:27:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![julcia01](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@julcia01](https://forum.kirupa.com/u/julcia01)\
**Post date:** [January 25, 2009, 11:27am UTC](https://forum.kirupa.com/t/custom-event-capturing-problem/280269/1 "2009-01-25T11:27:49Z")

</div>

Hey, code gurus.  
Today I came up with a problem. I created a new CustomEvents object which I want to use to let the main class located in .mxml file to know about an event which had finished it’s work in Crop class. However when I dispatch a CustomEvent from Crop class I can not catch it in my main .mxml file’s class.

CustomEvents class

```auto

package actions
{
    import flash.events.Event;

    public class CustomEvents extends Event
    {    
        public static const CROP = "crop";
        public function CustomEvents(type:String)
        {
            super(type);
        }
        
    }
}

```

Crop class

```auto

package actions
{
   ...
   private function cropImage():void
        {            
           ...
           sendCropEvent();                                                         
        }
        public function sendCropEvent():void
        {
            var e:CustomEvents = new CustomEvents(CustomEvents.CROP);
            dispatchEvent(e);
        }

```

snippets from Main Class

```auto

public function init():void
            {
              tabNavigator.addEventListener(IndexChangedEvent.CHANGE,windowChange);
              swfLoader = new Loader();
              var req:URLRequest = new URLRequest("file:/C:/flex/DSC00128.jpg");
              swfLoader.load(req);
              swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
                
               stage.addEventListener(CustomEvents.CROP,pictureInit);
                
            }

public function cropToolController():void
            {
                BitmapDataCrop.cropImage(); 
                flag = !flag;
            }

public function pictureInit(event:Event):void
            {
                Alert.show("Worked");
            }

```

Hope the code will be clear. If any questions please ask.
