Create button with code AS3

I feel like something like this exists, but how to create a button in only script 3 code action ? I mean without , creating a form and transforming it into a button symbol or something like that. It would probably be easier to work only with FlashDevelop.

+6
source share
1 answer

You can use the SimpleButton class or flip your own using the Sprite class. Then you can draw something or use any image as a button, and then by default.

For example, a simple button might look like this:

 var goButton:SimpleButton = new SimpleButton(); var myButtonSprite:Sprite = new Sprite(); myButtonSprite.graphics.lineStyle(1, 0x555555); myButtonSprite.graphics.beginFill(0xff000,1); myButtonSprite.graphics.drawRect(0,0,200,30); myButtonSprite.graphics.endFill(); goButton.overState = goButton.downState = goButton.upState = goButton.hitTestState = myButtonSprite; addChild(goButton); 

You can have different display objects for each button state, or you can attach bitmaps instead of sprites.

+13
source

Source: https://habr.com/ru/post/943932/


All Articles