/**
* Copyright Fellyph.Cintra ( http://wonderfl.net/user/Fellyph.Cintra )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vFzs
*/
// forked from Fellyph.Cintra's Seta com seno e coseno
package
{
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class LinhaMotion extends Sprite
{
public var linha :Shape;
public var timer :Timer;
public var centerX :Number;
public var centerY :Number;
public var raio :Number = 50;
public var angle :Number = 0;
public var velocidade :Number = 0.15;
public var controle :Number = 1 ;
public var centroAtualX:Number = 0;
public var centroAtualY:Number = 60;
public var posx :Number;
public var posy :Number;
public var limiteX :int = 12;
public var limiteY :int = 7;
public var contadorX :int = 1;
public var contadorY :int = 0;
public function LinhaMotion()
{
init()
}
public function init():void{
criaLinha();
}
public function onComplete(e:TimerEvent):void{
if(contadorX < limiteX){
centroAtualY = posy;
centroAtualX = posx;
}else{
centroAtualX = 0;
centroAtualY = posy + 60;
contadorX = 0
contadorY++;
}
velocidade *= -1;
if(contadorY < limiteY){
criaLinha()
contadorX++;
}
}
public function criaLinha():void{
linha = new Shape();
centerX = centroAtualX;
centerY = centroAtualY;
addChild(linha);
angle = 0;
timer = new Timer(20, 6);
timer.start();
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
}
public function onTimer(e:TimerEvent):void{
linha.graphics.clear();
linha.graphics.lineStyle(1, Math.random()*0xFFFFFF);
linha.graphics.moveTo(centerX , centerY);
posy = centerY + Math.sin(angle) * raio;
posx = centerX + Math.cos(angle) * raio;
linha. graphics.lineTo(posx, posy);
angle += velocidade;
}
}
}