FlashTest
♥0 |
Line 23 |
Modified 2012-04-10 02:00:19 |
MIT License
archived:2017-03-20 01:24:22
ActionScript3 source code
/**
* Copyright MMMMMonchi ( http://wonderfl.net/user/MMMMMonchi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tt5P
*/
package {
import flash.display.Sprite;
import flash.events.Event;
public class FlashTest extends Sprite {
private var ball:Sprite;
private var vx:int = 15;
private var vy:int = 21;
public function FlashTest() {
ball = new Sprite();
ball.graphics.beginFill(0x00ff00);
ball.graphics.drawCircle(100,100,100);
ball.graphics.endFill();
addChild(ball);
ball.addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
//エンターフレイムイベントによって呼ばれるメソッド
private function onEnterFrame(e:Event ):void {
ball.x += vx;
ball.y += vy;
if(ball.x<0||ball.x>stage.width){vx=-vx}
if(ball.y<0||ball.y>stage.height){vy=-vy}
}
}
}