• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How to display buttons on the stage?

New Here ,
Oct 01, 2012 Oct 01, 2012

Copy link to clipboard

Copied

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;

                    }

          }

}

Views

428

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 02, 2012 Oct 02, 2012

Copy link to clipboard

Copied

LATEST

there is no line of:

upButton.addChild(upButtonLoader);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines