Flash 5 Preloader Question: How to run an MC in a preloader in proportion to loading?

Here's the question, in a nutshell:

I designed a nifty little MC to use as a preloader for a movie.  Basically, it's a watering can that tips over and then pours out water on a flower pot.  The MC is simple:  straight time line tweening animation.

Now, my question is this -- I know how to make fairly decent preloaders, with progress bars, etc., but I'm wondering if it is possible to:

1. Drop the MC into Frame 1 of the main move
2. Include an action script (flash 5, please) that would run the MC, once, not looping, smoothly and in proportion the the loading of the movie.  In short, like a progress bar, but it's a watering can tipping over.  The MC itself is about 16 frames.

Make sense?  This is for an on-going project, so I'd appreciate your help!
geod100Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
vickerleungConnect With a Mentor Commented:
qeod100,

I am not sure whether Flash 5 have onClipEvent and getbytesloaded
Please check, if no, do let me know

The method is not that difficult actually.

In your mc, insert the stop(); actionscript in the first frame;

And then drag your mc on stage.
Name the mc like abcd
Add the following actiosncript to your mc

onClipEvent (enterFrame) = function ()
{
     progress_percentage = Math.round (_root.getBytesLoaded / _root.getBytesTotal * 100);
     frame_target = Math.round (progress_percentage * 16); // in here 16 is your mc total frame number
     _root.abcd.gotoAndStop (frame_target);
}

That's it!!
Vicker
0
 
vickerleungCommented:
O~~~ sorry
that should be

onClipEvent (enterframe)

only~ :p

sorry for that
0
 
vickerleungCommented:
O sorry once more =.=|||

I missed the braces...
maybe I repost the code

onClipEvent (enterFrame)
{
     progress_percentage = Math.round (_root.getBytesLoaded () / _root.getBytesTotal () * 100);
     frame_target = Math.round (progress_percentage * 16); // in here 16 is your mc total frame number
     _root.abcd.gotoAndStop (frame_target);
}

To apologize, I have uploaded a sample to:
http://www.geocities.com/vickerleung/loader_animation.zip

I have enlarge the file so that you can feel the loading sequence.

Further, the FLA is saved in MX format... Hope Flash 5 can open
If not, you still can open the swf file, it is in flash player 5 format.

Cheers :)
Vicker
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
nishasrilankanCommented:
And dont forget to include gotoAnd.play or gotoAndStop for the main movie...otherwise it will stop at the 16th frame of the preloader..or..I can suggest like this..

put the preloader(mc_preloader) MC in frame 1 and put the main movie in frame 5(or something)

inserrt >Movieclip>name it as script

put the script on to a new layer on the main time line (Instance name "script")

//in the first frame of the script put this code..
var totalBytes ;
var loadedBytes ;

//in the third frame of the script put this code..
totalBytes = _root.getBytesTotal();
loadedBytes = _root.getBytesLoaded();

if(totalBytes==loadedBytes){
_root.gotoAndPlay(5); //or you can use _root.gotoAndStop() depending on the situation
}
else{
numCurruntFrame = Math.ceil((loadedBytes/totalBytes)*16);
_root.preloader.gotoAndStop(numcurrentFrame);
gotoAndPlay(2);
}


0
 
geod100Author Commented:
Unfortunately, this is all Flash MX -- I needed a Flash 5 solution....
0
 
vickerleungCommented:
geod100,

I am sure that Flash 5 already have getbytesloaded and getbytestotal functions

for the onclipevent, I am not sure

Okay
I provide a method that don't depend on onclipevent

First of all, prepare the animation mc,
again on frame 1 add stop ();
drag to stage and name it abcd
last frame with scene transition (i.e. something like _root.gotoAndPlay ("start_movie"))

Second, make another mc which have two frames and empty content
the first frame add the following script

progress_percentage = Math.round (_root.getBytesLoaded () / _root.getBytesTotal () * 100);
frame_target = Math.round (progress_percentage * 16); // in here 16 is your mc total frame number
_root.abcd.gotoAndStop (frame_target);

the second frame add the following
gotoAndPlay (1);

Drag this new mc on stage also

That's it!!
The logic is that the 2nd mc will loop count the percentage and control the abcd mc

Hope this time works :)
Vicker
0
 
geod100Author Commented:
Vicker,

This isn't clear to me.  From your points above: "Last frame with scene transition (ie, something like...) -- what do you mean by this?  Is this code that goes into the last frame of the MC I dragged to screen?  IE, do I put this code in the last frame of the MC itself?

