ForumsProgramming ForumPreloader Actionscript 3.0

7 4751
LennonTheMage
offline
LennonTheMage
55 posts
Nomad

Okay so I've always never been able to get preloaders to work with actionscript 2.0. Now that I've moved on to 3.0 I STILL can't get them to work. I've tried many tutorials and still I have not been able to get them to work. Can someone suggest me to a tutorial that works for them?

(This doesn't need to be answered, but I was thinking of just including it because I have a 2nd question :3)
Random Extra Question: I've had a bracket broken for about 1 month on the very right tooth(my right) and I'm worried that it might mess up my progress. Thankfully I'm going in in a week, but it's been, like I said, 1 month already Does anyone know if this will be a huge drawback?

  • 7 Replies
Darkroot
offline
Darkroot
2,763 posts
Peasant

Here is a good video tutorial that includes the .fla files from cartoon-smart.

I'm no dentist but I did fficial&client=firefox-a">google your problem. Seems that if your not in horrible pain you can just wait or book an earlier appointment.

WhiskeyedJack
offline
WhiskeyedJack
80 posts
Shepherd

Programming and medical advice! How I love one stop shopping. Also this is kind of the that always keeps me amused/enamored of this place.

LennonTheMage
offline
LennonTheMage
55 posts
Nomad

@Darkroot Thank you :3 Even if it doesn't work there is one tutorial that will for sure work, it's just the sketchy way of doing it so I didn't want to learn some lame "turn your problems into a feature" way -_-

@Whiskeyed Hahahaha yep. That's Armor Games for you XD

PixelSmash
offline
PixelSmash
566 posts
Nomad

You could also look at something called 'factoryClass', though it's only usable if you don't compile using Flash I believe. Some info about it can be found here if you're interested!

Good luck!

LennonTheMage
offline
LennonTheMage
55 posts
Nomad

So I finally got it to work, but once I added all my .as files to it to get the actual content in... It didn't work 0_0. I don't know why the .as files are affecting how my actionscript runs on just on frame of my timeline frames.

I know for a fact it doesn't involve the preloader, because it alone works fine.

I decided that I should make everything use .as files. So I'm trying to transfer it over.

package {

import flash.events.Event;
import flash.display.MovieClip


public class loadBar extends MovieClip{

addEventListener(Event.ENTER_FRAME, loading );

function loading(event:Event){
var bytestotal = stage.loaderInfo.bytesTotal;
var bytesloaded = stage.loaderInfo.bytesLoaded;


var percentVar = Math.round(bytesloaded * 100 /bytestotal );
loadtext.text = percentVar + "% Loaded";
loadBar.gotoAndStop ( percentVar );

if ( bytesloaded >= bytestotal) {
removeEventListener(Event.ENTER_FRAME, loading );

removeChild( loadtext );
removeChild( loadBar);
gotoAndStop(2);
}
}
}
}

That's my code so far and it's coming up with errors :/

PixelSmash
offline
PixelSmash
566 posts
Nomad

You're on the right track, but I think I know what's going wrong here.

To summarize, you want a loadBar instance that extends movieclip. The thing you're missing though is the constructor, the function that gets executed when creating the loadBar. (Btw, naming convention: all classes start with a capital, though it's not mandatory)

Let me see if I can make a quick fix for you:

package {

import flash.events.Event;
import flash.display.MovieClip


public class LoadBar extends MovieClip{

public function LoadBar() {
addEventListener(Event.ENTER_FRAME, loading );
}

private function loading(event:Event):void{
var bytestotal = stage.loaderInfo.bytesTotal;
var bytesloaded = stage.loaderInfo.bytesLoaded;


var percentVar = Math.round(bytesloaded * 100 /bytestotal );
loadtext.text = percentVar + "% Loaded";
loadBar.gotoAndStop ( percentVar );

if ( bytesloaded >= bytestotal) {
removeEventListener(Event.ENTER_FRAME, loading );

removeChild( loadtext );
removeChild( loadBar);
gotoAndStop(2);
}
}
}
}

Now, if you use this as Document Class, it should be allright. Note however that if you don't have the loadtext or loadBar instances on the timeline, it will still generate errors!
I've also renamed the class to LoadBar, otherwise the removechild (loadBar) could generate errors as well, since the code doesn't know if it should remove a movieclip called loadBar or the class loadBar. In any case, you'll need to rename the .as to LoadBar.as

I hope this helps, and if you run into more errors, please do post them here since they can give a lot of insight as to what is actually going wrong

Good luck!

LennonTheMage
offline
LennonTheMage
55 posts
Nomad

I just went with the 3 frame method which works for me. I just tried your code, but it did not work for me. I didn't get any errors, but the loadbar would just sit there and nothing would happen.

Oh well :/

Showing 1-7 of 7