Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.MovieClip;
- import flash.events.Event;
- public class Floater extends MovieClip {
- var soundTik:Sound1 = new Sound1();
- public var positionX:int;
- public var ballSpeedX:int = -8;
- public var ballSpeedY:int = -8;
- public function Floater():void {
- addEventListener(Event.ENTER_FRAME, goMove);
- }
- public function goMove(e:Event):void {
- this.x += ballSpeedX;
- this.y += ballSpeedY;
- if (this.x <= this.width / 2) {
- this.x = this.width / 2;
- ballSpeedX *= -1;
- soundTik.play();
- }
- else if (this.x >= stage.stageWidth - (this.width / 2)) {
- this.x = stage.stageWidth - (this.width / 2);
- ballSpeedX *= -1;
- soundTik.play();
- }
- if (this.y <= this.height / 2) {
- this.y = this.height / 2;
- ballSpeedY *= -1;
- soundTik.play();
- }
- else if (this.y >= stage.stageHeight - (this.width / 2)) {
- this.y = stage.stageHeight - (this.width / 2);
- ballSpeedY *= -1;
- soundTik.play();
- }
- }
- public function setX(positionX):void {
- trace("hello");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement