forked from: Chapter 25 Example 2
forked from Chapter 25 Example 2 (diff: 28)
import com.actionscriptbible.Example;
ActionScript3 source code
/**
* Copyright tsu_droid ( http://wonderfl.net/user/tsu_droid )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mBcNr
*/
// forked from actionscriptbible's Chapter 25 Example 2
package {
import flash.display.*;
import flash.text.*;
import flash.filters.BevelFilter;
import flash.events.MouseEvent;
//import com.actionscriptbible.Example;
[ SWF (width = '465', height = '465', backgroundColor = '0x000000', frameRate = '50')]
public class ch25ex2 extends Sprite {
protected var button:Sprite;
protected var text_field:TextField;
public function ch25ex2() {
graphics.beginFill(0x123456);
graphics.drawRect(0, 0, 465, 465);
graphics.endFill();
button = new Sprite();
button.graphics.lineStyle(2, 0xDDDDDD, 0.5, true);
button.mouseChildren = false;
button.graphics.beginFill(0xDDDDDD, 0.5);
button.graphics.drawRoundRect(-40, -12, 80, 24, 6, 6);
button.graphics.endFill();
button.filters = [new BevelFilter(2)];
button.buttonMode = true;
button.x = stage.stageWidth / 2;
button.y = stage.stageHeight / 2;
addChild(button);
text_field = new TextField();
button.addChild(text_field);
//text_field.border = true;
text_field.autoSize = "center";
text_field.x = -35;
text_field.y = -10;
text_field.width = 70;
text_field.height = 20;
text_field.text = "テストボタン";
button.addEventListener(MouseEvent.CLICK, onButtonClick);
}
protected function onButtonClick(event:MouseEvent):void {
doSomethingTricky(event.localX, event.localY);
}
protected function doSomethingTricky(x:Number, y:Number):void {
var distance:Number = Math.sqrt(x * x + y * y);
trace("Distance:", distance);
}
}
}
