flash on 2010-4-17
♥0 |
Line 49 |
Modified 2010-04-17 23:28:21 |
MIT License
archived:2017-03-30 02:21:54
ActionScript3 source code
/**
* Copyright kihon ( http://wonderfl.net/user/kihon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jn6t
*/
package
{
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main()
{
var p:Joint = new Joint();
p.x = p.y = 100;
addChild(p);
var joint:Joint;
for (var i:int = 0; i < 5; i++)
{
if (i == 4) joint = new Joint(false);
else joint = new Joint();
p.addChild(joint);
p = joint;
}
}
}
}
import flash.display.Sprite;
import flash.events.MouseEvent;
class Joint extends Sprite
{
public var lineSize:int = 50;
public var radius:int = 5;
public var rotate:Number = 36;
public function Joint(line:Boolean = true)
{
this.x = lineSize;
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0x0);
circle.graphics.drawCircle(0, 0, radius);
circle.graphics.endFill();
addChild(circle);
circle.addEventListener(MouseEvent.CLICK, onMouseClick);
if (line)
{
graphics.lineStyle(2.0, 0x0);
graphics.lineTo(lineSize, 0);
}
}
private function onMouseClick(event:MouseEvent):void
{
var p:Joint = event.currentTarget.parent as Joint;
p.rotation += rotate;
}
}