Hey all,
So I have two classes talking to each other with EventDispatcher. One is a thumbnail of an image, and when it’s clicked, it sends an event to the other class to display the full size version. I’m using a MovieClipLoader instance to load the full version (and the thumbnail).
Here’s how it’s sending the event from the thumbnail class:
private function initButton () {
this.loadMe.onPress = function () {
this._parent.sendEvent();
}
}
private function sendEvent () {
// create eventObject to be passed to anything that is listening
var eventObject:Object = {target:this, type:'onPhotoSelected'};
eventObject.photo2load = this.photoID;
trace ("send Event " + eventObject.photo2load);
// dispatch event that tells any listeners to load the full version
dispatchEvent(eventObject);
}
And here’s what’s receiving the event:
public function onPhotoSelected (listenObj) {
trace ("event received");
this.loadPhoto(listenObj.photo2load);
}
public function loadPhoto (photoID:Number) {
trace ("photoID " + photoID);
fullImageLoader.loadClip(this._parent.fullImageURL + this._parent.fileNames[photoID] + ".jpg", this);
}
The problem I’m having is it loads the full size version ONCE. After that, it no longer receives the event. The (“event received”) trace no longer comes through. But the (“send event”) trace continues to work.
The other weird part is if I comment out the loadClip, then the events come through just fine on both sides. But it’s like after it loads an image once, it quits responding to that event (‘onPhotoSelected’). Is there some kind of mis-communication between the events of the MovieClipLoader and my custom event or something?
Any theories appreciated!