Section 1
//MainTimeline (CardGame_fla.MainTimeline)
package CardGame_fla {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.net.*;
public dynamic class MainTimeline extends MovieClip {
public var addButton:SimpleButton;
public var playAgainB:SimpleButton;
public var showTime:TextField;
public var bDev:SimpleButton;
public var addGame:SimpleButton;
public var showScore:TextField;
public var loadBar:MovieClip;
public var playButton:SimpleButton;
public var denied:TextField;
public var spillScore:int;
public var gameTime:String;
public var moreGame:SimpleButton;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
addButton.addEventListener(MouseEvent.CLICK, addClick);
}
public function addClick(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.koalafun.com/");
navigateToURL(_local2);
}
function frame1(){
stop();
addEventListener(Event.ENTER_FRAME, loadProgress);
}
function frame4(){
showScore.text = ("Score: " + String(spillScore));
showTime.text = ("Time: " + gameTime);
playAgainB.addEventListener(MouseEvent.CLICK, playAgain);
stop();
}
public function startGame(_arg1:MouseEvent){
gotoAndStop("playgame");
}
public function loadProgress(_arg1:Event){
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
_local2 = this.root.loaderInfo.bytesLoaded;
_local3 = this.root.loaderInfo.bytesTotal;
_local4 = (_local2 / 0x0400);
_local5 = (_local3 / 0x0400);
denied.text = (((("Loading: " + _local4) + "K/") + _local5) + "K");
loadBar.scaleX = (_local4 / _local5);
if (_local2 >= _local3){
removeEventListener(Event.ENTER_FRAME, loadProgress);
gotoAndStop(2);
};
}
public function visitWebmaster(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.koalafun.com/free-website-games.htm");
navigateToURL(_local2);
}
public function playAgain(_arg1:MouseEvent){
gotoAndStop("playgame");
}
public function moreClick(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.koalafun.com/");
navigateToURL(_local2);
}
public function visitStian(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://rodrevmcfox.deviantart.com/");
navigateToURL(_local2);
}
function frame2(){
stop();
playButton.addEventListener(MouseEvent.CLICK, startGame);
stop();
moreGame.addEventListener(MouseEvent.CLICK, moreClick);
bDev.addEventListener(MouseEvent.CLICK, visitStian);
addGame.addEventListener(MouseEvent.CLICK, visitWebmaster);
}
}
}//package CardGame_fla
Section 2
//Card (Card)
package {
import flash.events.*;
import flash.display.*;
public dynamic class Card extends MovieClip {
private var flipToFrame:uint;
private var isFlipping:Boolean;// = false
private var flipStep:uint;
public function Card(){
isFlipping = false;
super();
}
public function flip(_arg1:Event){
flipStep--;
if (flipStep > 5){
this.scaleX = (0.2 * (flipStep - 6));
} else {
this.scaleX = (0.2 * (5 - flipStep));
};
if (flipStep == 5){
gotoAndStop(flipToFrame);
};
if (flipStep == 0){
this.removeEventListener(Event.ENTER_FRAME, flip);
};
}
public function startFlip(_arg1:uint){
isFlipping = true;
flipStep = 10;
flipToFrame = _arg1;
this.addEventListener(Event.ENTER_FRAME, flip);
}
}
}//package
Section 3
//FirstCardSound (FirstCardSound)
package {
import flash.media.*;
public dynamic class FirstCardSound extends Sound {
}
}//package
Section 4
//fremdrift1 (fremdrift1)
package {
import flash.display.*;
public dynamic class fremdrift1 extends MovieClip {
}
}//package
Section 5
//MatchSound (MatchSound)
package {
import flash.media.*;
public dynamic class MatchSound extends Sound {
}
}//package
Section 6
//MissSound (MissSound)
package {
import flash.media.*;
public dynamic class MissSound extends Sound {
}
}//package
Section 7
//playCardGame (playCardGame)
package {
import flash.display.*;
public dynamic class playCardGame extends SimpleButton {
}
}//package
Section 8
//Symbol1 (Symbol1)
package {
import flash.events.*;
import flash.media.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
public class Symbol1 extends MovieClip {
private var cardLeft:uint;
var firstSound:FirstCardSound;
private var gameTimeField:TextField;
private var scoreFelt:TextField;
var matchSound:MatchSound;
private var gameStartTime:uint;
var missSound:MissSound;
private var flipBackTimer:Timer;
private var secondCard:Card;
private var spillScore:int;
private var firstCard:Card;
private var gameTime:uint;
private static const boardWidth:uint = 6;
private static const cardMellomromH:Number = 75;
private static const poengG:int = -5;
private static const cardMellomromV:Number = 75;
private static const boardHeight:uint = 6;
private static const boardOffsetY:Number = 70;
private static const poengR:int = 100;
private static const boardOffsetX:Number = 145;
public function Symbol1():void{
var _local1:Array;
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:Card;
var _local6:uint;
firstSound = new FirstCardSound();
missSound = new MissSound();
matchSound = new MatchSound();
super();
_local1 = new Array();
_local2 = 0;
while (_local2 < ((boardWidth * boardHeight) / 2)) {
_local1.push(_local2);
_local1.push(_local2);
_local2++;
};
cardLeft = 0;
_local3 = 0;
while (_local3 < boardWidth) {
_local4 = 0;
while (_local4 < boardHeight) {
_local5 = new Card();
_local5.stop();
_local5.buttonMode = true;
_local5.x = ((_local3 * cardMellomromH) + boardOffsetX);
_local5.y = ((_local4 * cardMellomromV) + boardOffsetY);
_local6 = Math.floor((Math.random() * _local1.length));
_local5.cardface = _local1[_local6];
_local1.splice(_local6, 1);
_local5.addEventListener(MouseEvent.CLICK, clickCard);
addChild(_local5);
cardLeft++;
_local4++;
};
_local3++;
};
scoreFelt = new TextField();
scoreFelt.x = 5;
addChild(scoreFelt);
spillScore = 0;
visSpillScore();
gameTimeField = new TextField();
gameTimeField.x = 580;
addChild(gameTimeField);
gameStartTime = getTimer();
gameTime = 0;
addEventListener(Event.ENTER_FRAME, showTime);
}
public function visSpillScore(){
scoreFelt.text = ("Score: " + String(spillScore));
}
public function returnCards(_arg1:TimerEvent){
firstCard.startFlip(1);
secondCard.startFlip(1);
firstCard = null;
secondCard = null;
flipBackTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, returnCards);
}
public function playSound(_arg1:Object){
var _local2:SoundChannel;
_local2 = _arg1.play();
}
public function showTime(_arg1:Event){
gameTime = (getTimer() - gameStartTime);
gameTimeField.text = ("Time: " + clockTime(gameTime));
}
public function clockTime(_arg1:int){
var _local2:int;
var _local3:int;
var _local4:String;
_local2 = Math.floor((_arg1 / 1000));
_local3 = Math.floor((_local2 / 60));
_local2 = (_local2 - (_local3 * 60));
_local4 = ((_local3 + ":") + String((_local2 + 100)).substr(1, 2));
return (_local4);
}
public function clickCard(_arg1:MouseEvent){
var _local2:Card;
_local2 = (_arg1.target as Card);
if (firstCard == null){
firstCard = _local2;
firstCard.startFlip((_local2.cardface + 2));
playSound(firstSound);
} else {
if (firstCard == _local2){
firstCard.startFlip(1);
firstCard = null;
} else {
if (secondCard == null){
secondCard = _local2;
secondCard.startFlip((_local2.cardface + 2));
if (firstCard.cardface == secondCard.cardface){
removeChild(firstCard);
removeChild(secondCard);
firstCard = null;
secondCard = null;
spillScore = (spillScore + poengR);
visSpillScore();
MovieClip(root).spillScore = spillScore;
MovieClip(root).gameTime = clockTime(gameTime);
playSound(matchSound);
cardLeft = (cardLeft - 2);
if (cardLeft == 0){
MovieClip(root).gotoAndStop("gameover");
};
} else {
spillScore = (spillScore + poengG);
visSpillScore();
playSound(missSound);
flipBackTimer = new Timer(2000, 1);
flipBackTimer.addEventListener(TimerEvent.TIMER_COMPLETE, returnCards);
flipBackTimer.start();
};
} else {
returnCards(null);
playSound(firstSound);
firstCard = _local2;
firstCard.startFlip((_local2.cardface + 2));
};
};
};
}
}
}//package