Game Development Reference
In-Depth Information
Memory.fla and the two class files are Memory.as and MemoryCard.
as. If you open the FLA file, you will see 12 instances of the Memory-
Card class arranged on the stage. We
'
ll look at this file first.
The MemoryCard Class
Each MemoryCard object is a MovieClip derivative that contains
theface-downstateonthefirstframeandalltheotherfaceson
subsequent frames. Every card needs to know what its value is so
that it can display the correct frame, and so that the game can
compare any two cards to determine a match. The card numbers
start at one and go up, in this case to six.
package {
import flash.display.MovieClip;
public class MemoryCard extends MovieClip {
protected var _cardNumber:int;
public function MemoryCard() {
stop();
}
public function get cardNumber():int {
return _cardNumber;
}
public function set cardNumber(value:int):void {
_cardNumber = value;
}
public function show():void {
gotoAndStop(_cardNumber + 1);
}
public function hide():void {
gotoAndStop(1);
}
}
}
Once a card has an assigned cardNumber ,the show and hide
methods are the two main functions in play. The hide method
returns the card to its first frame, and the show method jumps to
itsrespectivecardNumberplusone.Therestofthefunctionality
for this game is in the Memory class.
Search Nedrilad ::




Custom Search