Question

So I had been messing around in AS3 for awhile and had done some basic starting flash game things, but then found out I could use air to make them for mobile platforms. So I tried copying over what I had worked on before, but I am running into issues.

Right now I am just trying to find out how to add an instance of a MovieClip to the stage. I have an image converted to a MovieClip with it's own class so I can manipulate it later (such as moving around) and I have this in my Main class:

class Main extends MovieClip
{
    var space:Background;  //Background is the MovieClip

    function Main():void
    {
        space = new Background(stage);
        stage.addChild(space);
    }
}

But when I run the program, the image doesn't show up. It works that way when I just had a standard AS3 program and I don't understand why it would be different when I am trying to use AIR. Any assistance would be greatly appreciated, thank you.

Was it helpful?

Solution 3

Rajneesh Gaikwad had the answer, I didn't have my Main class as my Document class.

OTHER TIPS

Put the word 'public' in front of 'class' in your first line.

Also remove the 'stage' from the first line in your constructor: make it space = new Background();

And do you really need 'stage' in the addChild statement? Unnecessarily verbose!

I can run this code through the AIR compiler (AIR SDK 3.8 or later):

package  

{
    import flash.display.MovieClip;

    public class MAIN extends MovieClip
    {
        var space:Background; 

        public function MAIN()
        {

            space = new Background();
            stage.addChild(space);
        }
    }

}

With an image inside the Background class it shows up fine. My 'Background' is a library symbol linked for Actionscript. If your 'Background' is pure Actionscript are you adding a graphic to it?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top