t810042
♥0 |
Line 53 |
Modified 2011-06-23 12:16:00 |
MIT License
archived:2017-03-30 01:26:28
ActionScript3 source code
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/euuM
*/
////////////////////////////////////////////////////////////////////////////////
// t810042
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]
public class Main extends Sprite {
private var _mc:Sprite;
private var _btn:Sprite;
public function Main() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
init();
}
private function init():void {
_mc = new Sprite();
addChild(_mc);
_mc.graphics.beginFill(0xFF0000);
_mc.graphics.drawRect(-20, -20, 40, 40);
_mc.graphics.endFill();
_mc.x = 132;
_mc.y = 212;
//
_btn = new Sprite();
addChild(_btn);
_btn.buttonMode = true;
_btn.graphics.beginFill(0x000000);
_btn.graphics.drawRect(-10, -10, 20, 20);
_btn.graphics.endFill();
_btn.x = 232;
_btn.y = 432;
//
_btn.addEventListener(MouseEvent.CLICK, click1, false, 0, true);
}
private function click1(e:MouseEvent):void {
_btn.removeEventListener(MouseEvent.CLICK, click1);
_btn.addEventListener(MouseEvent.CLICK, click2, false, 0, true);
_mc.addEventListener(Event.ENTER_FRAME, motion, false, 0, true);
}
private function click2(e:MouseEvent):void {
_btn.removeEventListener(MouseEvent.CLICK, click2);
_btn.addEventListener(MouseEvent.CLICK, click1, false, 0, true);
_mc.removeEventListener(Event.ENTER_FRAME, motion);
_mc.x = 132;
}
private function motion(evt:Event):void {
if (_mc.x < 332) {
_mc.x += 5;
} else {
_mc.removeEventListener(Event.ENTER_FRAME, motion);
}
}
}
}