Confused : compiling & embedding a project (ASC2.0) [SOLVED]


(s corneil) #1

Hi guys,

I finished my first FlashPunk game & put it online (website link). Even though the swf is really small (1.07 MB), It takes a couple of seconds before it has loaded. During that time there is … absolutely nothing to see :frowning:

So : these are the questions I have not found an answer to yet, even after an extensive search :

  • Is this loading ‘lag’ normal for this kind of file size (1.07 MB) ?
  • I thought that maybe I should have a preloader for the game. But that opened up another can of worms : apparently, I have compiled my project with ASC2.0. This means the meta tag’ [Frame(factoryClass=“Preloader.as”)]’ no longer works …
    I have not been able to figure out how to (1) compile my project with an older compiler (and should I even do that ?), (2) or : have a preloader work with my current compiler :frowning:

Any help / hints very much appreciated !


(Jacob Albano) #2

It’s definitely normal to see loading delay with even a small game, and a preloader would certainly fix that. Check this Stack Overflow thread for a potential workaround.


(s corneil) #3

Good to know a delay is normal, even for small files … :slight_smile:

I have read that thread earlier, and I have tried to implement it, but I couldn’t figure out where this (’-frame=AnyFrameLabelYouWant,YourMainClass’) goes …
I always got an error saying that the class could not be found (or something to that extend). Could this be because of the ASC2.0 ?
I really have no clue … :frowning:

Also, did I understand correctly that ‘AnyFrameLabelYouWant’ is the name the compiler will give to the frame where your main class should load ? (sort of like ‘frame number 2’)

I really would like to get this working …

PS-Thanks !


(s corneil) #4

Ok. Some progress …

So, for everyone else that is new to AS3 / FD / FP : adding a preloader to a project that is compiled with ASC2.0 has turned out not to be difficult at all.You just need to know what you’re doing … :slight_smile:

  • add a Preloader.as class to your project (see other Q&A for what code goes in there).
  • in the project manager : right click on the Preloader.as class > set document class (notice how the icon is now green instead of red)
  • also in the project manager : right click your project > properties > compiler options > click the plus-sign next to ‘aditional compiler options’ > click in the right colomn, next to [0] and type (without the quotes)’ -frame freeToChoseLabelName nameOfYourRealStartupClass '. There is a space between the 3 arguments (but not between - and frame).

If you compile your project and then (in the project manager) click on bin > yourProject.swf > properties, you’ll see : ‘frames: 2’.

That’s how you know you did everything right :wink:.

Now, that still did not entirely help me : even with my preloader, I see about 2 seconds of ‘nothing’, then I see my preloader flash by (no pun intended), and then I see my game.
After reading a lot of different things, that makes me think everything is still being loaded on frame 1 (instead of frame2). I know that in Flash Pro, you have to set ‘export to frame 2’ on all assets …
Anybody knows if you need to do the same thing in FD ? And how would you do it ?

I also saw someone add all images and such in the ‘lib’ folder > right click the img > add to library, and then include them in the project.
I have all my assets in folders (‘img’, ‘sound’, …) that are not part of the library… Think that makes a difference ???

Sorry for the long post :blush:


(s corneil) #5

Finally ! Success !!!

At the time of my previous post, I had 2 frames in the swf, but somehow everything was loaded on the first frame.
So, when I checked my swf, I would always only see FRAME 0, and no reference at all the my second frame…

I still don’t quite know what went wrong, but the thing that finally did it for me, was to simply clean my project (shift + F8), en rebuild it (F8). Poofff. Like magic. :smile: My preloader image loads on FR.0, all the game stuff on the next frame …

So : for future reference :

  • The code in the preloader class is the same as that of everybody else (and yes : you DO need to use getDefinitionByName() (which somehow always caused errors for me) ; using new MyGameClass() instead will cause all the game stuff to load on FR.0 !)
  • I’m using the AIR14 SDK with output AIR14 (but other combinations seem to work as well).
  • Don’t forget to add ‘additional compiler options [0] : -frame gameFrameLabel MyGameClass’ in the project properties.