Question for beginners: Stop () hide EnventListener

advertisements

That seems a very simple question but I don't found anything on internet (or I don't enter the good words on google).

I try to implement a gallery of image with two buttons on each side of the picture to go to the next or the previous image. Very simple!

This is my code:

leftButton.addEventListener(MouseEvent.CLICK, ButtonLeftHandler);
rightButton.addEventListener(MouseEvent.CLICK, ButtonRightHandler);

function ButtonLeftHandler(event:MouseEvent):void {
    trace("Mouse Button Left clicked");
    picIndex--;
    uiLoader.source = picIndex + ".jpg";
    gotoAndPlay(23);
} 

function ButtonRightHandler(event:MouseEvent):void {
    trace("Mouse Button Right clicked");
    picIndex++;
    uiLoader.source = picIndex + ".jpg";
    gotoAndPlay(23);
} 

stop();
trace("Sequence Stopped");

uiLoader and picIndex are defined in a earlier frame..

On my output, I get

Sequence Stopped

When I clicked on a button. I don't get the trace message "Mouse button left..." My sequence is blocked.

Why ?!

Thank you


Your buttons have to have the instance names you're using (leftButton and rightButton) assigned in the Properties panel. They also have to be available (on Stage) on the frame that is running this code.