Skip navigation
Currently Being Moderated

pasegame

Jul 31, 2012 2:39 AM

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

 
Replies
  • Currently Being Moderated
    Jul 31, 2012 4:21 AM   in reply to milanfiala

    You have not declared the pauseGame variable anywhere that I can see, as in...

     

    var pauseGame:Timer;

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points