Native3D Particle Test
♥0 |
Line 40 |
Modified 2011-10-16 08:31:46 |
MIT License
archived:2017-03-30 22:03:48
ActionScript3 source code
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/orkZ
*/
package {
import flash.geom.*;
import flash.display.Bitmap
import flash.display.BitmapData
import flash.display.DisplayObject
import flash.display.Sprite
import flash.events.Event
[SWF(width="465", height="465", frameRate="30", backgroundColor="0x000000")]
public class ParticlesField extends Sprite
{
public var stars:Sprite = new Sprite()
public var pointsVector:Vector.<Vector3D> = new Vector.<Vector3D>()
protected var iter:int
public function ParticlesField()
{
addParticles()
addChild( stars )
addEventListener(Event.ENTER_FRAME, frameListener)
};
public function addParticles():void
{
for(iter=0; iter<800; iter++) {
pointsVector.push(new Vector3D(Math.random()*800 - 400, Math.random()*500 - 250, Math.random()*900 - 450) )
var tempStarData:BitmapData = new BitmapData(5, 5, true, 0xaaFFFFFF)
var tempStar:Bitmap = new Bitmap(tempStarData)//Star_1()//Bitmap(tempStarData)
tempStar.x = pointsVector[iter].x
tempStar.y = pointsVector[iter].y
tempStar.z = pointsVector[iter].z
tempStar.rotationY+= Math.round( Math.random()*800 )
stars.addChild( tempStar )
}
stars.x = 300
stars.z = 500
stars.y = 150
};
protected function frameListener(evt:Event):void{
stars.rotationY++
};
}
}