2017-10-12 3 views
-3

swf를 차례로로드하는 컨테이너를 만드는 코드를 개발했습니다. 각 swf가 끝나면 swf가 언로드됩니다. 다음 당신이로드 한 swf를 저장하고 다음에 시작할 때, 그것은 마지막 swf를로드합니다. 하지만 불행히도 난 내 출력 :(이납니다내가 얻는 이유 : 제공된 색인이 범위를 벗어났습니다. 오류가 있습니까?

SWFLoader의 'loader2'(part2.swf)로드

SWFLoader의 'loader1'(part1.swf)

SWFLoader의 'loader4'(part4로드 .SWF)는

로드

모든 SWF가

0

로드로드에 SWFLoader 'loader3'(part3.swf) 17,451,515,

0

SWFLoader의 'loader1'(part1.swf)

0

오류 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를 사용하십시오. 당신은 기꺼이 도와 줄 사람들을 존경하고, 대본을 얼굴에 던지지 않도록해야합니다. 그런 다음 오류를 생성하는 한 줄로 질문 범위를 좁히기 위해 디버깅을 활성화하여 도우미가 오류를 찾지 않고 오류의 핵심에 집중할 수 있도록하십시오. – Organis

+0

만약 누군가가 그들의 IQ에 대해 자랑하지만 그들의 코드는 완전한 초자연적 인 것처럼 보인다면 좋아할 것이다. – DodgerThud

답변

2

= 0 대신 -1 : 간단 할 수 있다면, 그래서 내가 AS3에 새로운 해요 ... 여기 코드입니다 var에 loaderIndex : 번호 = 0; 시도해보고 결과를 알려주십시오.

+0

... greeeeeeeeeeeeeeaaat ...하지만, 다음번 part1.swf를로드 한 후에 ... 문제가 돌아온다 ... – Pixier

+0

그게 낫겠 다 ... 꼭 끝났어 ... 끝났어 ... (loaderIndex == swfs.numChildren - 1) 완벽한 ... 당신의 도움을 rexamass ... – Pixier

+0

@Pixier 만약 그것이 올바른 해결책이 대답을 수락 하시겠습니까? – 3vilguy

관련 문제