Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you make a progress bar work? 2

Status
Not open for further replies.

JoshT172

Programmer
Jul 11, 2002
13
US
I'm trying to make a progress bar in a flash movie. I found a tutorial on a website :

(
I followed everything step-by-step and the flash movie still won't display until EVERYTHING is downloaded. (I thought that flash movies could still be displayed WHILE they are being downloaded). Is there some kind of setting for it to play while being downloaded? (NOTE: I do not have the setting 'paused at start' set).

Flash Version: MX (Version 6).
 
The best way I found to do a percentage bar was to create a movie clip. Inside that, create an animation of a bar getting longer (the progress bar), but make it exactly 100 frames long.
Then, work out the percentage with the following code:

total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
percent = int((loaded_bytes/total_bytes)*100);

Call your progress bar movie clip 'bar' and use the following code:

bar.gotoAndStop(percent);

Put all the code in the very first frame of your movie (along with the rest of your preloader code).

I'll let you figure out how it works...

Regards
 
Alternatively you can script things which will save you on filesize. Use thatrenowned's code for establishing how much data is loaded but instead of going to a frame in "bar" use this...

bar._xscale=percent; .

...make sure that your "bar" clip's registration is left aligned to see the bar animate properly.

Plus spread the code out across at least a couple of frames or else it won't work - you need to loop the script to see the bar grow.

Slainte

 
IMHO, first frame of any preloader should remain clear of any text displays and/or graphics and animations, so that you can avoid seeing a flash frame of those displays or animations upon a refresh or a subsequent visit to the site.
It should only contain the conditional statement, that will immediately start the movie, if the movie is already in the user's cache.
Also, noticed you're using MX, and if you have components in your movie, and/or are exporting stuff on the first frame (Linkage), then no preloader (even the loadBar component) will work properly. It will only appear when the preloading is almost complete, thus defeating the purpose of having a preloader in the first place.
The workaround is to create a new preloader movie, which sole purpose is to load your present movie (without it's own preloader!), on another level or in an empty holder clip. Then that preloader will display properly! Regards,

new.gif
 
Thanks for the info. How do u make such a preloader movie that loads the other movie while the preloader is being displayed (what oldnewbie said). I used a LOT of linkage in my movie.
 
oldnewbie,

I don't understand what the .fla you show does. Where would you put it and where is the action script? I want to use a simple loader like that so the rest of my flash movie loads then plays.

Can you explain a bit more.

Thanks! NATE
spyderix.gif

design@spyderix-designz.com
 
Thanks a bunch oldnewbie, works like a charm!
 
To: SPYDERIX

The action script resides in frame one of the layer. All you have to do is to replace 'content.swf' to the filename of your flash movie, and you are on your way! Also, please note that all references to _root.object must be changed to _level0.loader.object

-- Josh
 
Hi,

One quick question. Does my .fla get imported into the loader.fla, or the loader.fla get imported into my movie.

Sorry I don't know flash at all, and need someone to explain how this works.

Thanks! NATE
spyderix.gif

design@spyderix-designz.com
 
No .flas are inported no where!

In the loader .fla your change the name of "content.swf" by the name of your .swf, "mymovie.swf" for example.
Output "loader.swf" and with both .swfs in the same folder or on your server, run loader.swf. It will load your present movie into it and start it playing. Regards,

new.gif
 
There is even an easier way to use the 'loader.swf' document. All you have to do is to first let it load the document into the blank 'loader' movie, then, after it's done, use the if comparison with the 'PERCENTAGE' string (make it true if equal to "100%"), and then make the statements inside the if comparison load 'content.swf' into the _root instead of 'loader' and unload the 'loader' movie. Then, you don't have to edit out ANY of your code in the origional movie to comply with _level0.loader.object. You can leave the code as-is (_root.object) and you still get the progress bar!
 
Don't quite understand what you've been saying... There's no need to change any code inside your "to be loaded" movie. This ain't loaded on a level, it's loaded in a holder clip set in the main movie which is _root. _level0 would only have to be used if you loaded the movie on another level and wanted to target the main movie, which in this case is pretty useless, since the main movie is only there to preload your other movie. Regards,

new.gif
 
That's strange. I couldn't load symbols on the FScrollPane 'MainWindowScroll' (which was on the _root level) until I changed it to _level0.loader.MainWindowScroll in my 'to be loaded' document.
 
Hi,

I got this to work ("sort of") but not quite was I was looking for. I want a bar that goes across. Someone posted something about 100 frames and moving it across based on the %. How can I do that? I have been searching through a bunch of their intro movies but haven't found what I'm looking for.

Can someone assist further.

Thanks! NATE
spyderix.gif

design@spyderix-designz.com
 
First make an animation of a bar getting longer, name the instance 'bar', put it into the 'loader.fla' document. Next, you have to implement thatrenowned's code inside of the 'this.onEnterFrame = function()' on frame 1 of layer 1. To make an animation, you must know a little bit about tweening.
 
The very first preloader I got was from You go to the tutorials section and I think its in the intermediate level part. I downloaded that, figured out how it worked and now any preloader I create uses the code in that, and also extra stuff like time passed\remaining, completion time (although that still needs some work on it), transfer rate etc.
Hope this is of some help...the site is really good for other tutorials and stuff.

Regards
 
Cool. Unfortunately, the only one I found had it's comments in German! I can't understand German, so I guess I'll have to figure out the code myself...
 
That one is pretty cool. However, I was also able to create my own using the 'loader.fla' document and implementing part of thatreowned's code in it, but instead of making it an animation, I used wangbar's idea of using the _xscale method. However, Instead of making a single bar "grow", I made the origional bar at full size, and created another black-colored bar on top of it that 'shrinks' as the document loads so it appears that the origional bar grows. (I did it this way because I decided to use gradients in the origional bar, and I didn't want the gradient to grow with the bar). You can look at it on: (a website I'm making for a company - it's entirely flash-based and has almost no HTML). However, the website is still under construction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top