epicycloid
/**
* Copyright codeonwort ( http://wonderfl.net/user/codeonwort )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zbxx
*/
package {
import flash.geom.Point;
import flash.events.Event
import flash.display.Shape
import flash.display.Sprite
public class FlashTest extends Sprite {
private const r0:Number = 100
private const r:Number = 50
private var C:Sprite
private var t:Number = 0
private var P:Shape
private var path:Shape
public function FlashTest() {
// write as3 code here..
var C0:Sprite = new Sprite
C0.graphics.beginFill(0x00ff00, .3)
C0.graphics.drawCircle(0, 0, r0)
C0.x = 465/2, C0.y = 465/2
addChild(C0)
C0.addChild(C = new Sprite)
C.graphics.beginFill(0x0000ff, .5)
C.graphics.drawCircle(0, 0, r)
P = new Shape
P.graphics.beginFill(0xff0000)
P.graphics.drawCircle(0, 0, 5)
P.x = -r
C.addChild(P)
addChild(path = new Shape)
path.graphics.lineStyle(1, 0x0)
var pt:Point = P.localToGlobal(new Point)
path.graphics.moveTo(C0.x + r0, C0.y)
addEventListener("enterFrame", loop)
}
private function loop($:Event):void {
var dt:Number = .01
t += dt
C.x = (r0 + r) * Math.cos(t)
C.y = (r0 + r) * Math.sin(t)
C.rotation += (dt*2*Math.PI) * 180/Math.PI
var pt:Point = P.localToGlobal(new Point)
path.graphics.lineTo(pt.x, pt.y)
}
}
}