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

Button issue

New Here ,
Sep 17, 2013 Sep 17, 2013

hello,

I'am new in as3 programming,

I use this code and there is nothing displayed on the screen.

package

{

import flash.display.Sprite;

import flash.display.Graphics;

import flash.events.Event;

import fl.core.UIComponent;

import fl.controls.Button;

public class Main extends Sprite

{

public function Main():void

{

init();

}

private function init ():void

{

var myButton:Button = new Button();

myButton.emphasized = false;

myButton.width = 150;

myButton.move(20, 20);

addChild(myButton);

}

}

}

Help me please.

TOPICS
ActionScript
915
Translate
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

correct answers 1 Correct answer

LEGEND , Sep 17, 2013 Sep 17, 2013

I just noticed in your code that you disable the border by using:

myButton.emphasized = false;

change that if you want a border around the button.

Translate
LEGEND ,
Sep 17, 2013 Sep 17, 2013

1) The code you show needs to be placed in an Actionscript class file named Main.as.  

2) You need to specify "Main" as the document class in the Properties panel of your Flash file so that it uses the Main.as file for its code

3) You need to place a Button component in the library of the Flash file - do this by dragging one from the Components library to the stage, then delete it from the stage - it will be retained in the library after that

Translate
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
New Here ,
Sep 17, 2013 Sep 17, 2013

thank you for your reply, i already did the first ans second request you wrote.

but for the third it doesn't work. I run the programm it works bur it display only a text: Label without any border of button.

PS: iam using flash develo 4.3 and for the fl.control library i downloaded the fl.swc library. i copyed in the lib folder.

Translate
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
LEGEND ,
Sep 17, 2013 Sep 17, 2013

"Label" is the default label for a Button component.  I am not familiar with whatever other component library you might be using so that might be where your problem lies... it might be the button doesn't resemble what you expect?

Try assigning a label title to the button.  If the label you describe shows that text then there's your Button displayed on the screen - problem solved...

       myButton.label = "Some Text";

Translate
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
New Here ,
Sep 17, 2013 Sep 17, 2013

it works the text is changed but same result no border for the button.

Translate
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
LEGEND ,
Sep 17, 2013 Sep 17, 2013

Try changing the background where the button is placed -  maybe it's the same color.  If you still have an issue, show a screen shot.

Also, try assigning some interaction for the button as well.

Translate
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
LEGEND ,
Sep 17, 2013 Sep 17, 2013
LATEST

I just noticed in your code that you disable the border by using:

myButton.emphasized = false;

change that if you want a border around the button.

Translate
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