Round
マウスイベントに非常に手間取りました^^;
/**
* Copyright syunki ( http://wonderfl.net/user/syunki )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jlFc
*/
// マウスイベントに非常に手間取りました^^;
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
[SWF(width = 465, height = 465, frameRate="30", backgroundColor=0xFFFFFF)]
public class Round extends Sprite
{
public const WIDTH:Number = 465;
public const HEIGH:Number = 465;
public const DISTA:Number = 125;
private var _round:Array;
private var siz:Array;
private var container:Sprite;
private var title:TextField;
public function Round():void
{
init();
}
private function init():void
{
container = new Sprite();
addChild(container);
_round = [];
siz = [];
title = new TextField();
title.text = "round";
container.addChild( title );
for (var i:int = 0; i < 10; i++) {
var round:Sprite = new Sprite();
siz[i] = 10;
_round[i] = round;
_round[i].name = i;
Draw(i);
container.addChild(_round[i]);
this._round[i].addEventListener(MouseEvent.MOUSE_OVER, mouseoverHandler);
this._round[i].addEventListener(MouseEvent.MOUSE_OUT, mouseoutHandler);
}
this.stage.addEventListener(Event.ENTER_FRAME, eventframeHandler);
}
private function eventframeHandler(e:Event):void {
for (var i:int = 0; i < 10; i++) {
Draw(i);
}
}
private function Draw(i:int):void {
_round[i].graphics.clear();
_round[i].graphics.beginFill(0xFFFFAA);
_round[i].graphics.lineStyle(2, 0x000000);
_round[i].graphics.drawCircle(WIDTH / 2 + DISTA * Math.cos(i * Math.PI / 5), HEIGH / 2 + DISTA * Math.sin(i * Math.PI / 5), DISTA * Math.PI / siz[i] - 1);
_round[i].graphics.endFill();
}
private function mouseoverHandler(e:MouseEvent):void {
// var target:DisplayObject = container.getChildByName(e.currentTarget.name);
// title.text = String(container.getChildIndex(target));
if (e.currentTarget.name != 9) container.swapChildrenAt(int(e.currentTarget.name) + 1, 10);
siz[e.currentTarget.name] = 5;
}
private function mouseoutHandler(e:MouseEvent):void {
siz[e.currentTarget.name] = 10;
if (e.currentTarget.name != 9) container.swapChildrenAt(10, int(e.currentTarget.name) + 1);
}
}
}