ほっとくと消える
がべじちゃんお掃除してくれるだろうか・・・
package {
import flash.geom.Point;
import flash.filters.ColorMatrixFilter;
import flash.text.TextField;
import flash.events.Event;
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import net.hires.debug.Stats;
[SWF(width="465",height="465",backgroundColor="0x000000",frameRate="60")]
public class FlashTest extends Sprite {
private var tf:TextField;
private var eff:BitmapData;
private var bmp:Bitmap;
private var cmf:ColorMatrixFilter;
public function FlashTest() {
addEventListener(Event.ENTER_FRAME,onEnterFrame);
tf=new TextField();
tf.textColor=0xffffff;
addChild(tf);
tf.text=numChildren.toString();
eff=new BitmapData(465,465,true,0x00000000);
bmp=new Bitmap(eff);
addChild(bmp);
cmf=new ColorMatrixFilter([
1,0,0,0,-64,
0,1,0,0,0,
0,0,1,0,-16,
0,0,0,0.49,0
]);
var stats:Stats=new Stats();
stats.y=350;
addChild(stats);
}
private function onEnterFrame(e:Event):void{
eff.applyFilter(eff,eff.rect,new Point(0,0),cmf);
var t:Test=new Test(465/2,465);
addChild(t);
t=null;
tf.text=numChildren.toString();
eff.draw(this);
}
}
}
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
class Test extends Sprite{
private var _parent:Sprite;
private var c:int;
private var px:Number;
private var py:Number;
private var sx:Number;
private var sy:Number;
public function Test(x:Number,y:Number){
_parent=null;
this.x=x;
this.y=y;
c=0;
var g:Graphics=graphics;
g.beginFill(0xffffff);
g.moveTo(0,0);
g.lineTo(-8,16);
g.lineTo(0,4);
g.lineTo(8,16);
g.endFill();
g.beginFill(0xffffff);
g.drawEllipse(-2,16,4,8);
g.endFill();
px=Math.random()*(465+400)-200;
py=Math.random()*100;
rotation=90+Math.atan2(py-465,px-465/2)*180/Math.PI;
addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
}
private function onAddedToStage(event:Event):void{
_parent=Sprite(parent);
sx=x;
sy=y;
removeEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onEnterFrame(event:Event):void{
var ox:Number=x;
var oy:Number=y;
var t:Number=c/100;
var qx:Number=sx*(1-t)+px*t;
var qy:Number=sy*(1-t)+py*t;
var rx:Number=px*(1-t)+(465/2)*t;
var ry:Number=py*(1-t)+0*t;
x=qx*(1-t)+rx*t;
y=qy*(1-t)+ry*t;
rotation=90+Math.atan2(y-oy,x-ox)*180/Math.PI;
c++;
if(c>=105){
graphics.clear();
removeEventListener(Event.ENTER_FRAME,onEnterFrame);
parent.removeChild(this);
}
}
}