Flash Preloader [Flash][Actionscript]

Started by: Cory | Replies: 18 | Views: 3,184

Cory
2

Posts: 536
Joined: Jun 2007
Rep: 10

View Profile
Dec 2, 2007 12:23 PM #70214
So ya need a preloader you say?
Well lets get cracking.


First create a new flash document then press f8 to create a new movieclip (MC)

Now create an 100 frame animation exactly of a progressive bar loading or an intro animation or something. Not 99, not 101. 100.
example: Image




Yay you made a 100 frame animation, good job. Now make three blank keyframes on the main timeline in the beginning (right click > Insert Blank Keyframe). Highlight the third keyframe and go to Properties. Set the frames name as "start" without the quotations.

Image


Next put your 100 frame animation in the first two frames, make shure they are in the same place in both frames though. Now on both frames add
onClipEvent (enterFrame) {
gotoAndPlay(_root.percentDone);
}

under the actions of your 100 frame mc.

Image


Finally in the actions of the first frame add
totalBytes = Math.round(getBytesTotal()/1024);
loadedBytes = Math.round(getBytesLoaded()/1024);
percentDone = Math.round((loadedBytes/totalBytes)*100);
if (_root._framesloaded>=_root._totalframes) {
gotoAndPlay("start");
}

and on the second frame's actions add
gotoAndPlay(1);



Basically:
1. Create a one hundred frame animation in a mc
2. In another mc create 3 blank keyframes
3. Name the third frame "start" without the quotations
4. Put your mc in the first two frames
5. Add the script


example of final product
Paco
2

Posts: 910
Joined: Feb 2006
Rep: 10

View Profile
Dec 2, 2007 4:57 PM #70230
good job with the pictures, explaining and stuff but could have maby made it a nicer preloader. but it seems like you where aiming twards basic.
Gray
2

Posts: 926
Joined: Aug 2005
Rep: 15

View Profile
Dec 2, 2007 5:53 PM #70237
Good tutorial. This will definitly help people. Good work
NCz
2

Posts: 337
Joined: Jun 2007
Rep: 10

View Profile
Dec 2, 2007 7:36 PM #70242
You have to be kidding me....












This thread came out just as i was going to go looking for tut's on preloaders for one I'm trying to make!
Cory
2

Posts: 536
Joined: Jun 2007
Rep: 10

View Profile
Dec 2, 2007 10:41 PM #70257
lol, sorry. I just kept seeing questions on preloaders so I just decided to make a tut. I thinking about adding another section on how to add a play button.
alexjustdoit

Posts: 0
Joined: Apr 2026
Dec 15, 2007 5:40 PM #72026
Thanks, it was really helpful.
horriblepain

Posts: 0
Joined: Apr 2026
Dec 27, 2007 5:25 AM #74239
im kinda new to flash,could you care to explain,"making the animation bar"?
Toais

Posts: 0
Joined: Apr 2026
Jan 2, 2008 8:10 AM #75415
umm, how i put my 100 frame animation into one frame?
alphastickmania

Posts: 0
Joined: Apr 2026
Jan 2, 2008 9:04 AM #75422
Eh? How about before you even touch anything after opening a new .fla document, press F8. Than choose movie clip and press ok. Then you go about creating your 100 frames. Anyway, good job Cory. Basic version with less actionscript goes well for beginners. (Btw, although the Play button part should already be go figure, put up an additinal section for it if you want.)
alphastickmania

Posts: 0
Joined: Apr 2026
Jan 2, 2008 9:22 AM #75425
Quote from horriblepain
im kinda new to flash,could you care to explain,"making the animation bar"?


Erm. I might not give what he was teaching you exactly but it goes something like this.

Step 1. Use the rectangle tool to create a bar as such below. (To get the rounded corners, double click on the rectangle icons and type in the value for number of point for corner radius.) Size is up to you.

Step 2. Select the whole rectangle you have just created and press F8. Choose the movie clip option and click ok.

Step 3. Now double click on the new movie clip you have just created to "enter" the movie clip.

Step 4. Count up to 100 frames sharp and create a new keyframe.

Step 5. Select the first keyframe in the movieclip again and shorten the rectangle until it is as you can see from the picture in the tutorial.

Step 6. Now go to a random frame in between the two keyframes and right-click. Select the Create Motion Tween option.

Step 7. Now select all the frames (Every single one of them) and right-click again. Select the Convert To Keyframes option this time.

Step 8. Follow Cory's instructions in his tutorial to the end from here on.
Iceberg

Posts: 0
Joined: Apr 2026
Jan 19, 2008 10:44 PM #78594
Quote from Cory
So ya need a preloader you say?
Well lets get cracking.


First create a new flash document then press f8 to create a new movieclip (MC)

Now create an 100 frame animation exactly of a progressive bar loading or an intro animation or something. Not 99, not 101. 100.
example: Image




Yay you made a 100 frame animation, good job. Now make three blank keyframes on the main timeline in the beginning (right click > Insert Blank Keyframe). Highlight the third keyframe and go to Properties. Set the frames name as "start" without the quotations.

Image


Next put your 100 frame animation in the first two frames, make shure they are in the same place in both frames though. Now on both frames add
onClipEvent (enterFrame) {
gotoAndPlay(_root.percentDone);
}
under the actions of your 100 frame mc.

Image


Finally in the actions of the first frame add
totalBytes = Math.round(getBytesTotal()/1024);
loadedBytes = Math.round(getBytesLoaded()/1024);
percentDone = Math.round((loadedBytes/totalBytes)*100);
if (_root._framesloaded>=_root._totalframes) {
gotoAndPlay("start");
}
and on the second frame's actions add
gotoAndPlay(1);
Basically:
1. Create a one hundred frame animation in a mc
2. In another mc create 3 blank keyframes
3. Name the third frame "start" without the quotations
4. Put your mc in the first two frames
5. Add the script


example of final product


I don't understand ='[

You can do a tutorial with image? xD
LN3uq
2

Posts: 2,457
Joined: Dec 2004
Rep: 35

View Profile
Jan 20, 2008 1:11 AM #78615
Those were images, yes.

What don't you understand about it?
Rather Cheesy
2

Posts: 2,137
Joined: Apr 2007
Rep: 10

View Profile
Jan 21, 2008 12:16 AM #78755
Quote from Cory

Next put your 100 frame animation in the first two frames, make shure they are in the same place in both frames though. Now on both frames add
onClipEvent (enterFrame) {
gotoAndPlay(_root.percentDone);
}

under the actions of your 100 frame mc.


Make it more clear that you need to put this code on the MC and not the frames. like so

Next put your 100 frame animation in the first two frames, make sure they are in the same place in both frames though. Now on both of the 100 frame animations on both frames add this code
onClipEvent (enterFrame) {
gotoAndPlay(_root.percentDone);
}

Make sure this is on the Movieclip, not the frame or it won't work!


Other than that, excellent tut, It would've helped me if I didn't already know how to make one ^_^
Cobra42

Posts: 0
Joined: Apr 2026
Feb 16, 2008 7:34 AM #83645
Just one question...
Quote from Cory

Next put your 100 frame animation in the first two frames, make shure they

Howtf am i supposed to do that?!
Gavel
2

Posts: 6,675
Joined: Oct 2006
Rep: 10

View Profile
Feb 16, 2008 9:16 PM #83734
Quote from Cobra42
Just one question...

Howtf am i supposed to do that?!

If you could read, you'd see that at the very beginning he told you to make this a Movie Clip.