Ah, okay, I understand.  The stop() goes in the first frame of the animation MC.  I'm not sure what you mean by the second line of code, though.  Can you be more specific?
0
 
geod100Author Commented:
Vicker,

I tried all  your steps, but it doesn't really work. Basically, the first frame of the animation MC flashes on the screen, and then it immediately jumps to the rest of the movie (the rest of the movie being a 2.6megabyte SWF that I load into frame two of this movie).
0
 
geod100Author Commented:
Okay, here's what I'm getting: your script jumps the animation MC from the first frame to the last frame, but it doesn't *play* the tweened frames in between.
0
 
geod100Author Commented:
I guess I should post this question again -- all I've gotten so far is inadequately commented good that, well, simply does not work...and no responses to my follow-up questions.
0
 
vickerleungCommented:
geod100,

O~~ at least you know that Flash 5 have that getBytesTotal and getBytesLoaded functions,

sorry for being late reply, cause I am too tired and gone to sleep XD

Okay, I am too sleepy last night that the code forget that you have to play the tweened animation. So please try the following code instead:

progress_percentage = Math.round (_root.getBytesLoaded () / _root.getBytesTotal () * 100);
frame_target = Math.round (progress_percentage * 16); // in here 16 is your mc total frame number
if (_root.abcd._currentframe < frame_target)
{
     _root.abcd.nextFrame ();
}

CAUTION: I am not sure if in Flash 5, it is called abcd.next (); instead

Cheer up friend~~!!
Vicker
0
 
nishasrilankanCommented:
Please try first...can you say one function in my code to not working with Flash 5?
0
 
geod100Author Commented:
Vicker, I appreciate your trying. I think you now understand the logic I'm getting it -- the for the movie to play the animation MC in proportion to the loading process.

However, now I get the error " unexpected } " refering, apparently, to the last bracket.
0
 
geod100Author Commented:
nishasrilankan,

Your script is fine -- there are no error messages whatsover.  The problem is, it only plays frame one of the preloader MC and then skips over to the main movie.  What I need is for the preloader MC to play smoothly, in proportion to the loading process.
0
 
vickerleungCommented:
geod100,
use

_root.abcd.next ();

instead~

Gd luck

Vicker
I think is the nextFrame problem,
0
 
vickerleungCommented:
Sorry typing error

repost

geod100,
I think is the nextFrame problem,

use

_root.abcd.next ();

instead~

Gd luck

Vicker
0
 
geod100Author Commented:
Sorry, Vicker...it doesn't work.  Basically, now the preloader now freezes on the first frame of the preloader MC ("abcd") and then goes on to the movie.  No error message (yeah!) but it doesn't play the MC, either.
0
 
vickerleungCommented:
geod100,

o~~~ boy

Is really hard for me to test cause I don't have Flash 5 in hand...
sorry that I always post unwork answer

Try this

if (_root.abcd._currentframe < frame_target)
{
     _root.abcd.gotoAndStop (_root.abcd._currentframe + 1);
}

Gd luck this time~~

Vicker

P.S. If you still don't work... I beg that I better find a Flash 5 and write it for you LOL
0
 
geod100Author Commented:
Nope, doesn't work -- preloader remains frozen on first frame, and then movie loads.

Thank you, though.
0
 
vickerleungCommented:
geod100,

oh my god

Maybe you do me a favour
Use this script to replace the existing one
so that I can do some debugging

if (_root.abcd._currentframe < frame_target)
{
     trace ("current_frame" + _root.abcd._currentframe);
     _root.abcd.gotoAndStop (_root.abcd._currentframe + 1);
}

Copy what displays in the output window to me, thx~~!!

IF!! You don't get any output... Just to remind you that
This script is attached to the 1st frame of a new mc
2nd frame is a "gotoAndPlay (1);" statement
AND THIS MC HAVE PUT ONTO THE STAGE ALSO!!
OF COURSE PUT ONTO THE STAGE'S FIRST FRAME
(or I should say the same frame as you put your animation mc)

Vicker
0
 
vickerleungCommented:
O sorry geod100
gotta sleep
help u tmr~ :p
0
 
nishasrilankanCommented:
try this...
in the preloader timeline, select all the frames and right click> convert to key frames...

then put stop(); in all the key frames....

** there might be an easy way to do this than the above
0
All Courses

From novice to tech pro — start learning today.