/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wXEZ
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public var ta:wTag;
public var tb:wTag;
public var tc:wTag;
public function FlashTest() {
ta = new wTag(200, 200, 0);
tb = new wTag(50, 0, 1.57);
tb.par = ta;
tc = new wTag(0, 50, 0.3);
tc.par = ta;
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var ang:Number = 0;
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(1, 0);
ta.ca += 0.03;
ta.cx = 200 + Math.cos(ang) * 30;
ta.cy = 200 + Math.sin(ang) * 30;
ang -= 0.1;
ta.draw(graphics);
tb.draw(graphics);
tc.draw(graphics);
}//onenter
}//classend
}
import flash.display.Graphics;
internal class wTag
{
public var cx:Number = 0;
public var cy:Number = 0;
public var ca:Number = 0;
public var par:wTag = null;
public var wx:Number = 0;
public var wy:Number = 0;
public var wa:Number = 0;
public function wTag(x:Number, y:Number, a:Number)
{
cx = x;
cy = y;
ca = a;
wx= cx;
wy =cy;
wa = a;
}//ctor
public function draw(g:Graphics):void
{
//var p:wTag;
//var kx:Number;
//var ky:Number;
//ok so this is a rather primitive version
//only supports 1 parent max
// (so the transform of the parents parent doesnt taken into account
// also the order of update matters)
if (par != null)
{
wx = ( Math.cos(par.ca) *cx - Math.sin(par.ca) * cy) + par.cx;
wy = ( Math.sin(par.ca)*cx + Math.cos(par.ca) * cy) + par.cy;
wa = ca + par.ca;
}
else
{
wx = cx;
wy = cy;
wa = ca;
}
g.drawCircle(wx,wy, 8);
g.moveTo(wx,wy);
g.lineTo(wx + Math.cos(wa)*8, wy + Math.sin(wa)*8);
}//draw
}//tag