flash on 2010-3-31
/**
* Copyright deform ( http://wonderfl.net/user/deform )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/lpAP
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.DisplayObject;
public class FlashTest extends Sprite {
private var hit:Sprite;
private var container:Sprite;
private var tf:TextField;
private var rotateNum:Number = 3;
public function FlashTest() {
// write as3 code here..
hit = new Sprite();
hit.graphics.beginFill(0xff0000,0);
hit.graphics.drawRect(0,0,465,465);
hit.graphics.endFill();
container = new Sprite();
container.x = container.y = 465/2;
addChild(container);
tf = new TextField();
tf.text = "松本";
tf.width = tf.textWidth+4;
tf.height = tf.textHeight+4;
tf.mouseEnabled = false;
container.addChild(tf);
setRatio(tf);
addChild(hit);
addEventListener(Event.ENTER_FRAME, _updateHandler);
hit.addEventListener(MouseEvent.ROLL_OVER, _rolloverHandler);
hit.addEventListener(MouseEvent.ROLL_OUT, _rolloutHandler);
}
private function setRatio(t:DisplayObject):void
{
var ratio:Number = Math.min(465/t.width, 465/t.height);
t.scaleX = ratio;
t.scaleY = ratio;
t.x = -t.width/2;
t.y = -t.height/2;
}
private function _rolloverHandler(e:MouseEvent):void
{
rotateNum = 15;
}
private function _rolloutHandler(e:MouseEvent):void
{
rotateNum = 3;
}
private function _updateHandler(e:Event):void
{
container.rotationY += rotateNum;
}
}
}