3 Replies Latest reply on Apr 3, 2016 8:21 PM by pocket_sevens

    How do you create an instance of an object through code only?

    pocket_sevens

      Hi there everyone! So I'm watching some Flash3 tutorials on YouTube that have been extremely helpful, except there are some inconsistencies.  The guy in the tutorial said that the following code is equivalent to actually dragging a symbol called flyer onto the stage:

       

      Package  {

       

        import flash.display.MovieClip;

       

             public class Main extends MovieClip {

       

                  var flyer:Flyer = new Flyer();

             

                  public function Main() {

       

                       startGame();

                  }

       

                  public function startGame():void {

                        //positions flyer in middle of the stage

                       flyer.x = stage.stageWidth*.5;

                       fyler.y = stage.stageHeight*.5;

                       addChild(flyer);

                  }

       

            }

      }

       

       

      Sadly when I test this nothing happens, and this is an error I've been running into a lot. I believe the tutorial author is using an older version of Flash, could that be why?

       

      In summary my question is how do you create a symbol on the stage using Actionscript only? I would greatly appreciate anyone who could help me out with this in any way, whether it be answering the question yourself or pointing me towards a tutorial that could answer it. I'm really pressed for time and I've already sunk hours into trying to figure this out. Please help!