Skip to content

Instantly share code, notes, and snippets.

@NicolaiSattler
Created October 20, 2011 10:19
Show Gist options
  • Select an option

  • Save NicolaiSattler/1300832 to your computer and use it in GitHub Desktop.

Select an option

Save NicolaiSattler/1300832 to your computer and use it in GitHub Desktop.
trail
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class LineTrail extends Sprite
{
public var _timer:Timer;
public var _counter:uint;
public var _spawnPos:Array = new Array();
public function LineTrail()
{
addEventListener(Event.ADDED_TO_STAGE,init);
}
public function init(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init)
_timer = new Timer(16);
_timer.addEventListener(TimerEvent.TIMER, spawn);
_timer.start();
}
public function spawn(te:TimerEvent):void
{
_counter+=1;
_spawnPos['x']= (Math.sin(_counter/55)*300+200)+(Math.cos(_counter/10)*150+200);
_spawnPos['y']= (Math.cos(_counter/44)*200+150)+(Math.sin(_counter/11)/100+150);
_spawnPos['z']= (Math.cos(_counter/100)*200+150)+(Math.sin(_counter/500)/100+150);
var pt:Line = new Line();
pt._effectList2.push(new GravityEffectTrail(1));
pt._effectList2.push(new FadeEffectTrail());
pt.x = _spawnPos['x'];
pt.y = _spawnPos['y'];
pt.z = _spawnPos['z'];
addChild(pt);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment