forked from: SimpleButton
forked from SimpleButton (diff: 3)
ActionScript3 source code
/**
* Copyright uepon24 ( http://wonderfl.net/user/uepon24 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qAiT
*/
// forked from emanon's SimpleButton
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.SimpleButton;
[SWF(width="465", height="465", frameRate="60")]
public class Main extends Sprite
{
public function Main()
{
var button:SimpleButton = new SimpleButton();
button.x = 10;
button.y = 10;
button.upState = makeRoundRect(0x228822); //ボタン通常時
button.overState = makeRoundRect(0x225522); //マウスが乗っているとき
button.downState = makeRoundRect(0x553355); //押されたとき
button.hitTestState = button.upState;
addChild(button);
button.addEventListener(MouseEvent.CLICK, onButtonClick);
}
//ボタン作成
private function makeRoundRect(color:uint):Sprite{
var s:Sprite = new Sprite();
s.graphics.beginFill(color);
s.graphics.drawRoundRect(0, 0, 100, 20, 15);
s.graphics.endFill();
s.alpha = 0.8;
return s;
}
//イベント
private function onButtonClick(event:MouseEvent):void
{
graphics.beginFill(Math.floor(Math.random() * 0xFFFFFF), 0.5);
graphics.drawCircle(Math.floor(Math.random() * 465),
Math.floor(Math.random() * 465), 50);
graphics.endFill();
}
}
}
