View Full Version : [AS3] AS3 loading bar
byron
06-04-2007, 07:14 PM
I have just created a small game in the Flash CS3 ide using just AS3 for completely code driven content (i.e. I haven't used the timeline for anything). The time came to implement the loading bar - except in this version I have no idea how because you can't drag code onto the second frame of a timeline..
Does anybody have any idea how to do this?
orange gold
06-04-2007, 08:42 PM
im not sure if this is what u mean but right click on the frame and click copy frame then right click on second frame and click paste frame
jsimpson
06-04-2007, 08:59 PM
If you mean your entire movie is based in one class, there are two considerations. One is do you have items in the library. If you have items in your library you have to check their linkage and make sure export in first frame is unchecked. Then on frame 2 or so, drop an instance of every object on stage.
Then move your code or change your import line to frame 3. And then create a preloader like normal with a gotoAndPlay(3) command.
var tickTimer:Timer = new Timer(10);
tickTimer.addEventListener(TimerEvent.TIMER, testLoaded);
tickTimer.start();
function testLoaded(ev:TimerEvent){
root.loaderInfo.bytesLoaded;
root.loaderInfo.bytesTotal;
getPercent = bytes_loaded/bytes_total;
if (bytes_loaded == bytes_total) {
tickTimer.stop();
gotoAndPlay(3);
}}
The other option is to create a seperate preloader that loads your swf and plays it.
byron
06-04-2007, 11:33 PM
How does this work with the document class being specified? In theory with that specified you no longer really have a timeline.
jsimpson
06-05-2007, 04:09 AM
Right, so for that situation you would have to make another file that loads your movie and in itself contains the loading script/preloader that you want to use.
byron
06-05-2007, 09:15 AM
okay - thanks, I was afraid that would be the case but kind of hoped it wouldn't...
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.