forked from: Space
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/w1Mn
*/
// forked from devenulol's Space
package {
import flash.display.AVM1Movie;
import flash.events.Event;
import flash.display.Sprite;
import flash.filters.BitmapFilterQuality;
import flash.filters.GlowFilter;
[SWF(backgroundColor="#000000", frameRate=30)]
public class Space extends Sprite {
public var stars:Array = new Array();
public var starCount:Number = 0;
public var glow1:GlowFilter = new GlowFilter(0x000055, 8, 8, 8, 15, 2, false, false);
public var glow2:GlowFilter = new GlowFilter(0x440044, 8, 8, 8, 15, 2, false, false);
public var glow3:GlowFilter = new GlowFilter(0x222222, 8, 8, 8, 15, 2, false, false);
public var starColors:Array = new Array(glow1,glow2,glow3);
public var i:int = 0;
public var sLocations:Array = new Array();
public function Space():void {
for (starCount; starCount < 1500; starCount++){
var star:Sprite = new Sprite();
var colorCheck:int = (Math.random() * 3);
star.graphics.beginFill(0xFFFFFF);
star.graphics.drawCircle(0,0,1.3);
star.graphics.endFill();
star.filters = [starColors[colorCheck]];
stars.push(star);
sLocations.push((Math.random()*0.90) + 6);
}
for (i; i < starCount; i++){
stars[i].x = ((Math.random()*stage.stageWidth)) *2 ;
stars[i].y = ((Math.random()*stage.stageHeight)) *2;
stars[i].z = (Math.random()*3000);
addChild(stars[i]);
addEventListener(Event.ENTER_FRAME, moveStars);
}
}
public function moveStars(e:Event):void{
for (var n:int = 0; n < i; n++){
stars[n].x -= sLocations[n];
if (stars[n].x < 0 && stars[n].y < stage.stageHeight){
stars[n].x = stage.stageWidth;
stars[n].z = 0;
};
if (mouseY > stage.stageWidth/2) {
stars[n].z -= mouseY/(mouseY*.2);
}
if (mouseY < stage.stageWidth/2) {
stars[n].z += mouseY/(mouseY*.2);
}
}
}
}
}