flash on 2009-9-11

by ta1
♥0 | Line 46 | Modified 2009-09-11 18:58:50 | MIT License
play

ActionScript3 source code

/**
 * Copyright ta1 ( http://wonderfl.net/user/ta1 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/yU7D
 */

ppackage {
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.net.*;

	public class Link extends MovieClip {

		public function Link():void {
			
			var circle:Sprite = new Sprite();
			circle.graphics.beginFill(0xFF0000);
			circle.graphics.drawCircle(100,100,50);
			this.addChild(circle);
			
			//btnの設定
			this.buttonMode=true;
			var btText:SimpleButton = new SimpleButton();
			var txtUp:TextField = new TextField();
			var txtOver:TextField = new TextField();
			var txtDown:TextField = new TextField();
			setBtnText(txtUp,"?",0xDDDDDD);
			setBtnText(txtOver,"!",0xFFFF00);
			setBtnText(txtDown,"ありがとう",0xFF9900);
			
			btText.upState = txtUp;
			btText.overState = txtOver;
			btText.downState = btText.hitTestState = txtDown;
			btText.x=75;
			btText.y=75;
			this.addChild(btText);
			function setBtnText(txt:TextField,str:String,bgCol:uint):void{
				txt.text = str;
				txt.width = 50;
				txt.height = 50;
				txt.background = true;
				txt.backgroundColor = bgCol;
				var tFormat :TextFormat = new TextFormat();
				tFormat.align = TextFormatAlign.CENTER;
				tFormat.size = 48;
				txt.setTextFormat(tFormat);
				}

			this.addEventListener(MouseEvent.CLICK,gotoLink);

			function gotoLink(event:Event):void {


				//押してくれてありがとう!
				trace("Thanks");
				var thanks:String = "http://thx.kayac.jp/pc/";
				var request:URLRequest = new URLRequest(thanks);
				navigateToURL(request,"_blank");

			}

		}
	}
}