flash on 2013-11-27
♥0 |
Line 43 |
Modified 2013-11-27 12:18:41 |
MIT License
archived:2017-03-30 02:42:05
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rBWJ
*/
package {
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var btn:Btn = new Btn();
addChild(btn);
}
}
}
import flash.display.*;
import flash.events.*;
import flash.text.*;
class Btn extends Sprite{
private var w:Number;//幅
private var h:Number;//高さ
private var ba:Number = 0.1;//背景透過率
private var color1:uint = 0x00aaff;
private var color2:uint = 0xaaaaaa;//背景色
private var _text:TextField;
public function Btn(width:Number=100,height:Number=20):void{
w = width;
h = height;
_text = new TextField();
_text.textColor = color1;
_text.selectable = false;
_text.text = "test";
addChild(_text);
draw();
}
private function draw():void{
graphics.lineStyle(0,color1);
graphics.beginFill(color2,ba);
graphics.drawRect(0,0,w,h);
graphics.endFill();
_text.x = (w/2)-(_text.textWidth/2);
var s:Sprite = new Sprite();
s.graphics.beginFill(0,0);
s.graphics.drawRect(0,0,w,h);
s.graphics.endFill();
addChild(s);
s.buttonMode = true;
}
}