Hello all I need a little help preloading images from my xml file. I have dynamic text and dynamic images being loaded into movie clips on the stage
when I preload my xml file everything goes fine except my images hang for a while before they get loaded into there respected movieclips even when my preloader reaches 100% they are still hanging trying to load and eventually they will load.
I am able to preload my xml file by using my_xml.getBytesTotal() and my_xml.getBytesLoaded but I noticed that only includes what data is in the xml file “mainly text” and not the image paths to the actual image files. How would I go about preloading everything?
To matthewjumps: thanx for the reply I am a little confused because of the way I have set up my xml to load images into my movie clip "thumb_mc"
I am currently using a this.onEnterFrame to try and get the bytesTotal()/bytesLoaded () of the movie clip “thumb_mc”
here is my code
this.onEnterFrame = function() {
var loaded:Number = thumb_mc.getBytesLoaded()/thumb_mc.getBytesTotal() * 100;
loader._xscale = loaded;
}
should I be using a this.onEnterFrame? cause I was already using this.onEnterFrame to get bytesLoaded and the bytesTotal of my xml file
here is the code that I am using to load my image into thumb_mc
I’m calling the image paths from XML and assigning them to variables in Flash with FOR like…
for (i = 0; i < total; i++) {
this.createEmptyMovieClip("thumb" + i, i);
this["thumb" + i].loadMovie(thumb*);
this["thumb" + i].getBytesLoaded() == this["thumb" + i].getBytesTotal() ? DO SOMETHING : null;
}
But it doesn’t seem to work. What I had it doing was displaying a loading animation, like a black dot blinking or something like that, and then when the image was loaded, the black dot MC moved forward a frame to a button with different onPress and onRelease
properties.
AND… I tried tracing the …getBytesTotal, and no matter how I wrote it, the trace always returned 0. I’m not
sure why, as even though the trace returned 0, when I tested the movie with the simulated download, the thumbnails still lagged because they were being loaded.
To matthewjumps thanx for your help and reply I tried to clean up a little bit I am just starting out in flash and kind of picking up here and there through theses forms so there is probally some code in there that I dont need . Here is the link to the fla file again thanx for your help http://webpages.charter.net/theartofjae/upload.fla
heres an intersting comment about using XML.getBytesLoaded()
“If you attempt to use this example to load a local file that resides on your hard disk, this example will not work properly because in test movie mode Flash Player loads local files in their entirety.”
To:matthewjumps I know my .fla file is kind of crazy. The code I am trying to get to work is on frame 3 inside a movie clip called “Update_Container” on frame 3 if you double click inside that and look at my actions layer you will see all the code that I am using. I know its burried deep but I thought it would give me more control over my movie clips if I worked this way instead of putting everything on the main time line hope this helps
Last night I made some progress on the thumb_mc movie clip layer I added this code after searching through the fourms.
i replaced what I thought was correct “==” with this “!=” and it worked that really baffles me because when I write “==” it does not work.
Well I will keep trying thanx for all your help.
Status Update:
I used the following code to get it working. I thought I was supposed to use a delete this.onEnterFrame after and onEnterFrame event but when I do the preloader will not work so I just removed it.
this.onEnterFrame = function() {
var bytesLoaded = thumb_mc.getBytesTotal();
var bytesTotal = thumb_mc.getBytesLoaded();
var percentLoaded = bytesLoaded/bytesTotal * 100;
myloader._xscale = percentLoaded;
myText.text = Math.round(percentLoaded) + "%";
}