Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 17th, 2012  |  syntax: ActionScript 3  |  size: 1.70 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package
  2. {
  3.         import flash.display.MovieClip;
  4.         import flash.display.Sprite;
  5.         import flash.events.MouseEvent;
  6.         import flash.events.TimerEvent;
  7.         import flash.ui.Mouse;
  8.         import flash.utils.Timer;
  9.        
  10.         public class Eindopdracht extends Sprite
  11.         {
  12.                 var cursorAim:MovieClip;
  13.                 var totalIndians:uint;
  14.                 var makeIndians:Timer;
  15.                 var container:MovieClip;
  16.                
  17.                 public function Eindopdracht()
  18.                 {
  19.                         trace("startgame")
  20.                         initGame();
  21.                         changeMouse();
  22.                 }
  23.                
  24.                
  25.                 public function initGame()
  26.                 {
  27.                         totalIndians = 10;
  28.                         makeIndians = new Timer(2000, totalIndians);
  29.                         container = new MovieClip();
  30.                         addChild(container);
  31.                         makeIndians.addEventListener(TimerEvent.TIMER, createIndians);
  32.                         makeIndians.start();
  33.                 }
  34.                
  35.                 public function changeMouse() {
  36.                         cursorAim = new CursorAim();
  37.                         this.addChild(cursorAim);
  38.                         //
  39.                         cursorAim.enabled = false;
  40.                         stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorAimMoveEvent);
  41.                         stage.addEventListener(MouseEvent.CLICK, removeIndian);
  42.                         Mouse.hide();
  43.                         cursorAim.mouseEnabled = false;
  44.                         cursorAim.mouseChildren = false;
  45.                 }
  46.                 public function cursorAimMoveEvent(evt:MouseEvent) {
  47.                         cursorAim.x = this.mouseX;
  48.                         cursorAim.y = this.mouseY;
  49.                 }
  50.                
  51.                 public function createIndians(evt:TimerEvent) {
  52.                         var indian:MovieClip;
  53.                         indian = new Indian();
  54.                         indian.x = randomGenerator(1,1000);
  55.                         indian.y = randomGenerator(1,500);
  56.                         indian.buttonMode = true;
  57.                        
  58.                        
  59.                         container.addChild(indian);
  60.                 }
  61.                
  62.                 public function randomGenerator(low:Number = 0, high:Number = 1):Number{
  63.                         return Math.floor(Math.random() * (1+high-low)) + low;
  64.                 }
  65.                
  66.                 public function removeIndian(evt:MouseEvent) {
  67.                         trace("click");
  68.                         trace(evt.target);
  69.                 }
  70.         }
  71. }