我開發的代碼創建了一個接一個加載swfs的容器,當每個swf完成時它將卸載該swf。那麼它會保存你已經加載的swf,並且下次啓動時會加載最後一個swf。但遺憾的是我在我的輸出:(得到這個爲什麼我會得到:提供的索引超出界限錯誤?
的SWFLoader 'loader2'(part2.swf)加載
的SWFLoader 'loader1'(part1.swf)加載
的SWFLoader 'loader4'(第四部分.swf文件)加載
的SWFLoader 'loader3'(part3.swf)加載
所有SWF加載
的SWFLoader 'loader1'(part1.swf)
的RangeError:錯誤#2006:提供的索引超出範圍。
在flash.display使用::級DisplayObjectContainer/getChildAt() 在dblogo()
如何擺脫提供的索引是出界失誤? 我新的AS3所以,如果可以把它簡單... 下面是代碼:
import flash.events.FullScreenEvent;
import flash.display.StageScaleMode;
stage.scaleMode = StageScaleMode.EXACT_FIT;
stage.displayState = StageDisplayState.FULL_SCREEN;
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.SharedObject;
import flash.events.MouseEvent;
var mySO:SharedObject = SharedObject.getLocal("edbfngrwfh");
var reza:Number = -1;
var loaderIndex:Number = -1;
loaderIndex = mySO.data.my_vis;
if (!mySO.data.my_vis) {
loaderIndex = -1;
}
if (mySO.data.my_vis == 1) {
loaderIndex = 0;
}
if (mySO.data.my_vis == 2) {
loaderIndex = 1;
}
if (mySO.data.my_vis == 3) {
loaderIndex = 2;
}
if (mySO.data.my_vis == 4) {
loaderIndex = 3;
}
progress_mc.scaleX = 0;
var currentLoader:SWFLoader;
var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler});
swfs.append(new SWFLoader("part1.swf", {container:this.stage, autoPlay:false}));
swfs.append(new SWFLoader("part2.swf", {container:this.stage, autoPlay:false}));
swfs.append(new SWFLoader("part3.swf", {container:this.stage, autoPlay:false}));
swfs.append(new SWFLoader("part4.swf", {container:this.stage, autoPlay:false}));
function progressHandler(e:LoaderEvent):void {
progress_mc.scaleX = e.target.progress;
}
function childCompleteHandler(e:LoaderEvent):void {
trace(e.target + " loaded");
e.target.content.visible = false;
}
function completeHandler(e:LoaderEvent):void {
trace("all swfs loaded");
progress_mc.visible = false;
initCurrentLoader();
addEventListener(Event.ENTER_FRAME, trackSWFPlayback);
}
function initCurrentLoader() {
loaderIndex++;
trace(loaderIndex);
reza = loaderIndex
trace(reza);
mySO.data.my_vis = loaderIndex;
mySO.flush();
if (loaderIndex == swfs.numChildren) {
//reset back to 0 if the last swf has already played
//loaderIndex = 0;
//can't show stuff that was unloaded so lets stop
mySO.clear();
loaderIndex = -1
swfs.load();
trace("all done everyone gone");
removeEventListener(Event.ENTER_FRAME, trackSWFPlayback);
} else {
//dynamically reference current loader based on value of loaderIndex
currentLoader = swfs.getChildAt(loaderIndex);
trace(currentLoader);
trace(loaderIndex);
//make the content of the current loader visible
currentLoader.content.visible = true;
//fade it in
TweenLite.from(currentLoader.content, 0.1, {alpha:1});
//tell the current loader's swf to to play
currentLoader.rawContent.gotoAndPlay(1);
}
}
function trackSWFPlayback(e:Event):void {
//trace(currentLoader.rawContent.currentFrame);
//detect if the loaded swf is on the last frame
if (currentLoader.rawContent.currentFrame == currentLoader.rawContent.totalFrames) {
trace("swf done");
//hide and stop current swf
currentLoader.content.visible = false;
currentLoader.rawContent.stop();
//unload the swf that just played
currentLoader.unload();
//set up and play the next swf
initCurrentLoader();
}
}
this.addEventListener(Event.ENTER_FRAME, loadSWFs)
function loadSWFs(e:Event):void{
load_btn.visible = false;
swfs.load();
this.removeEventListener(Event.ENTER_FRAME, loadSWFs)
}
/* Click to Hide an Object
Clicking on the specified symbol instance hides it.
Instructions:
1. Use this code for objects that are currently visible.
*/
請使用您的巨大智商來正確地設置您的代碼。你應該尊重那些願意幫助的人,而不是把一個腳本亂成一團。然後,啓用調試將問題縮小到產生錯誤的一行,以便幫助者可以專注於錯誤的本質而不是搜索它。 – Organis
如果有人吹噓自己的智商,但他們的代碼看起來像是完整的newb廢話,那就得愛一個人。 – DodgerThud