blackHole
/**
* Copyright tipein123 ( http://wonderfl.net/user/tipein123 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cAtJ
*/
// forked from tipein123's forked from: forked from: Kinderliste Enter_Frame
// forked from tipein123's forked from: Kinderliste Enter_Frame
// forked from tipein123's Kinderliste Enter_Frame
// forked from tipein123's forked from: Kinderliste
// forked from tipein123's Kinderliste
// forked from tipein123's forked from: test kinder
// forked from tipein123's test kinder
package {
import flash.geom.Point;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.filters.*;
[SWF(width="500",height="500",backgroundColor="0x000000",frameRate="30")]
public class FlashTest extends Sprite {
public function FlashTest() {
var MamaRadius:Number = 30;
var KinderRadius:Number = 1.2;
var KinderMenge:int = 1000;
var Verdrehung:Number = 6;
var KuerzungsFaktor:Number = 0.94;
var Mama:Sprite = new Sprite();
Mama.graphics.beginFill(0x111111);
Mama.graphics.drawCircle(0, 0, MamaRadius);
addChild(Mama);
Mama.x = 250;
Mama.y = 250;
var glow1:GlowFilter = new GlowFilter(0xff0000,1,50,50)
var glow2:GlowFilter = new GlowFilter(0x00ff33,1,60,60)
Mama.filters = [glow1];
var Kinderliste:Array = new Array();
var Farbliste:Array = new Array(0xFFFFFF,0xFF0000,0x00FF00,0x0000FF,0x00FFFF,0xFF00FF,0xFFFF00);
for(var i:uint = 0; i<KinderMenge; i++){
var Kind:Sprite = new Sprite();
Kinderliste.push(Kind);
var Farbnummer:uint = (Math.random()*8)-1;
Kind.graphics.beginFill(Farbliste[Farbnummer]);// i%7
Kind.graphics.drawCircle(0, 0, KinderRadius/10*Math.random()*10);
addChild(Kind);
Kind.filters = [glow2];
irgendwoAblegen(Kind);
Kind.addEventListener(Event.ENTER_FRAME, bewegeDich);
}
function irgendwoAblegen(iA:Sprite):void {
iA.x = Math.random()*stage.stageWidth;
iA.y = Math.random()*stage.stageHeight;
}
function bewegeDich(bdVon:Event):void {
//bdVon.target.x -= bdVon.target.x / 10;
//bdVon.target.y -= bdVon.target.y / 10;
var wohin:Array = holeNeuenPunkt(bdVon.target.x,bdVon.target.y);
bdVon.target.x = wohin[0];
bdVon.target.y = wohin[1];
//Ziel erreicht ?
if ((Math.abs(bdVon.target.x-stage.mouseX) < MamaRadius*0.5) && (Math.abs(bdVon.target.y-stage.mouseY) < MamaRadius*0.5))
{
irgendwoAblegen(bdVon.target)
}
}
function holeNeuenPunkt(nPx:Number , nPy:Number):Array{
var Winkel:Number;
var Ausgabe:Array;
var Ziel:Point = new Point(stage.mouseX,stage.mouseY);
var Laenge:Number = Math.sqrt( (nPx-Ziel.x)*(nPx-Ziel.x) + (nPy-Ziel.y) * (nPy-Ziel.y) );
Laenge = Laenge * KuerzungsFaktor;
Winkel = Math.atan2 ((nPx - Ziel.x), (nPy - Ziel.y));
Winkel = Winkel + (Math.PI/180)*Verdrehung;
Ausgabe = [ Ziel.x + (Math.sin(Winkel)*Laenge) , Ziel.y + (Math.cos(Winkel)*Laenge) ];
Mama.x = Ziel.x;
Mama.y = Ziel.y;
return Ausgabe;
}
}
}
}