Advertisement
Guest User

Floater.as

a guest
May 24th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package {
  2.    
  3.     import flash.display.MovieClip;
  4.     import flash.events.Event;
  5.    
  6.     public class Floater extends MovieClip {
  7.         var soundTik:Sound1 = new Sound1();
  8.         public var positionX:int;
  9.         public var ballSpeedX:int = -8;
  10.         public var ballSpeedY:int = -8;
  11.        
  12.         public function Floater():void {
  13.             addEventListener(Event.ENTER_FRAME, goMove);
  14.         }
  15.        
  16.         public function goMove(e:Event):void {
  17.             this.x += ballSpeedX;
  18.             this.y += ballSpeedY;
  19.            
  20.             if (this.x <= this.width / 2) {
  21.                 this.x = this.width / 2;
  22.                 ballSpeedX *= -1;
  23.                 soundTik.play();
  24.             }
  25.            
  26.             else if (this.x >= stage.stageWidth - (this.width / 2)) {
  27.                 this.x = stage.stageWidth - (this.width / 2);
  28.                 ballSpeedX *= -1;
  29.                 soundTik.play();
  30.             }
  31.            
  32.             if (this.y <= this.height / 2) {
  33.                 this.y = this.height / 2;
  34.                 ballSpeedY *= -1;
  35.                 soundTik.play();
  36.             }
  37.            
  38.             else if (this.y >= stage.stageHeight - (this.width / 2)) {
  39.                 this.y = stage.stageHeight - (this.width / 2);
  40.                 ballSpeedY *= -1;
  41.                 soundTik.play();
  42.             }
  43.         }
  44.        
  45.         public function setX(positionX):void {
  46.             trace("hello");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement