Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.utils.Timer;
- import flash.display.MovieClip;
- import flash.events.Event;
- import flash.events.MouseEvent;
- var ballen:Array = [];
- var counter:int = 0;
- var listener:int = 0;
- var timer:Timer = new Timer(1000, 1);
- addEventListener(Event.ENTER_FRAME, loop);
- timer.addEventListener(TimerEvent.TIMER, add);
- function add(event:TimerEvent):void
- {
- var Ball:MovieClip = new Symbol1;
- ballen.push(Ball);
- addChild(Ball);
- counter++;
- Ball.x = Math.random() * 300;
- Ball.y = Math.random() * 300;
- }
- function loop(e:Event):void
- {
- if(counter < 5)
- {
- timer.start();
- }
- for(var i:int = 0; i < ballen.length; i++)
- {
- ballen[i].y += 5;
- ballen[i].addEventListener(MouseEvent.CLICK, shoot);
- }
- }
- function shoot(e:MouseEvent):void
- {
- removeChild(ballen[i]);
- ballen.splice(i, 1);
- ballen[i].removeEventListener(MouseEvent.CLICK, shoot);
- }
Add Comment
Please, Sign In to add comment