Question

Hi I have made a tile based game using a tutorial from this site http://www.wildbunny.co.uk/blog/2011...m-game-part-1/ My game is complete but I want to add a preloader to it.

A little background for a hopefully better understanding.

FlashDevelop is where all of my as3 files and classes are and I can also test my game here and I works fine.

Flash CS6 is where I have only one scene "scene 1" with one frame on it, this frame has all of my tile based images ( movieClips ) and animations in squares, if I double click a movieClip ( for example "player" ) it will go inside and I have got lots of frames ( jumping, running etc ).

I can't test my game from here, It shows errors (scenes are NAN). I think that's normal not sure - maybe off topic anyway.

I have looked on the internet for a tutorial on preloaders suiting my situation but can't find any using flash with flashDevelop and AS3.

Was it helpful?

Solution

You create a brand new project "Actionscript 3 with preloader", FD will generate you a preloader class *.as file, and a main class file with a [frame] directive in it. Copy the preloader *.as file into your current project, copy the directive from new project's Main.as into your project's Main.as, change the package name if needed in both places (in preloader's getDefinitionByName() call and in the directive - fully qualified class names required), add whatever visuals you want to your preloader class, and you're set.

The directive in my case looked like this:

[Frame(factoryClass="Geologist.Preloader")]

The package is Geologist, and the startup() function of the preloader was like this:

private function startup():void 
{
    var mainClass:Class = getDefinitionByName("Geologist.Main") as Class;
    var theStage:Stage = this.stage;
    theStage.addChild(new mainClass() as DisplayObject);
    theStage.removeChild(this);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top