Well, I finaly got to it. sleep helps.\r\rOk, there are two things that the uninitiated needs to know about preloaders right off the bat. They are A) the loop, and B) get properties functions.\r\rEvery time you need to check for something over and over in flash, the best way is to make a loop, out of the action script. Frame loops are the most common, so Iâm going to cover them in this post, then weâll move on to onClipEvent (enterFrame) loops.\r\r* If you donât have a blank layer, just for action script, then I suggest that you make one. Nothing annoys more than having to search through FLA files for the action script.\r\r1) Create a blank layer, and create a second frame on that layer.\r\r2) With the second frame selected, open the âActionâ panel, and insert the following action script.\r\rgotoAndPlay(1);\r\r There you have it⌠thatâs a loop. The play head will reach frame one, go on to frame two, and when it reaches the action script, it will loop back to frame one again.\rNow we need some script in frame one to get some properties of the movie. Alot of people like to use framesLoaded. I do not. framesLoaded might be useful if you are trying to test to see if a particuar frame is loaded, but most of us are interested in the total killobytes, and the number of killobytes that have loaded. I use the getBytesTotal();, and the getBytesLoaded(); commands.\r\r3) With frame one selected, enter the following code. Iâve added â//â in some of these lines. They will show up pink in your action script panel. They are comments and are not important to the Flash player, but should help you to understand what is happening in the code.\r\r//here we are getting the total bytes and the number of \r//bytes that have been loaded so far, of the movie, and \r//dividing it by 1000 in order to come up with killobytes.\r//we set two variables to be equal to these two statements \r//like so\rtotalK=getBytesTotal()/1000;\rloadedK=getBytesLoaded()/1000;\r//remaining K is just the first variable, minus the second.\rremainingK=totalK-loadedK;\r//percentage of K loaded is just the second variable divided \r//by the first, and then mutliplied by 100.\rpercentageK=(loadedK/totalK)100;\r//here we set the bar movie clip to scale, left/right by the \r//amount of the percentage variable.\rsetProperty(âbarâ,_xscale,percentageK);\r//here is our break out⌠if the amount of K loaded is greater \r//than the total K of the movie, AND (thatâs what && means⌠\r//both conditions have to be true) the total K is NOT equal to \r//0, then goto the third frame. \rif(loadedK>=totalK&&totalK!=0){\r gotoAndPlay(3);\r}\r\r we need to create a percentage bar\r4) Create a new layer.\r\r4a) On the main stage, create a square of fill, with no stroke. \r\r4b) Click on it once to select it, then open your âinfoâ panel. In the height and width fields, enter 20 for height, and 200 for width. Hit enter after making each entry.\r\r4c) With the rectangle still selected, hit F8, and in the dialogue box that opens, select Movie Clip. The name can be anything.\r\r4d) Double click on the bar movie clip to edit it in place. When youâre inside the movie clip, select the fill and move it to the right, until itâs left side is flush with the small cross hair, representing the middle of the clip.\r* why go through this step? Because we are scaling the bar movie clip, we donât want it to expand from the middle to either end, but rather from one side out to the right. It just looks better, though Iâve also had some that expanded from the middle outwards. Itâs really your choice.\r\r4d) Go back to the main stage, select the movie clip, open your âinstanceâ panel, and enter âbarâ in the instance name field.\r\r4e) You may wish to create some text that says 0%, 50% 100% or what ever, and place these near the bar, with 0% on the left side and 100% on the right. See my example.\r\r some people like to have text fields display the different K amounts*\r5a) Select the text tool. Open the âtextâ panel and select âDynamic textâ from the pull down menu. The variable name field, will now allow you to enter something into it. Enter âtotalKâ in this field.\r5b) Repeat step 5a, two more times, naming each âloadedKâ, and âremainingKâ.\r5c) If you like, create some plane text labels for these, and possition to your liking. I usually stack them with totalK on top, loadedK in the middle, and remainingK on the bottem.\r\rThatâs really all there is too it.\r\rThe preloaderBar files are located, for download, as open source, here\rwww.centerspin.com/downloâŚderBar.fla\r[url=âhttp://www.centerspin.com/download/preloaderBar.swfâ]www.centerspin.com/downloâŚderBar.swf\r\rAsk your questions.
Nice little tute Uppy!\r\rpj\r:cool:
where can i see the live example of the preloder that u have used pls give the url\rEbu
oops⌠you know⌠I never posted that. I think because when I made my example I was doing it as a movie clip, but wrote it as if it were on the main timeline⌠so I didnât have one to post. Iâll post both the SWF and the FLA in an hour when I get home.
Just a note⌠a lot of people donât know about the bandwidth profiler, and streaming settings. These are important if you want to check to see if the preloader is working properly⌠so I better go over it.\r\rWhen you do a menu option âcontrol/test movieâ, a flash player will open. With this player open, click on menu option âview/bandwidth profilerâ. This will show you how many bytes are located in each frame of your movie.\rIn addition, under the âviewâ menu option, there is also a âshow streamingâ choice. This will let you see the movie, as it would apear, on various connectly speeds. Youâll have to play around a little, but you have all the options you like, right there. You can even create speeds that donât exist, like 12,560kps, or something like that. It is a very useful tool for those of you interested in knowing exactly what your visitors are likely to be going through to see your stuff.
The preloaderBar files are located, for download, as open source, here\rwww.centerspin.com/downloâŚderBar.fla\r[url=âhttp://www.centerspin.com/download/preloaderBar.swfâ]www.centerspin.com/downloâŚderBar.swf
Hey, Upu, loose the rat !!!\r\rpom 0]
Thanks so much for your mini tutorial!!\rI would have never figured that out!!\r:)
ok⌠so hereâs an update⌠since we have new information that I wasnât aware of before I wrote that.\r\rThis code will work for any object in your movie. That is to say, you can get the bytes information for anything that can be named with an instance name. In MX this would allow someone to target just about anything, but in Flash 5.0 it just means that anything we wish to find out this information on needs to be inside a movie clip. If it has an âinstanceâ name, then you can find out the bytesLoaded, and Total.\r\rwith a large movie clip. You could have a stop action on itâs first frame. Then if it were named myMovieClip, this code would figure out when the clip should start playing.\r\rtotalK=_root.myMovieClip.getBytesTotal()/1000;\rloadedK=_root.myMovieClip.getBytesLoaded()/1000;\rpercentageK=(loadedK/totalK)*100;\rif(loadedK>=totalK&&totalK!=0){\r _root.myMovieClip.play();\r}
Post on the regular forums, noono, youâre not supposed to use this forum to ask questions
pom :cowboy:
what? then why arenât these threads locked? âŚlolâŚ
loookit mE MA!! iâm posting on BEST OF KIRUPA!!! WOW I FEEL SO SPECIAL