forked from: マウスオーバーで四角形回転
forked from マウスオーバーで四角形回転 (diff: 14)
ActionScript3 source code
/**
* Copyright takun336 ( http://wonderfl.net/user/takun336 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/f2V8
*/
// forked from yuugurenote's マウスオーバーで四角形回転
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
[SWF(width=960,height=540, frameRate=60)]
public class AS120618_01 extends Sprite {
public var sw:Number=stage.stageWidth;
public var sh:Number=stage.stageHeight;
public var _myRect:myRect;
public var _mySprite:mySprite;
public var _myArray:Array = new Array();
public var max:Number=200; // 전체갯수
public function AS120618_01() {
for (var i:Number=1; i<max; i++) {
_mySprite = new mySprite();
_mySprite.x=i%10*100 + 50; // X전체위치
_mySprite.y=Math.floor(i/10)*54 - 240; // Y전체위치
addChild(_mySprite);
_myRect= new myRect();
_mySprite.addChild(_myRect);
_myRect.x=-23.25; // X 중심축
_myRect.y=-23.25; // Y 중심축
_mySprite.addChild(_myRect);
_myArray.push(_mySprite);
}
addEventListener(Event.ENTER_FRAME,xEnter);
}
public function xEnter(e:Event):void {
for (var i:Number=0; i<max; i++) {
_myArray[i].myAct();
}
}
}
}
import flash.ui.Mouse;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
class myRect extends Sprite {
public var myInt:Number=0;
public var myFlag:Boolean=false;
public function myRect() {
this.graphics.beginFill(Math.random()*0xFFFFFF,1);
this.graphics.drawRect(0,0,46.5,46.5);
this.graphics.endFill();
}
}
class mySprite extends Sprite {
public var myInt:Number=0;
public var myFlag:Boolean=false;
public function mySprite() {
}
public function myAct():void {
this.addEventListener(MouseEvent.MOUSE_OVER,xOver);
}
public function xOver(e:MouseEvent):void {
myFlag=true;
this.addEventListener(Event.ENTER_FRAME,xEnter2);
}
public function xEnter2(e:Event):void {
if (myFlag) {
myInt+=10
if (myInt>=5) { // 스타트
myFlag=false;
}
}
if ((!myFlag) && (myInt > 0)) {
myInt-=0.01; // 마지막 모습
if (myInt<0.09){
this.rotation =0;
//this.removeEventListener(Event.ENTER_FRAME,xEnter2);
}
}
Mouse.hide();
this.rotation+=myInt;
}
}
