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
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
package actions
{
...
private function cropImage():void
{
...
sendCropEvent();
}
public function sendCropEvent():void
{
var e:CustomEvents = new CustomEvents(CustomEvents.CROP);
dispatchEvent(e);
}
snippets from Main Class
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.