forked from: flash on 2010-9-9
/**
* Copyright say0 ( http://wonderfl.net/user/say0 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/i8D6
*/
// forked from say0's flash on 2010-9-9
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
[SWF (width=800,height=400)]
public class FlashTest extends Sprite {
private var speed : Number = 0.2;
private var rot : Number = 0;
private var arr : Array = new Array();
private var tf:TextField = new TextField();
public function FlashTest(){
stage.addChild(tf);
for(var i:int = 0;i<5;i++){
var sp:Sprite = new CircleGrp(50+50*i);
arr[i] = sp;
arr[i].rot = rot;
stage.addChild(sp);
}
stage.addEventListener(MouseEvent.CLICK,clickHdl);
stage.addEventListener(Event.ENTER_FRAME,frameHdl);
}
private function clickHdl(e:Event):void{
rot += 90;
tf.text = String(rot);
}
private function frameHdl(e:Event):void{
for (var i:int = 0;i<5;i++){
if(!i){
arr[i].rot = speed*(rot - arr[i].rot) + arr[i].rot;
}else{
arr[i].rot = speed*(arr[i-1].rot - arr[i].rot) + arr[i].rot;
}
arr[i].rotation = arr[i].rot;
arr[i].x = mouseX;
arr[i].y = mouseY;
}
}
}
}
import flash.display.Sprite;
class CircleGrp extends Sprite {
public var rot:Number = new Number();
public function CircleGrp(_width:uint):void{
var w:int = _width;
var r:int = 10;
this.graphics.lineStyle(1,0x000000,1);
this.graphics.beginFill(0);
this.graphics.drawCircle(0,w,r);
this.graphics.drawCircle(0,-w,r);
this.graphics.drawCircle(w,0,r);
this.graphics.drawCircle(-w,0,r);
this.graphics.endFill();
}
}