forked from: forked from: forked from: SNOW DANCE
forked from forked from: forked from: SNOW DANCE (diff: 81)
ActionScript3 source code
/**
* Copyright DLabz ( http://wonderfl.net/user/DLabz )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iyRe
*/
// forked from DLabz's forked from: forked from: SNOW DANCE
// forked from makc3d's forked from: SNOW DANCE
// forked from KBM's SNOW DANCE
package {
import flash.display.Graphics;
import flash.events.Event;
import flash.display.Sprite;
import flash.geom.Vector3D;
public class Base extends Sprite {
public var density:int = 2;
public var limit:int = 0;
public var mv:Vector3D =new Vector3D(100,100,100);
public var center: Vector3D = new Vector3D(200,200,200);
public var male: SNparticle = new SNparticle(center, center);
public var female: SNparticle = new SNparticle(mv, center);
public function Base() {
// write as3 code here..
//var w:Vector3D = new Vector3D(10,10,10);
var gr:Graphics = this.graphics;
gr.beginFill(0, 1);
gr.drawRect(0,0,stage.stageWidth,stage.stageHeight);
addEventListener(Event.ENTER_FRAME,onEnterFrame);
addChild(male);
addChild(female);
function onEnterFrame():void{
}
}
}
}
import flash.geom.Vector3D;
import flash.filters.GlowFilter;
import flash.display.Graphics;
import flash.events.Event;
import flash.display.Sprite;
class SNparticle extends Sprite{
///public var depth = 0;
private var e:Number;
private var v:Vector3D;
private var a:Vector3D;
private var gr:Graphics;
public function SNparticle(position:Vector3D, center:Vector3D){
this.x = position.x;
this.y = position.y;
this.z = position.z;
//velocity.negate();
var love:Vector3D = position.clone();
this.e = love.dotProduct(position);
love.negate();
love.normalize();
this.v = love;
var gr:Graphics = this.graphics;
gr.beginFill(0xFFFFFF);
gr.drawCircle(0,0,10);
//this.v = new Vector3D(1,5,1);
//r/=10;
gr.endFill();
// this.filters = [new GlowFilter(0xFFFFFF,1,7,7,1,3)]
addEventListener(Event.ADDED,onStage);
}
private function onStage(e:Event):void{
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onEnterFrame(e:Event):void{
this.a = this.v.clone();
this.a.negate();
this.e = this.a.dotProduct(new Vector3D(this.x, this.y, this.z));
//this.a.normalize();
this.a.scaleBy(1/this.e);
this.v.add(this.a);
this.x += this.v.x;
this.y += this.v.y;
this.z += this.v.z;
// if(this.x > 2*stage.stageWidth || this.x < -stage.stageWidth){this.x = stage.stageWidth - this.x};
//removeEventListener(Event.ENTER_FRAME,onEnterFrame);}
}
}
