import flash.filters.*; import flash.display.BitmapData; import flash.geom.Matrix; var dotmc:MovieClip=this.createEmptyMovieClip('dotmc',this.getNextHighestDepth()) drawdot(dotmc,0,0,5,undefined,0xd0d0d0); dotmc._alpha=0; var dotmc2:MovieClip=this.createEmptyMovieClip('dotmc',this.getNextHighestDepth()) drawdot(dotmc2,0,0,2,undefined,0x00d000); dotmc2._alpha=0; var bmp:BitmapData = new flash.display.BitmapData(640, 300,false,0x004A00); drawMC.attachBitmap(bmp, 1); drawPixeldot(bmp,400,200) MCmoveto(this.mmcc,400,200,0,0) stop(); function drawPixeldot(bmp:BitmapData,x,y){ //bmp.draw(drawMC, myMatrix, myColorTransform, blendMode, myRectangle, smooth); //var filter:BitmapFilter = new BlurFilter(5, 5, 2); //bmp.applyFilter(bmp, bmp.rectangle, new Point(0, 0), filter); var myMatrix:Matrix = new Matrix(); myMatrix.tx=x; myMatrix.ty=y; bmp.draw(dotmc,myMatrix); } function drawPixeldot2(bmp:BitmapData,x,y){ var filter:BitmapFilter = new BlurFilter(2, 2, 1); bmp.applyFilter(bmp, bmp.rectangle, new Point(0, 0), filter); var myMatrix:Matrix = new Matrix(); myMatrix.tx=x; myMatrix.ty=y; bmp.draw(dotmc2,myMatrix); } function MCmoveto(MC:MovieClip,zx,zy,pos,schritte){ if(pos==0) { schritte=Math.round(streckenlaenge2D([MC._x,MC._y],[zx,zy])*0.2); if(schritte<30)schritte=30; if(schritte>60)schritte=60; } pos++; var nx=(zx-MC._x)/schritte*(pos*0.25); var ny=(zy-MC._y)/schritte*(pos*0.25); //Richtung bestimmen var winkel=90+Math.atan2(ny, nx) * 180 / Math.PI; if(pos==1)MC._rotation=winkel; if(pos==schritte || (MC._x==zx && MC._y==zy) ) { //fertig, neues Ziel per Zufall erzeugen zx=Math.round(Math.random()*540)+50; zy=Math.round(Math.random()*200)+50; drawPixeldot(bmp,zx,zy) setTimeout(MCmoveto,25, MC,zx,zy,0,schritte); } else {//in Richtung Ziel schieben MC._x+=Math.round(nx); MC._y+=Math.round(ny); drawPixeldot2(bmp,MC._x,MC._y) //pfeilspur setTimeout(MCmoveto,25, MC,zx,zy,pos,schritte);//Timeout neustarten updateAfterEvent(); } }; function streckenlaenge2D(p1,p2:Array):Number { return Math.sqrt( Math.pow(p2[1]-p1[1],2)+Math.pow(p2[0]-p1[0],2)); } function drawdot(mc:MovieClip,x,y,r,randfarbe,fillfarbe){//x,y=Mittelpunkt var ziel:MovieClip if(fillfarbe!=undefined) mc.beginFill(fillfarbe,100); else mc.beginFill(0,0); if(randfarbe!=undefined) mc.lineStyle(1,randfarbe, 100); else mc.lineStyle(0,0, 0); mc.moveTo(x+r, y);//erste Position mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y); mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y); mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y); mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y); mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y); mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y); mc.endFill(); }