I have a class called SlideShow that extends Sprite. I also have a reference to a calls called bio which also extends a Sprite. In the SlideShow class I have a dispacthEvent that fires in a function. The problem I’m getting is the listener in the Bio class is not listening correctly. I thought this would bubble up as both Sprites are of the same parnet.
SlideShow Class
package com.slideshow {
import flash.display.Sprite;
import flash.events.Event;
import com.slideshow.Bio;
public class SlideShow extends Sprite{
private var _bio : Bio;
public function SlideShow( ){
init();
onShowNextSlide( 0 );
}
private function init() : void {
_bio = new Bio();
_bio.x = 620;
_bio.y = 12;
addChild(_bio);
}
public function onShowNextSlide( ID : Number ) : void {
dispatchEvent(new Event('onNextSlide'));
onStartSlideChange( ID );
}
Bio Class
package com.slideshow {
import flash.display.Sprite;
import flash.events.Event;
public class Bio extends Sprite{
public function Bio(){
this.alpha = 0;
this.addEventListener('onNextSlide', onRefresh );
}
private function onRefresh( evt : Event ) : void {
trace("Refresh Bio");
}
}
}
It works if I use the line
_bio.dispatchEvent(new Event('onNextSlide'));
But the problem with the above is I will have other classes that need to listened for the same dispatched event. Lets say I had 2 bio Sprites that needed to listen to the same event.