adding SimpleButton to: flash on 2014-9-3
Refactoring the button into its own class with the help of the Box helper class, employing functionality from SimpleButton.
♥0 |
Line 38 |
Modified 2014-09-03 22:13:09 |
MIT License
archived:2017-03-20 02:18:42
ActionScript3 source code
/**
* Copyright milchreis ( http://wonderfl.net/user/milchreis )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/lgbR
*/
// forked from MadeByBeta's flash on 2014-9-3
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Graphics;
import flash.events.MouseEvent;
public class Main extends Sprite
{
private var button:BoxButton;
public function Main():void
{
//Create a new instance of a Sprite to act as the button graphic. Then create the text.
button = new BoxButton(0x99CCFF, 0xFF0000, 0x99CCFF);
button.width = 220;
button.height = 60;
addChild(button);
}
}
}
import flash.display.SimpleButton;
import flash.display.Shape;
internal class Box extends Shape
{
public function Box(color:uint = 0)
{
graphics.beginFill(color);
graphics.drawRect(0,0,100,100);
graphics.endFill();
}
}
internal class BoxButton extends SimpleButton
{
public function BoxButton(upColor:uint = 0, overColor:uint = 0, downColor:uint = 0)
{
var up:Box = new Box(upColor);
super(up, new Box(overColor), new Box(downColor), up);
useHandCursor = true;
}
}