Skip to main content
Inspiring
June 9, 2006
Question

what's wrong with this code?

  • June 9, 2006
  • 4 replies
  • 327 views
Don't get any error msg's, just a blank stage. Any ideas what's wrong?

Frame 1 of Main.swf:
-------------------------------
if (init == undefined) {
var aSWFs:Array = new Array("an1.swf", "an2.swf", "an3.swf");
var nSWFs:Number = aSWFs.length;
var nCurSWF:Number = 0;
var aSWFmcs:Array = new Array();
for (var n=0; n<=nSWFs; n++) {
aSWFmcs.push(createEmptyMovieClip("swf"+n, n));
}
var mcl:MovieClipLoader = new MovieClipLoader();
var Listen:Object = new Object();
Listen.onLoadInit = function(target) {
trace(target);
if (nCurSWF <= nSWFs) {
nCurSWF++;
// load the next swf
mcl.loadClip(this.aSWFs[nCurSWF], aSWFmcs[nCurSWF]);
} else {
// done loading... start playing
aSWFmcs[0].gotoAndPlay(2);
}
}
mcl.addListener(Listen);
mcl.loadClip(this.aSWFs[0], aSWFmcs[0]);

init = 1;
}

---------------------------
This code is in each 'called' swf:
---------------------------
Frame 1:
stop();

Last Frame:
stop();
// if the Current SWF is not the last increment nCurSWF, else set it to
the start
if (nCurSWF < nSWFs) {
nCurSWF++;
} else {
nCurSWF = 0;
}
aSWFs[nCurSWF].gotoAndPlay(2);
This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
June 10, 2006
you're welcome.
Inspiring
June 9, 2006
Got the answer (_global variables)
All three swfs are loading and the first one is playing.


Here's the last sticking point:
in each 'loaded swf' the final frame holds this code:

------------------------------------------
stop();
// if the Current SWF is not the last increment nCurSWF, else set it to
the start
if (_global.nCur < _global.nClips) {
_global.nCur++;
} else {
_global.nCur = 0;
}
trace(_global.nCur);
eval("_level0.swf"+_global.nCur+".gotoAndPlay(2)"); <--the problem


the trace reports the right number
(loaded swfs are _level0.swf0, _level0.swf1, _level0.swf2)

if I substitute the hard code .... _level0.swf1.gotoAndPlay(2);
then the next swf plays.

What's the right code to accomplish the deed??
kglad
Community Expert
Community Expert
June 10, 2006
try:

Inspiring
June 9, 2006
In article <e6bv4k$a6v$1@forums.macromedia.com>,
webforumsuser@macromedia.com says...
> your first swf should load without problem or you have a path/file name problem
> in aSWFs. to remedy, use the correct path/file names.
>
> your subsequent swfs will fail to load because of your use of "this" in
> this.aSWFs[nCurSWF] within your Listen handler. "this", in that location,
> refers to Listen and aSWFs are not defined within that scope.
>
> to remedy, remove the word "this".
>
>
OK... applied remedies and the first gotoAndPlay(2) works... first SWF
plays through.

But, subsequent SWFs aren't playing... added a trace and the variables
are undefined:
nCurSWF - current swf number
nSWFs - the total number loaded
aSWFs - an array of references to the movie clips that the swf's are
loaded into.

I tried making them 'public' in the main.swf... that threw an error.
How do I make those available to all loaded swf's???


kglad
Community Expert
Community Expert
June 9, 2006
your first swf should load without problem or you have a path/file name problem in aSWFs. to remedy, use the correct path/file names.

your subsequent swfs will fail to load because of your use of "this" in this.aSWFs[nCurSWF] within your Listen handler. "this", in that location, refers to Listen and aSWFs are not defined within that scope.

to remedy, remove the word "this".