|
-
[F8] Load Sequentially
I'm making a big flash movie which contains many separate flash files ( like a big puzzle and it's pieces ), but I want to load these files sequentially. So when the first movie has been loaded than it starts loading the second. Here's a piece from the AS:
var arrPaths:Array = new Array();
for (var k:Number=1;k<=9;++k) arrPaths.push(k+".swf");
var arrX:Array = new Array();
var arrY:Array = new Array();
load_btn.onRelease = function () {
for (i=0; i<nSwfCount; i++)
{
crtSwf = mcHolder.createEmptyMovieClip("swfHolder"+i, i);
crtSwf.loadMovie(arrPaths[i]);
crtSwf._x = arrX[i];
crtSwf._y = arrY[i];
}
}
Thank you,
YvorL
ps: I've read this "hope that helps. IF you need to know how to load movies sequentially with the MovieClipLoader.... lexicon has posted some sample scripts that work great!!" from : http://board.flashkit.com/board/hist.../693731-1.html , but I can't find it and don't know if it's helps.
-
Registered User
hi YvorL,
Welcome to FlashKit.
This post?
Please, use meaningful titles!
-
Yes I think this is what madzigian meant , but I don't know how to build in to my code... sorry for the title.
YvorL
-
Registered User
No problem
Here's the idea:
- create a function to load external file i
- when it finishes loading, load file i+1
- if it's the last, we're done
Here's the idea for the code:
code:
var i:Number = 1; // initial number
var total:Number = 6; // total of external files
function myLoadFunction(i:Number):Void
{
var mcl:MovieClipLoader = new MovieClipLoader();
var mcll:Object = new Object(); // listener
// finished loading
mcll.onLoadInit = function()
{
if (i <= total)
{
myLoadFunction(++i); // load the next
}
else
{
// all loaded
}
}
mcl.addListener(mcll);
mcl.loadClip(i+".swf", eval("mc"+i));
}
// start loading
myLoadFunction (i);
This loads 1.swf, 2.swf, ... inisde mc1, mc2, ...
-
holder and paths
Okay this is the code, but if I'm using a holder mc , and want to determine the paths whre to load these swf's what should I modify?
Code:
this.createEmptyMovieClip("mcHolder", 0);
load_btn.swapDepths(mcHolder);
up_btn.swapDepths(mcHolder);
down_btn.swapDepths(mcHolder);
left_btn.swapDepths(mcHolder);
right_btn.swapDepths(mcHolder);
speed=19
this.attachMovie("btnHolder", 1);
var nSwfCount = 9;
var arrPaths:Array = new Array();
for (var k:Number=1;k<=9;++k) arrPaths.push(k+".jpg");
var arrX:Array = new Array(-1754, 0, -1754, 0, -1754, 0, -1754, 0);
var arrY:Array = new Array(-1240, -1240, 0, 0, 1240, 1240, 2480, 2480);
load_btn.onRelease = function () {
for (i=0; i<nSwfCount; i++)
{
crtSwf = mcHolder.createEmptyMovieClip("swfHolder"+i, i);
crtSwf.loadMovie(arrPaths[i]);
crtSwf._x = arrX[i];
crtSwf._y = arrY[i];
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|