J'ai développé un code qui crée un conteneur qui charge les swfs les uns après les autres et quand chaque swf se termine, il décharge ce swf. puis il enregistre quel swf vous avez chargé et la prochaine fois que vous démarrez, il charge ce dernier swf. mais malheureusement je reçois dans ma sortie :(Pourquoi je reçois: L'index fourni est une erreur hors limites Pourtant?
SWFLoader 'loader2' (part2.swf) chargé
SWFLoader 'loader1' (part1.swf) chargé
SWFLoader 'loader4' (part4 .swf) chargé
SWFLoader 'loader3' (part3.swf) chargés
tous swfs chargés
SWFLoader 'loader1' (part1.swf)
RangeError: Erreur # 2006: L'indice fourni est hors des limites.
à flash.display :: DisplayObjectContainer/getChildAt() à dblogo()
Comment se débarrasser de l'indice fourni est hors d'erreur de limites? Je suis nouveau AS3 donc si on pouvait faire simple ... Voici le code:
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.
*/
S'il vous plaît utilisez votre énorme QI pour formater votre code correctement. Vous êtes censé respecter les gens prêts à aider, ne pas jeter un gâchis de script sur leurs visages. Ensuite, activez le débogage pour restreindre votre question à la ligne qui génère l'erreur afin que les utilisateurs puissent se concentrer sur l'essence de l'erreur plutôt que de la rechercher. – Organis
Je dois aimer si quelqu'un se vante de son QI mais son code ressemble à un non-sens complet. – DodgerThud