Create a Button with only code AS3
actionscript-3, button, flash
Solution
You can use the `SimpleButton` class or roll your own using the `Sprite` class. Then you can draw anything or use any image as the button and it's over, down and default states.
For example a simple button can be 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 state of the button or you can attach bitmaps instead of sprites.
Problem
I feel like something like this exists but how would I create a button in only action script 3 code? I mean without making a shape and converting it to a button symbol or something. It would probably make it easier to only work in FlashDevelop.