Question

Sounds simple right? Apparently not, because what has worked countless times before for me won't work now, and I have no idea why, I have tried everything. This is for a preloader for as3.

stop();
this.addEventListener(Event.ENTER_FRAME, loading);

function loading(e:Event):void {
    var total:Number = this.stage.loaderInfo.bytesTotal;
    var loaded:Number = this.stage.loaderInfo.bytesLoaded;

    preloader.bar_mc.gotoAndPlay(Math.floor((loaded/total)*100));

    if (total == loaded) {
        this.removeEventListener(Event.ENTER_FRAME, loading);
        preloader.playLoad.gotoAndPlay(2);
    }
}

preloader.playLoad.playButton.addEventListener(MouseEvent.CLICK, playClick);

function playClick(ev:MouseEvent):void {
    gotoAndPlay(2);
}
Était-ce utile?

La solution

Sound like playButton didn't catch that event. try

stage.addEventListener(MouseEvent.CLICK, playClick);

and

function playClick(e:MouseEvent):void {

    trace(e.target)

    if(e.target == preloader.playLoad.playButton)
    {
        gotoAndPlay(2)
    }
}

and look what trace will throw, hope it helps

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top