听起来很简单吧?显然不是,因为之前为我做过无数次的工作现在不会工作,我不知道为什么,我已经尝试了一切。这是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);
}
答案 0 :(得分:1)
听起来像playButton没有抓到那个事件。 尝试
stage.addEventListener(MouseEvent.CLICK, playClick);
和
function playClick(e:MouseEvent):void {
trace(e.target)
if(e.target == preloader.playLoad.playButton)
{
gotoAndPlay(2)
}
}
并查看将抛出的痕迹,希望它有所帮助