Hey fellow Kirupians,
I am very new to AS3. As I’m working on a simple XML photo gallery, I am having a bit of trouble making my Slide class successfully dispatch an MOUSE_OVER and MOUSE_OUT event to the Main class.
Main.as
// add a new slide
var slide:Slide = new Slide(_slideHolder, "slide_" + no, _xml.img[no], x, no);
slide.addEventListener(Event.COMPLETE, imageLoaded);
slide.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
slide.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
_slides.push(slide);
Slide.as (extends ImageLoader.as which Extends EventDispatcher)
public override function loaded(e:Event):void {
// assign some events
_image.addEventListener(MouseEvent.ROLL_OVER, mouseOver);
_image.addEventListener(MouseEvent.ROLL_OUT, mouseOut);
TweenPlugin.activate([ColorMatrixFilterPlugin]);
// tell parent we've loaded
dispatchEvent(new Event(Event.COMPLETE));
}
Further, I have the two following functions:
public function mouseOver(e:MouseEvent):void {
dispatchEvent(new MouseEvent(MouseEvent.ROLL_OVER));
}
public function mouseOut(e:MouseEvent):void {
dispatchEvent(new MouseEvent(MouseEvent.ROLL_OUT));
}
When I hover over my sprites, the functions inside Slide.as gets triggered - but they don’t pass the event to Main.as as I would have expected.
Strange thing is that the Event.COMPLETE gets triggered inside Main.as.
What am I doing wrong?
Kind regards,
Nitech