forked from: Kinderliste
/**
* Copyright tipein123 ( http://wonderfl.net/user/tipein123 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/b73i
*/
// forked from tipein123's Kinderliste
// forked from tipein123's forked from: test kinder
// forked from tipein123's test kinder
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
[SWF(width="500",height="500",backgroundColor="0x000000",frameRate="60")]
public class FlashTest extends Sprite {
public function FlashTest() {
var Mama:Sprite = new Sprite();
Mama.graphics.beginFill(0x111111);
Mama.graphics.drawCircle(0, 0, 40);
addChild(Mama);
Mama.x = 250;
Mama.y = 250;
var Kinderliste:Array = new Array();
var Farbliste:Array = new Array(0xFFFFFF,0xFF0000,0x00FF00,0x0000FF,0x00FFFF,0xFF00FF,0xFFFF00);
for(var i:uint = 0; i<21; 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, 5);
Mama.addChild(Kind);
irgendwoAblegen(Kind);
}
var ticker: Timer;
ticker = new Timer(33);
ticker.addEventListener(TimerEvent.TIMER, zielerfassung);
ticker.start();
function zielerfassung(event:TimerEvent):void {
//irgendwoAblegen(Kinderliste[5]);
for(var i:uint = 0; i<21; i++){
bewegeDich(Kinderliste[i]);
}
}
function irgendwoAblegen(iA:Sprite):void {
iA.x = Math.random()*500-250;
iA.y = Math.random()*500-250;
}
function bewegeDich(bdVon:Sprite):void {
bdVon.x -= bdVon.x / 10;
bdVon.y -= bdVon.y / 10;
//Ziel erreicht ?
if ((Math.abs(bdVon.x) <= 30) && (Math.abs(bdVon.y) <= 30)) //Mama.width
{
irgendwoAblegen(bdVon)
}
}
}
}
}