Groups | Blog | Home
all groups > flash actionscript > april 2005 >

flash actionscript : How to wait until jpgs have loaded



flashmaster52240
4/2/2005 5:54:32 PM
I'm dynamically loading in jpgs in this fashion:



for(i=0; i < totalNum; i++)
{
arr_fileName = fromSomeXMLChildNode;
currentClip = createEmptyMovieClip("clip_" + arr_fileName, i );
currentClip.loadMovie(folderName + "/thumbnails/" + arr_fileName);
}

And I want to do this right after:
currentClip._x = currentClip._width + 10;

But it wont since currentClip's dimensions at that point are
non-existent...how do I wait for all the images to have been done loading?

Also, this is within my loadXML function...I couldn't figure out another way
to wait until the XML was loaded before loading up the clips. Basically, I'm
having problems with understanding the loading mechanisms :).
Mr Tomo
4/2/2005 7:50:03 PM
currentClip.onEnterframe =function(){ //if image loaded
if(currentClip.getBytesLoaded() >= currentClip.getBytesTotal()){ //stop
onEnterFrame currentClip.onEnterframe =false; //shift image ...... } or in AS
2.0, use the MovieClipLoader() class
flashmaster52240
4/2/2005 8:31:39 PM
OK I've decided to use the MovieClipLoader. One problem...if I'm using it to
load a jpg into a clip whose name isn't determined until runtime, how do I
refer to that clip?

For example:

var currentClip:MovieClip;
var movieloader:MovieClipLoader = new MovieClipLoader;

movieloader.addListener({ onLoadInit: function(){
whatRef._x = whatRef.width
}});

for(i=0; i <total; i++)
{
currentClip = createEmptyMovieClip("clip" + i, depth)
movieloader.loadClip(jpg, currentClip
}

As you can see, I'm trying to access currentClip in the loadInit listener.

kf_w-l-media
4/3/2005 5:25:43 AM
im no pro but heres what i think you are looking for // this has target_mc
acting as an eval for the mc you are loading the clip into at runtime
myListener.onLoadInit = function(target_mc:MovieClip) { target_mc._x=
target_mc._width; target_mc._height = 100; } hope im right KF
AddThis Social Bookmark Button