the rotating rectangle
スマステで錯視やってたので。
/**
* Copyright o8que ( http://wonderfl.net/user/o8que )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qdjL
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(width="465",height="465",frameRate="60",backgroundColor="0xFFFFFF")]
public class Main extends Sprite {
public function Main() {
var rect:Sprite = new Sprite();
rect.graphics.beginFill(0xFF0000);
rect.graphics.drawRect( -80, -80, 160, 160);
rect.graphics.endFill();
rect.x = 232, rect.y = 232;
addChild(rect);
addEventListener(Event.ENTER_FRAME,
function(event:Event):void { rect.rotation += 2; }
);
var circleContainer:Sprite = new Sprite();
var circleX:Array = [162, 302, 162, 302];
var circleY:Array = [162, 162, 302, 302];
for (var i:int = 0; i < 4; i++) {
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0x000000);
circle.graphics.drawCircle(0, 0, 60);
circle.graphics.endFill();
circle.x = circleX[i], circle.y = circleY[i];
circle.buttonMode = true;
circleContainer.addChild(circle);
}
addChild(circleContainer);
circleContainer.addEventListener(MouseEvent.MOUSE_DOWN,
function(event:MouseEvent):void { event.target.startDrag(); }
);
circleContainer.addEventListener(MouseEvent.MOUSE_UP,
function(event:MouseEvent):void { event.target.stopDrag(); }
);
}
}
}