• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

pasegame

New Here ,
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

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

TOPICS
ActionScript

Views

477

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 31, 2012 Jul 31, 2012

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

var pauseGame:Timer;

Votes

Translate

Translate
LEGEND ,
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

LATEST

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

var pauseGame:Timer;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines