1 Reply Latest reply on Oct 2, 2012 6:30 AM by amtamt

    How to display buttons on the stage?

    harte93

      Screen shot 2012-10-01 at 2.37.30 PM.png

       

      I'm having an issue with an upbutton not appearing after I compile my program, and I have no idea why it won't show up. The character png. file shows up fine. Please let me know you have any ideas. I've attached a screen shot (blurred some parts of it) and included the code. 

       

      package

      {

                import flash.display.Loader;

                import flash.display.Sprite;

                import flash.events.MouseEvent;

                import flash.net.URLRequest;

       

                [ SWF(width="550", height="400",

          backgroundColor="#FFFFFF", frameRate="60") ]

       

                public class GameWorld1 extends Sprite

                {

        // define variables for background

                          public var backgroundURL:URLRequest;

                          public var backgroundLoader:Loader;

                          public var background:Sprite;

       

        // declare variables for character

                          public var characterURL:URLRequest

                          public var characterLoader:Loader;

                          public var character:Sprite;

       

        // declare variables for up button

                          public var upButtonURL:URLRequest;

                          public var upButtonLoader:Loader;

                          public var upButton:Sprite;

       

                          public function GameWorld1()

                          {

        //upload background to stage

                                    backgroundURL = new URLRequest();

                                    backgroundLoader = new Loader();

                                    background = new Sprite();

       

                                    backgroundURL.url = "../images/background.png";

                                    backgroundLoader.load(backgroundURL);

                                    background.addChild(backgroundLoader);

                                    stage.addChild(background); 

       

        //upload character to stage

                                    characterURL = new URLRequest();

                                    characterLoader = new Loader();

                                    character = new Sprite();

       

                                    characterURL.url = "../images/johnny.png";

                                    characterLoader.load(characterURL);

                                    character.addChild(characterLoader);

                                    stage.addChild(character);

                                    character.x = 275;

                                    character.y = 150;

       

        //upload upButton to stage

                                    upButtonURL = new URLRequest();

                                    upButtonLoader = new Loader();

                                    upButton = new Sprite();

                                    upButtonURL.url = "../images/up.png";

                                    upButtonLoader.load(upButtonURL);

                                    stage.addChild(upButton);

                                    upButton.x = 25;

                                    upButton.y = 25;

       

                          }

                }

      }