Guest User

Untitled

a guest
Jul 22nd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.utils.Timer;
  2. import flash.display.MovieClip;
  3. import flash.events.Event;
  4. import flash.events.MouseEvent;
  5.  
  6.  
  7. var ballen:Array = [];
  8. var counter:int  = 0;
  9. var listener:int = 0;
  10. var timer:Timer = new Timer(1000, 1);
  11. addEventListener(Event.ENTER_FRAME, loop);
  12. timer.addEventListener(TimerEvent.TIMER, add);
  13. function add(event:TimerEvent):void
  14. {
  15.     var Ball:MovieClip = new Symbol1;
  16.     ballen.push(Ball);
  17.     addChild(Ball);
  18.  
  19.     counter++;
  20.     Ball.x = Math.random() * 300;
  21.     Ball.y = Math.random() * 300;
  22.  
  23. }
  24.  
  25. function loop(e:Event):void
  26. {
  27.     if(counter < 5)
  28.     {
  29.         timer.start();
  30.     }
  31.    
  32.     for(var i:int = 0; i < ballen.length; i++)
  33.     {
  34.         ballen[i].y += 5;
  35.         ballen[i].addEventListener(MouseEvent.CLICK, shoot);
  36.     }
  37. }
  38.  
  39. function shoot(e:MouseEvent):void
  40. {
  41.     removeChild(ballen[i]);
  42.     ballen.splice(i, 1);
  43.     ballen[i].removeEventListener(MouseEvent.CLICK, shoot);
  44.    
  45. }
Add Comment
Please, Sign In to add comment