[SOLVED] ProgressBar While Loading SWF


(Zouhair Elamrani Abou Elassad) #1

Hi, I was trying to implement a progress bar for my game, i used SWFObjects.js and it was working great with medium size SWF (14 Mega), once i used a large once (size > 30 Mega), the preloading got stuck at a certain value, the SWF was always embedded in the page, just the loading that stops, my Flash is at its last version, so i don’t what could be the problem.

While i was looking i found one of your posts about a class that you use for preloading, Preloader, i was wondering if there is an example i can use to see how it is implemented, because i tried to load my game SWF from another flash project using Flash Loader class, but i didn’t work.


(Martí Angelats i Ribera) #2

You have to add this on your engine

[Frame(factoryClass = "Preloader")]
public class Game extend Engine

And then change the string

private static const mainClassName:String = "Game";

for the name of that class.


(Zouhair Elamrani Abou Elassad) #3

Oh that worked like a charm, thank you, is there a way to show the progress value on top of the progress bar.


(Martí Angelats i Ribera) #4

I haven’t work with this, but the p in the onEnterFrame seems to be the the value you are serching for. You only had to make the text (without using FP, so you need to use a regular TextField)


(Zouhair Elamrani Abou Elassad) #5

That’s exactly what i did, i wanted to show just a simple text so to be able to edit it after :

 var tf:TextFormat = new TextFormat( "TwCentBold", 30, 0x000000 );
		var textField:TextField = new TextField();
			textField.embedFonts 		= true;
			textField.autoSize 		= TextFieldAutoSize.LEFT;
			textField.defaultTextFormat = tf;
			textField.text = "Value";
			textField.x = 50;
			textField.y = 300;
			
			textField.width = 300;

                            stage.addChild(textField);

But it’s not working so far.


(Zouhair Elamrani Abou Elassad) #6

It Worked, thank you, the problem was in the TextFormat :smile:


(Martí Angelats i Ribera) #7

Directly use

addChild(textField)

So you’ll add the child to the Loader. Graphically it’s the same but this is more intuitive.


(Zouhair Elamrani Abou Elassad) #8

Done, Thank you, i spent like a lot of time trying to use progress bar while my SWF loads, i even used SWFObject which was good actually, cuz i used already prepared javascript plugins and that gave an awesome look in the UI, but the fact that this can be done in AS without the use of the LOADER class that didn’t work for large SWF is a great thing :smile: .