Preloaders and components

two questions actually.

  1. i’m loading in external .jpgs into a movie clip. right now i have a “loading” animation being triggered inside that clip, but i want to replace it with percentage progress bars. i’ve known how to create these since flash 5 but i’ve always put the bar into the .swf that was being loaded. since these are .jpgs that option is out. i know you can target .getBytesLoaded() and .getBytesTotal() but my percentages are way off. my math is right ( (loaded/total) * 100) ), and works everywhere else, except when i target the clip that’s getting images loaded into. does that even make sense, and does someone know what could be causing that? even better, does anyone know where a good tutorial on multiple progress bars is?

  2. this is another progress bar question. there are no external movies being loaded. i’ve got a working bar in the first frame and it’s accurate until i drop in a component (combobox). now it seems like the progress bar won’t show until after the combo box loads (which if half of my movies size) so i’m getting a white screen until it comes in, and then the percentage is all wrong. anyone have this trouble.

ps. am i using components wrong. i can’t believe that a vector component can add so much k to my movie.

any help would be appreciated. thanks

The combobox component export some stuff in the first frame. Anything exported in first frame is preloaded before anything else in the movie, causing a load delay before the movie starts.

Check this:
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=29617&highlight=preloader

i’m loading in external .jpgs into a movie clip. right now i have a “loading” animation being triggered inside that clip,

I need to do that, can you tell me how you are doing it please? :beam:

very helpful link. for some reason i never thought to check the linkage on components. this will really help out a lot. thanks.

i’ve run into an interesting development on the .jpg progress bar. it’s a long read as i set it up so please be patient.

i’ve set up a new .fla to do some testing on my first question. i’ve got a dynamic text box that’s outputting figures so i can nail down the problem. if one want’s to view it, it’s online at

http://www.liddick.com/photo_album
(the album will be to show off my kids, hence the photos of my son)

here’s a rundown.

dynamic textbox - “display”
movie clip - “photoAlbum”

  • movie clip - “photoAlbum.holder”
  • movie clip - “photoAlbum.progressBar”
    • movie clip - “photoAlbum.progressBar.bar”

here’s my progress funtion on the first frame:

progressBar.onEnterFrame = function() {
bytesLoaded = photoAlbum.holder.getBytesLoaded();
bytesTotal = photoAlbum.holder.getBytesTotal();
progressBar.percent = (bytesLoaded/bytesTotal) * 100;
progressBar.bar._width = progressBar.percent;
display = "Loaded = “+bytesLoaded+” : Total = “+bytesTotal+” : Percent = "+progressBar.percent;
};

basically, it checks the getBytesLoaded and getBytesTotal of “holder”. then it turns it into a percentage, and then make a clip called “bar” the width of the percentage. for the sake of testing, i’m spitting out all the variables onto the stage into “display”

then i’ve got two buttons.

button 1 - loads a 59k .jpg into photoAlbum.holder
button 2 - loads 68k .swf into photoAlbum.holder

now here’s where the weirdness appears. when you click on button 1, check the info in “display”. when it’s done, getBytesLoaded is 59k, but getBytesTotal is only 2.8. i don’t know why flash is not seeing the correct k size on the .jpg.

clicking on button 2 shows that flash is correctly seeing the 68k on the .swf, which is why it works.

am i going out of my mind or is this a legitimate flash mx bug. i know people do what i’m trying to do. i must be doing something wrong.

any help would be appreciated. thanks

BeanBoy

let’s say that on the stage, there’s a movie clip called “Album”. inside of album, i’ve got an empty clip called “Holder” on one layer, and another movie clip called “Loading”. Loading is an animation (the word loading is blinking). i set the alpha to 0.

also on the stage, i’ve got a button. on release, it loads a .jpg into “Album.Holder” and it also set’s the alpha of “Album.Loading” to be 100. so while it’s loading, you see the animation. on “Album.Holder”, i’ve got an onClipEvent Data that set’s the alpha back to 0.

onClipEvent Data only triggers when the data is finished loading.

so basically, when the photoAlbum clip loads, it’s empty and the loading animation is invisible. when you click the button, the animation becomes visible and the .jpg starts to load. when it’s done loading, onClipEvent Data turns the alpha back to 0.

I’m sure there’s a more effective way to do it but i never really investigated it because i would prefer to use progress bars. my current example (with the loading animation being triggered) is at

http://www.liddick.com/photo_album

thanks

sliddick

I looked at your .swf in the link and I saw that the percent is a huge mumber, you can use Math.round() to make that smaller and round it to the closest whole percent, unless of course you like the huge numbers.

hehe… yeah i know…

it was just a quick study to disect the problem so i cut a few corners.

i still find it odd that the .jpg and the .swf are basically the same size, but that flash sees one as 2.8 k and the other as 60k.

weird.

Is that not because the 60k is bytes? Did you divide the answer by 1024 to get Kb?

i’m just rounding things out when i explain the k sizes. in the example i have up, the numbers up top in my display text box are the accurate numbers.

the .jpg and the .swf are really close in size. also, the progress bar clip is the same clip detecting the percentage to both the .jpg and the .swf.

here are the actual numbers

.jpg

bytesLoaded - 59397
bytesTotal - 2484

.swf

bytesLoaded - 68432
bytesTotal - 68432

flash isn’t getting accurate bytesTotal on the .jpg. i can’t find any information about this either.

Cant help there sorry, I havnt loaded an external .jpg before. What is the actual size of the .jpg in Kb?