Hey everyone!
I’m making a memory game and it’s all been going well until I wanted to fix a problem of mismatch card flip. I got some help from lyndas Essentials where they do a memory game but i got stuck with an issue that they don’t solve there. When you get a mismatch in the game the last clicked card starts as if flipped and flips on its front. It might be confusing to understand so here’s a link to the app with the problem… http://blulinedesign.com/memory/
I tried to fix the problem by putting a timer in the checkCards function and close the cards when after a second but i keep getting an error …
ReferenceError: Error #1069: Property gotoAndPlay not found on flash.display.Stage and there is no default value.
at MethodInfo-18()
at MethodInfo-17()
at MethodInfo-16()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()
The part of the code that matters:
private function checkCards(event:MouseEvent):void {
event.currentTarget.removeEventListener(MouseEvent.CLICK, checkCards);
if (_firstCard == undefined) {
_firstCard = event.currentTarget;
} else if (String(_firstCard._type) == String(event.currentTarget._type)) {
trace("match!");
_firstCard = undefined;
_currentMatches ++;
if (_currentMatches >= _totalMatches) {
trace("YOU WIN!!!!!!");
}
} else {
trace("wrong!");
event.currentTarget.gotoAndPlay(1);
var T:Timer = new Timer(1000,1);
T.addEventListener(TimerEvent.TIMER, onTime);
T.start();
function onTime(evt:TimerEvent):void {
count++;
onCount();
}
trace(T.currentCount);
function onCount():void {
if (count == 1) {
onFlip();
}
}
function onFlip():void {
event.currentTarget.gotoAndPlay("flipBack");
_firstCard.gotoAndPlay("flipBack");
}
_firstCard.addEventListener(MouseEvent.CLICK, checkCards);
event.currentTarget.addEventListener(MouseEvent.CLICK, checkCards);
_firstCard = undefined;
}
}
I tried a lot of stuff so the code is not optimized i know, but nothing worked for me.
Thank you very much for any answers or for pointing me in the direction that will solve my problem, realy appreciate it.