1 Reply Latest reply: Jul 31, 2012 4:21 AM by Ned Murphy RSS

    pasegame

    milanfiala

      package {

      import flash.display.MovieClip;

      import flash.events.MouseEvent;

      import flash.events.TimerEvent;

      import flash.utils.Timer;

      public class Main extends MovieClip {

      private var pickedTiles:Array = new Array();

      private const NUMBER_OF_TILES:uint=20;

      public function Main() {

       

      ...

       

      private function onTileClicked(e:MouseEvent) {

      var picked:tile_movieclip=e.currentTarget as tile_movieclip;

      trace("you picked a "+e.currentTarget.cardType);

      // checking if the current tile has already been picked

      if (pickedTiles.indexOf(picked)==-1) {

      pickedTiles.push(picked);

      picked.gotoAndStop(picked.cardType+1);

      }

      // end checking if the current tile has already been picked

      // checking if we picked 2 tiles

       

       

      if (pickedTiles.length==2) {

      pauseGame=new Timer(1000,1);

      pauseGame.start();

      if (pickedTiles[0].cardType==pickedTiles[1].cardType) {

      // tiles match!!

      trace("tiles match!!!!");

                pauseGame.addEventListener(TimerEvent.TIMER_COMPLETE,removeTiles);

      pickedTiles[0].removeEventListener(MouseEvent.

      CLICK,onTileClicked);

      pickedTiles[1].removeEventListener(MouseEvent.CLICK,onTileClicked);

      removeChild(pickedTiles[0]);

      removeChild(pickedTiles[1]);

      } else {

      // tiles do not match

      trace("tiles do not match");

                pauseGame.addEventListener(TimerEvent.TIMER_COMPLETE,resetTiles);

      pickedTiles[0].gotoAndStop(NUMBER_OF_TILES/2+1);

      pickedTiles[1].gotoAndStop(NUMBER_OF_TILES/2+1);

      }

      pickedTiles = new Array();

      }

      // end checking if we picked 2 tiles

      }

      private function removeTiles(e:TimerEvent) {

      pauseGame.removeEventListener(TimerEvent.

      TIMER_COMPLETE,removeTiles);

      pickedTiles[0].removeEventListener(MouseEvent.CLICK,onTileClicked);

      pickedTiles[1].removeEventListener(MouseEvent.CLICK,onTileClicked);

      removeChild(pickedTiles[0]);

      removeChild(pickedTiles[1]);

      pickedTiles = new Array();

      }

       

       

      private function resetTiles(e:TimerEvent) {

      pauseGame.removeEventListener(TimerEvent.TIMER_COMPLETE,resetTiles);

      pickedTiles[0].gotoAndStop(NUMBER_OF_TILES/2+1);

      pickedTiles[1].gotoAndStop(NUMBER_OF_TILES/2+1);

      pickedTiles = new Array();

      }

       

      Error ... Acces of undefined property pauseGame ...

       

      Where can be the problem ?

      pauseGame=new Timer(1000,1);

      pauseGame.start(); ... the pauseGame is found here