Groups | Blog | Home
all groups > flash actionscript > may 2007 >

flash actionscript : Return function once loadClip is complete.


TylerKiwi
5/25/2007 7:34:21 PM
Ok, I think this will prob. be simple for you AS experts out there, here's my
code:
[CODE]
function loadPic(whichPic):Void {
var i:Number = 0;
var pic:String;

var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();

mclL.onLoadProgress = function(target,loaded,total){
trace("loading:"+total+"bytes");
}

mclL.onloadInit = function(){
trace("finished loading");
}
mcl.addListener(mclL);

switch (whichPic)
{
case "steam":
pic = "flash/flashImage-stream.jpg";
break;
case "house2":
pic = "flash/flashImage-house2.jpg";
break;
case "house3":
pic = "flash/flashImage-house3.jpg";
break;
case "balcony":
pic = "flash/flashImage-balconey.jpg";
break;
}

mcl.loadClip(pic,mainImage);
}
[/CODE]
What I want to do, is force the function to ONLY return once the file has
finished loading. How can I do this??
dfm_
5/25/2007 7:41:07 PM
TylerKiwi
5/25/2007 7:46:24 PM
It doesn't really matter ... I have another function that moves on to the next
line once this function has completed (when it returns) - I know the return is
set to :Void, but the main question remains ... how do I STOP the return of
this function until the loadClip has completed?

Thanks
dfm_
5/25/2007 7:54:16 PM
mm maybe:

delete [b]loadPic();[/b] or [b]delete loadPic;[/b]

TylerKiwi
5/25/2007 7:58:05 PM
GWD
5/26/2007 12:00:00 AM
well you could do it by churning up CPU cycles , but it doesn't make much sense
to do that.

What do you want to have happen after its finished? If its more code on the
same frame then bundle that inside a function (so it doesn't get executed now
because it hasn't been called) and call it after the load - where you have :
trace("finished loading");


TylerKiwi
5/26/2007 4:47:03 PM
I think I solved it ... because the function was completing before the
onLoadInit was able to fire. SO I moved all the MovieClipLoader and Listener
stuff outside of the function, and then just called the .loadClip from within
the function.

That seems to work! :) Thx for replying.
AddThis Social Bookmark Button