Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-02-2010, 02:34 PM   #1
Registered User
Join Date: Aug 2004
Posts: 5
Red face [AS3] "Window" not holding as it should

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!

ActionScript Code:
// ::: 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;             fadeInTween(bonusTurn);             bonusTurn.btnGuessPhrase.addEventListener(MouseEvent.CLICK, guessPhraseTry);         } // END FUNCTION : displayOption                 // remove the bonus option window         public function removeOption() {             fadeOutTween(bonusTurn);             bonusTurnFade = true;                         objInvisibleTimer = new Timer(1000,1);             objInvisibleTimer.addEventListener(TimerEvent.TIMER_COMPLETE,invisibleObj);             objInvisibleTimer.start();         }                         // ::: Guess the phrase functions :::         // guess the phrase         public function guessPhraseTry(event:MouseEvent) {             bonusTurn.btnGuessPhrase.removeEventListener(MouseEvent.CLICK, guessPhraseTry);             removeOption();                         guessPhraseBox.visible = true;             fadeInTween(guessPhraseBox);                         // 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(MouseEvent.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;                 showGameScore();             } 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);                 alertFadeInTimer.start();                                 guessPhraseTimer = new Timer(1500,1);                 guessPhraseTimer.addEventListener(TimerEvent.TIMER_COMPLETE,phraseOut);                 guessPhraseTimer.start();                                                 showGameScore();             } // END IF : submittedPhrase == correctPhrase                         guessPhraseBox.submitPhrase.removeEventListener(MouseEvent.CLICK,comparePhrase);                     } // END FUNCTION : comparePhrase                 public function phraseOut(event:TimerEvent) {             fadeOutTween(guessPhraseBox);                             phraseInvisibleTimer = new Timer(1500,1);             phraseInvisibleTimer.addEventListener(TimerEvent.TIMER_COMPLETE,phraseInv);             phraseInvisibleTimer.start();                         guessPhraseTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,phraseOut);         }                 public function phraseInv(event:TimerEvent) {             guessPhraseBox.visible = false;             phraseInvisibleTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,phraseInv);         }                 // Delete the spaces         public function stripSpaces(originalString:String):String {             var original:Array = originalString.split(" ");             return(original.join(""));         } // END FUNCTION : stripSpaces
CrystalEyes82 is offline   Reply With Quote
Old 11-03-2010, 07:16 PM   #2
Senior Member
Join Date: Aug 2008
Posts: 134

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
EightySeven is offline   Reply With Quote
Old 11-05-2010, 10:39 AM   #3
Registered User
Join Date: Aug 2004
Posts: 5

Thanks! I didn't even see that I was missing that. I only had it set when it was first set, but didn't realize that I wasn't resetting it.

All fixed now!
CrystalEyes82 is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 03:19 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.