PDA

View Full Version : An Easy Loader Bar! [Flash][Actionscript]



tyshim
02-15-2007, 07:22 AM
Ok so i've looked at many Preloaders with a bar or something that fills up and... well they are all VERY confusing so i'm going to keep this short and straight to the point:

1:Open New Flash Document and create a new scene, rename the scene "preloader" (without the "s)

2: now create 3 layers (you should now have 4 layers all together) and name
the very first one starting from the bottem up Bar, the one above that, Outline, the one above that, Text, The one above that, Actions

3: On the Bar Layer Create what you want to fill up, Usually a rectange, so just select the
rectangle tool and make a bar. (Width big length small:_________________
|_________________|
The fill color should be the color that you want to fill up inside of the bar.

4:Now double click on the outer edge of the Rectange so that you have only the lines selected not the Fill and hit Ctrl+X or just go to edit and cut it.
Paste it in place (Ctrl+Shift+V) on the Outline Layer.

5:Now select the bar layer and create another layer so that you now have a layer inbetween Bar and Outline, Rename the newly created layer to Mask.

6: In the mask layer select the Rectange tool again and check that it won't have lines (select the color for the line and go to the white box with a red stripe through it).and the fill color a Bright Green but easy to see around (yes all the way around (like starting at the Bars left edge and ending at the right but make sure it fills up the whole outline/bar. Now select the Green Rectange and hig F8 or right click and convert to symbol. Name it: mask_mc : and give set the registration point to the very left middle spot

+++
-> +++
+++

and hit OK. Now give it an instance name of: mask_mc : now select the Mask layer right click it and select Mask. If the bar layer isn't already selected to the mask so that it will reveal the bar layer than select it and drag it kind of into the middle of the mask layer.

7: Now lock all the layers except for the Text layer and put whatever text you wanna put in... Preferably Loading...

8: Now select the first frame of the Actions layer and hit F9 or right click and go to Actions. Now were going to put in some lines of code that will make the bar start from one end and go more to the left as the animation loads.

Actions:


stop();
masc_mc._width = 1;
this.onEnterFrame = function():Void {
var loadedData:Number = this.getBytesLoaded();
var allData:Number = this.getBytesTotal();
var percent:Number = Math.round(loadedData/allData*100);
mask_mc._xscale = percent;
if(loadedData>=allData) {
gotoAndPlay();
delete this.onEnterFrame;
}
}

NOTE: the gotoAndPlay function your going to have to put the Scene 1 (or whatever you renamed the other scene) and then a comma , then the scene number. NOTE2: The scene name needs to be inside " Ex:

gotoAndPlay("Scene 1",1);

That is it! good luck to you all and if you have questions be sure to post em \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

newb4eva
02-26-2007, 04:56 AM
holy crap!!!!!!!!!!!!!!!!!! i think i'll skip a loader

speedster239
02-26-2007, 08:50 PM
that's actually a pretty simplified loader, but if you really want to you don't need to document the bytes, you can base it on loaded frames instead

Arch-Angel
02-28-2007, 12:36 PM
Or can't you just have a bar with squares in it and every few frames fill one of the squares with the paint bucket tool?But I am a newb at Flash so what do I know!!!

mitsukai
03-10-2007, 09:56 PM
OK what do oyu mean by instance name i dont see that

edit: heh heh nvm

mintedmomo
03-12-2007, 11:06 AM
wow thanks for that it really helped

mitsukai
03-15-2007, 06:46 PM
does it matter how many frames you have

like should i make the fame last longer or something

edit: is there an action script to play a sound after it loads.

nineofspades
04-02-2007, 03:02 PM
How do you Change Scene Name (Im using flash 8)

karma
04-12-2007, 12:02 PM
Hey thanks dude i was hopin that someone posted that cause i was jellish of all the guyz that used load bars

Apples
04-13-2007, 02:16 PM
thanks.
respect + 1

kespen
04-13-2007, 08:12 PM
How do you Change Scene Name (Im using flash 8)
Goto: Window> Other Panels> Scene.
Then double-click the scene name you want to change, type in the name and hit the Enter/Return key.;)

web-ding
05-26-2007, 02:52 AM
This works,...but I'm not soooooo sure about how easy this is.

Vincent
07-12-2007, 03:03 AM
holy crap i'll skip the loader also i can't understand some of that stuff O.o

The_SaNdWrAiTh
07-15-2007, 03:44 PM
i think easy is not the word

_slanted_
07-15-2007, 10:32 PM
k now my bars will bve loading