flash on 2010-4-28
♥0 |
Line 69 |
Modified 2010-04-28 01:49:49 |
MIT License
archived:2017-03-20 02:51:12
ActionScript3 source code
/**
* Copyright foo9 ( http://wonderfl.net/user/foo9 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jpAK
*/
package {
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.display.BitmapData;
import flash.display.Bitmap;
public class FlashTest extends Sprite {
//public static const TEXT:String = "厂下广卞廿士十亠卉半与本二上旦"; // ?
//public static const TEXT:String = "猫マナー猫マナー猫マナー猫マナー"; // ?
//public static const TEXT:String = "123456789012345678901234567890";
public static const TEXT:String = "一 二 三 四 五 六 七 八 九 十 零";
public function FlashTest() {
var shape:Shape = new Shape();
addChild(shape);
shape.x = stage.stageWidth * 0.5;
shape.y = stage.stageHeight * 0.5;
var g:Graphics = shape.graphics;
g.lineStyle(1, 0x000000, 1.0);
g.beginFill(0xcccccc);
var r:Number = 170.0;
var n:uint = 99;
var rate:Number;
var x:Number;
var y:Number;
x = r * Math.cos(0);
y = r * Math.sin(0);
var x0:Number = x;
var y0:Number = y;
var x1:Number;
var y1:Number;
g.moveTo(x0, y0);
for (var i:uint = 1; i < n + 1; i++) {
rate = i / n;
x1 = r * Math.cos(2.0 * Math.PI * rate);
y1 = r * Math.sin(2.0 * Math.PI * rate);
g.lineTo(x1, y1);
//2点でできる線の角度を求める? ?
var rotation:Number = Math.atan2(y1 - y0, x1 - x0) * 180 / Math.PI;
//TODO:
var tf:TextField;
var bm:Bitmap;
var bmd:BitmapData;
var sp:Sprite;
tf = new TextField();
tf.text = TEXT; // + " " + i.toString();
tf.autoSize = TextFieldAutoSize.LEFT;
bmd = new BitmapData(tf.width, tf.height, true, 0x00ffffff);
bmd.draw(tf);
bm = new Bitmap(bmd, "auto", true);
bm.smoothing = true;
sp = new Sprite();
sp.addChild(bm);
addChild(sp);
sp.x = x1 - x0 + stage.stageWidth * 0.5;
sp.y = y1 - y0 + stage.stageHeight * 0.5;
sp.rotation = rotation;
sp.scaleX = sp.scaleY = 1.0;
x0 = x1;
y0 = y1;
}
g.endFill();
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
}
private function keyDown(event:KeyboardEvent):void {
if( (event.keyCode == 13) || (event.keyCode == Keyboard.ENTER) ) {
//TODO:
}
}
}
}