- 2008年3月23日 09:43
- flash
楕円軌道を描くテキスト。AS2.0用ソースコード。
FLASH8以上なら、1frame目にそのままコピペで実行できます。
ステージの真ん中を中心とする楕円軌道。
今回のソースは若干長め。
import flash.display.BitmapData;
var tf:TextField = _root.createTextField("t",100,0,0,0,0);
tf.autoSize = true;
tf._visible = false;
var format:TextFormat = new TextFormat();
with(format){size = 16; bold = true; color = 0xffffff;}
var cx:Number = Stage.width/2;
var cy:Number = Stage.height/2;
var n:Number = 0;
var str:String = "thiswebsiteispapiness";
var mc:MovieClip = _root.createEmptyMovieClip("m",0);
mc.moveTo(0,0);
mc.beginFill(Math.random()*255*65536+Math.random()*255*256+Math.random()*255);
mc.lineTo(0,cy*2);
mc.lineTo(cx*2,cy*2);
mc.lineTo(cx*2,0);
mc.endFill();
mc.onPress = function(){};
_root.onMouseDown = function(){
tf.text = str.substr(n++,1);
tf.setTextFormat(format);
mc = _root.createEmptyMovieClip("mc"+n,n);
mc.createEmptyMovieClip("m",0);
var bmd:BitmapData = new BitmapData(tf._width,tf._height,true,0xffffff);
mc.m.attachBitmap(bmd,0);
mc.m._x = -tf._width/2;
mc.m._y = -tf._height/2;
bmd.draw(tf);
if(cx < _xmouse) {mc.dig = 90; mc.h = _ymouse-cy;}
else {mc.dig = 270; mc.h = cy-_ymouse;}
mc.r = Math.abs(cx-_xmouse);
mc.onEnterFrame = function () {
this.rad = Math.PI/180*this.dig;
this.ya = Math.cos(this.rad);
this.xa = Math.sin(this.rad);
this._x = this.xa * this.r + cx;
this._y = this.ya * this.r/2 + cy + this.xa*(this.h);
this._xscale = this._yscale = (this.ya+1) * 150 + 150;
this.dig + = 4;
}
}
マウスクリックでテキストが現れます。
テキストの内容は"this web site is papiness"。
- Newer: sound synch
- Older: .JSFL : swap instance