首页 文章

Flash MovieClipLoader实例行为不正确

提问于
浏览
0

我目前有几个动画片段,我加载到另一个movieclip container . 我使用MovieClipLoader类来加载它们并使用 onLoadProgressonLoadStartonLoadInitonLoadCompleteonLoadError 个侦听器 .

onLoadProgess 监听器中,我监听加载的字节和总字节数,并将百分比放入另一个movieclip 's (that I put on the stage temporarily to show the loading) textbox. Here is the problem, the loading movieclip begins playing on the 40% loaded mark and does not wait to load 100%. This is weird and I don' t,了解我可能做错了什么 . 这是我的代码:

// loading icon to show progress
var loading_icon:MovieClip = new MovieClip();

// load PassionPurpose.swf
var passionPurposeLoader = new MovieClipLoader();
var passionPurpose:MovieClip = this.container.createEmptyMovieClip("passionPurpose", this.container.getNextHighestDepth());
passionPurpose._y = groupOverviewHeight;

passionPurposeLoader.onLoadInit = function (targetMc:MovieClip) {
 trace("Init... "+PPFile);

 loading_icon._visible = false;
 loading_icon.unloadMovie();
}

passionPurposeLoader.onLoadStart = function (targetMc:MovieClip) {
 loading_icon = passionPurpose._parent.attachMovie("loading_icon_ch1","loading_icon_ch1",passionPurpose._parent.getNextHighestDepth());

 loading_icon._x = 245 - loading_icon._width/2;
 loading_icon._y = 207 - loading_icon._height/2;

 loading_icon._visible = true;
}

passionPurposeLoader.onLoadComplete = function (targetMc:MovieClip) {
 trace("Complete... "+PPFile);

 loading_icon._visible = false;
 loading_icon.unloadMovie();
}

// progress function
passionPurposeLoader.onLoadProgress = function(targetMc:MovieClip, loadedBytes:Number, totalBytes:Number) {
 // determine percentage
 var percentage:Number = Math.round(loadedBytes / totalBytes * 100);

 trace("Loading... "+loadedBytes+"/"+totalBytes+" "+PPFile);
 loading_icon.loading_txt.text = percentage + "%";

 if (loadedBytes == totalBytes) loading_icon.unloadMovie();
}

// there was an error loading the movieclip
passionPurposeLoader.onLoadError = function (targetMC, errorCode) {
 trace("Error");
}

有没有人有某种解释或解决方案?

2 回答

  • 0

    我不太喜欢as2但似乎你可以在加载电影(passionPurpose)的第一帧中停止,所以当加载第一帧时,它只停在那里 . 当加载完成然后播放电影 . 或者在onLoadStart中暂停电影( passionMovie.gotoAndStop(1); ),当它完成时(即onLoadComplete)播放它 . 还有一件事,你可能不需要对load_icon进行两次unloadMovie调用,要么将它放在onLoadComplete中,要么放在onLoadProgress中 .
    如果它不起作用,那么你可以尝试让它看不见,直到它完全加载 .

  • 1

    正如bhups建议的那样,在加载的剪辑的第一帧上设置停止动作,或者在它们开始加载时立即停止它们 . 一旦加载帧,动画片段就会自动播放,除非你告诉他们不要 .

相关问题