2017-10-12 3 views
-3

swfを次々に読み込むコンテナを作成するコードを開発しました。各swfが終了すると、そのswfをアンロードします。あなたが読み込んだswfファイルを保存し、次回起動時に最後のswfファイルを読み込みます。残念ながら、私は私の出力:(でこれを取得してい私が取得する理由:指定されたインデックスが範囲外のエラーです。

にSWFLoader 'loader2'(part2.swf)ロード

にSWFLoader 'loader1'(part1.swf)

にSWFLoader 'loader4'(第4報をロード.swfファイル)すべてのSWFが

をロード

をロード

にSWFLoader 'loader3'(part3.swf)をロード

にSWFLoader 'loader1'(part1.swf)

例外RangeError:エラー#2006:指定したインデックスが範囲外です。指定されたインデックスを取り除くためにどのようにdblogoで は、flash.display ::のDisplayObjectContainer/getChildAt()で

()

は、境界エラーの出ているのですか?私はあなたがインデックスに開始すべきだと思う

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. 
*/ 
+5

あなたのコードを正しくフォーマットするためには、あなたの巨大なIQを使用してください。あなたは喜んで援助しようとする人々を尊重し、スクリプトの混乱を彼らの顔に投げ捨てないようにしなければなりません。次に、エラーを生成する1行に質問を絞り込むためにデバッグを有効にします。そのため、ヘルパーはエラーを探す代わりにエラーの本質に集中することができます。 – Organis

+0

誰かが自分のIQを誇っているが、そのコードが完全な新しいナンセンスのように見えるのなら、大好きです。それが行われます... itttttttttttttttttttttttttttttttだという – DodgerThud

答えて

2

= 0の代わりに-1: それは簡単な作ることができので、もし私がAS3に新たなんだ...ここ は、コードでのvar loaderIndex:数= 0; これを試してみて、結果を教えてください

+0

[OK]を... (loaderIndex == swfs.numChildren - 1)それは完璧になります... あなたの助けをrezamassのためのtnx ... – Pixier

+0

.... ... greeeeeeeeeeeeeaaaat働いていた...しかし、次回のためにpart1.swfをロードした後...問題が戻ってくる – Pixier

+0

@Pixierそれが正しい解決策なら、この答えを受け入れるためにクリックできますか? – 3vilguy

関連する問題