flash on 2012-4-12
♥0 |
Line 108 |
Modified 2012-04-12 07:42:41 |
MIT License
archived:2017-03-30 09:20:34
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/iZuS
*/
package
{
import flash.display.*
import flash.events.*
import flash.geom.*
import flash.ui.*
import com.greensock.*
import com.greensock.easing.*
public class FlashTest extends Sprite
{
public const SW:Number = new Number( stage.stageWidth )
public const SH:Number = new Number( stage.stageHeight )
public const SD:Number = new Number( 1000 )
public var Particles :Array
public var ball :Ball
public var numParticle :int = 2
public var minDist :Number = 2
public var size :int
public function FlashTest()
{
xINIT()
}
public function xINIT():void
{
Particles = []
for (var i:int = 0; i <numParticle; i++)
{
Particles.push( new Ball(5) )
size = Math.random()*3+2
Particles[i].scaleY = Particles[i].scaleX = size
Particles[i].mass = size
Particles[i].x = Math.random() * SW
Particles[i].y = Math.random() * SH
Particles[i].z = Math.random() * SD
Particles[i].vx = Math.random()* 6 - 3
Particles[i].vy = Math.random()* 6 - 3
Particles[i].vz = Math.random()* 6 - 3
addChild( Particles[i] )
}
addEventListener(Event.ENTER_FRAME, xREALTIME);
}
public function xREALTIME( e:Event ):void
{
for (var i:int = 0;i < numParticle;i++)
{
var p:Ball = Particles[i]
p.x += p.vx
p.y += p.vy
p.z += p.vz
if (p.x >stage.stageWidth + p.width/2){
p.x =0;
} else if (p.x < -p.width){
p.x = stage.stageWidth;
}
if (p.y > stage.stageHeight + p.height/2){
p.y = 0;
} else if (p.y < -p.height) {
p.y = stage.stageHeight;
}
}
for (i = 0; i < numParticle;i++)
{
var pA:Ball = Particles[i];
for (var j:int = 0;j < numParticle - 1;j++){
var pB:Ball = Particles[j];
}
}
graphics.clear();
particleLine();
}
public function particleLine():void
{
for (var i:int=0; i<numParticle-1; i++)
{
graphics.lineStyle(4,0x131413);
// graphics.lineTo(Particles[i].x.localToGlobal3D, Particles[i].y);
graphics.moveTo(Particles[i].LOC_getFix.x, Particles[i].LOC_getFix.y);
//graphics.moveTo(Particles[i].z, Particles[i].z);
}
}
}
}
import flash.display.*
import flash.events.*
import flash.geom.*
class Ball extends Sprite
{
public var mass:int
public var vx :Number
public var vy :Number
public var vz :Number
public var w :Number = 0
public var regX:Number
public var regY:Number
public var regZ:Number
public var regLOC:Vector3D
public function Ball (r:Number = 5,color:uint = 0x000000)
{
this.z = 0 // Converts 'this' object to a 3D object in the public namespace.
graphics.lineStyle(0)
graphics.beginFill(color)
graphics.drawCircle( r/2,r/2,r )
graphics.endFill()
}
public function LOC_getFix( LOCevent:Event ):Vector3D
{
regLOC = new Vector3D( this.x,this.y,this.z,this.w )
return regLOC
}
}