View Full Version : [AS3] "Window" not holding as it should

11-02-2010, 02:34 PM
I'm creating a memory game that reveals an image. When you make a correct match, those portions of the image is revealed. Then a "window" appears giving the user the option to take a free turn or attempt to guess the image. Now this works just fine the first time around, but the second time around, the "window" with this option holds for a second and then fades out as if the buttons have already been pressed. Any advice on how to correct this?

This is just the partial code that brings up the "window".

Any and all help would be greatly appreciated!

// ::: Take a free turn or guess the phrase :::
// bring in the bonus option window
public function displayOption(event:TimerEvent) {
// display match bonus options window
bonusTurn.visible = true;
bonusTurn.btnGuessPhrase.addEventListener(MouseEve nt.CLICK, guessPhraseTry);
} // END FUNCTION : displayOption

// remove the bonus option window
public function removeOption() {
bonusTurnFade = true;

objInvisibleTimer = new Timer(1000,1);
objInvisibleTimer.addEventListener(TimerEvent.TIME R_COMPLETE,invisibleObj);

// ::: Guess the phrase functions :::
// guess the phrase
public function guessPhraseTry(event:MouseEvent) {
bonusTurn.btnGuessPhrase.removeEventListener(Mouse Event.CLICK, guessPhraseTry);

guessPhraseBox.visible = true;

// Restrict the input of the textbox to upper and lower case letters only
guessPhraseBox.phrase.restrict = "A-Z a-z";
guessPhraseBox.phrase.text = "";
guessPhraseBox.submitPhrase.addEventListener(Mouse Event.CLICK,comparePhrase);
} // END FUNCTION : guessPhraseTry

// compare the phrase attempt to the actual phrase
public function comparePhrase(event:MouseEvent) {
// grab the phrase entered into the text box
var submittedPhrase:String = guessPhraseBox.phrase.text;
// convert the phrase into lower case letters and remove spaces
submittedPhrase = stripSpaces(submittedPhrase.toLowerCase());

// convert the correct phrase into lower case letters and remove spaces
var correctPhrase:String = stripSpaces(imgPhrase.toLowerCase());

if (submittedPhrase == correctPhrase) { // phrase was guessed correctly
gameScore += pointsForGuess;
} else { // phrase was guessed incorrectly
gameScore += pointsForGuessMiss; // deduct points for incorrect guess

phraseMissAlert.visible = true;

alertFadeInTimer = new Timer(1000,1);
alertFadeInTimer.addEventListener(TimerEvent.TIMER _COMPLETE,alertIn);

guessPhraseTimer = new Timer(1500,1);
guessPhraseTimer.addEventListener(TimerEvent.TIMER _COMPLETE,phraseOut);

} // END IF : submittedPhrase == correctPhrase

guessPhraseBox.submitPhrase.removeEventListener(Mo useEvent.CLICK,comparePhrase);

} // END FUNCTION : comparePhrase

public function phraseOut(event:TimerEvent) {

phraseInvisibleTimer = new Timer(1500,1);
phraseInvisibleTimer.addEventListener(TimerEvent.T IMER_COMPLETE,phraseInv);

guessPhraseTimer.removeEventListener(TimerEvent.TI MER_COMPLETE,phraseOut);

public function phraseInv(event:TimerEvent) {
guessPhraseBox.visible = false;
phraseInvisibleTimer.removeEventListener(TimerEven t.TIMER_COMPLETE,phraseInv);

// Delete the spaces
public function stripSpaces(originalString:String):String {
var original:Array = originalString.split(" ");
} // END FUNCTION : stripSpaces

11-03-2010, 07:16 PM
Quick question:

What does bonusTurnFade = true; do and where is it set to false?

The error sounds like your not resetting a value somewhere that is triggering the box to fade the second time

11-05-2010, 10:39 AM
Thanks! I didn't even see that I was missing that. :p I only had it set when it was first set, but didn't realize that I wasn't resetting it.

All fixed now! ;)