Section 1
//EasyLevelGame (christmasmemory.gameplay.EasyLevelGame)
package christmasmemory.gameplay {
public class EasyLevelGame implements ILevelGame {
private var fLevel:int;
private static const MOVETYPE:Array = new Array(15, 14, 19, 4, 5, 7, 8, 16, 19, 6, 9, 20, 16, 19, 6, 15, 14, 19, 6, 9, 16, 19, 6, 9, 19);
private static const LIFE:Array = new Array(120, 120, 120, 120, 120, 120, 120, 90, 90, 90, 90, 120, 120, 120, 120, 90, 90, 90, 120, 120, 120, 120, 120, 120, 120);
private static const MOVECOUNT:Array = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4);
private static const MOVETIME:Array = new Array(30, 30, 20, 30, 30, 30, 30, 15, 15, 15, 20, 10, 30, 30, 30, 15, 15, 15, 10, 20, 20, 20, 20, 20, 10);
private static const LEVELS:int = 25;
public function EasyLevelGame(aLevel:int=1){
super();
fLevel = aLevel;
}
public function get level():int{
return (fLevel);
}
public function get moveTime():int{
return (MOVETIME[(fLevel - 1)]);
}
public function nextLevel():void{
fLevel++;
}
public function get smileySize():int{
return (75);
}
public function get moveCount():int{
return (MOVECOUNT[(fLevel - 1)]);
}
public function get id():int{
return (0);
}
public function get totalLife():int{
var total:int;
var i:int;
while (i < LEVELS) {
total = (total + LIFE[i]);
i++;
};
return (total);
}
public function get columns():int{
return (4);
}
public function get rows():int{
return (4);
}
public function get levelCount():int{
return (LEVELS);
}
public function get moveType():int{
return (MOVETYPE[(fLevel - 1)]);
}
public function get showingTime():int{
return (3);
}
public function get life():int{
return (LIFE[(fLevel - 1)]);
}
public function get secondsPerTry():int{
return (5);
}
}
}//package christmasmemory.gameplay
Section 2
//HardLevelGame (christmasmemory.gameplay.HardLevelGame)
package christmasmemory.gameplay {
public class HardLevelGame implements ILevelGame {
private var fLevel:int;
private static const MOVETYPE:Array = new Array(15, 14, 19, 4, 5, 7, 8, 16, 19, 6, 9, 20, 16, 19, 6, 15, 14, 19, 6, 9, 16, 19, 6, 9, 19);
private static const LIFE:Array = new Array(330, 330, 300, 300, 300, 300, 300, 240, 240, 240, 300, 300, 300, 300, 300, 240, 240, 240, 300, 300, 300, 300, 300, 300, 300);
private static const MOVECOUNT:Array = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4);
private static const MOVETIME:Array = new Array(90, 60, 45, 60, 60, 60, 60, 45, 45, 45, 45, 45, 60, 60, 60, 45, 45, 45, 45, 45, 60, 60, 60, 60, 40);
private static const LEVELS:int = 25;
public function HardLevelGame(aLevel:int=1){
super();
fLevel = aLevel;
}
public function get level():int{
return (fLevel);
}
public function get moveTime():int{
return (MOVETIME[(fLevel - 1)]);
}
public function nextLevel():void{
fLevel++;
}
public function get smileySize():int{
return (50);
}
public function get moveCount():int{
return (MOVECOUNT[(fLevel - 1)]);
}
public function get id():int{
return (2);
}
public function get totalLife():int{
var total:int;
var i:int;
while (i < LEVELS) {
total = (total + LIFE[i]);
i++;
};
return (total);
}
public function get columns():int{
return (6);
}
public function get rows():int{
return (6);
}
public function get levelCount():int{
return (LEVELS);
}
public function get moveType():int{
return (MOVETYPE[(fLevel - 1)]);
}
public function get showingTime():int{
return (5);
}
public function get life():int{
return (LIFE[(fLevel - 1)]);
}
public function get secondsPerTry():int{
return (4);
}
}
}//package christmasmemory.gameplay
Section 3
//ILevelGame (christmasmemory.gameplay.ILevelGame)
package christmasmemory.gameplay {
public interface ILevelGame {
function get totalLife():int;
function get level():int;
function get moveCount():int;
function get rows():int;
function get levelCount():int;
function get columns():int;
function nextLevel():void;
function get showingTime():int;
function get smileySize():int;
function get moveType():int;
function get id():int;
function get life():int;
function get secondsPerTry():int;
function get moveTime():int;
}
}//package christmasmemory.gameplay
Section 4
//NormalLevelGame (christmasmemory.gameplay.NormalLevelGame)
package christmasmemory.gameplay {
public class NormalLevelGame implements ILevelGame {
private var fLevel:int;
private static const MOVETYPE:Array = new Array(20, 14, 19, 4, 5, 7, 8, 16, 19, 6, 9, 20, 16, 19, 6, 15, 14, 19, 6, 9, 16, 19, 6, 9, 19);
private static const LIFE:Array = new Array(180, 180, 180, 180, 180, 180, 180, 150, 150, 150, 150, 180, 180, 180, 180, 150, 150, 150, 180, 180, 180, 180, 180, 180, 180);
private static const MOVECOUNT:Array = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4);
private static const MOVETIME:Array = new Array(45, 45, 30, 45, 45, 45, 45, 20, 20, 20, 30, 15, 45, 45, 45, 20, 20, 20, 15, 30, 30, 30, 30, 30, 15);
private static const LEVELS:int = 25;
public function NormalLevelGame(aLevel:int=1){
super();
fLevel = aLevel;
}
public function get level():int{
return (fLevel);
}
public function get moveTime():int{
return (MOVETIME[(fLevel - 1)]);
}
public function nextLevel():void{
fLevel++;
}
public function get smileySize():int{
return (75);
}
public function get moveCount():int{
return (MOVECOUNT[(fLevel - 1)]);
}
public function get id():int{
return (1);
}
public function get totalLife():int{
var total:int;
var i:int;
while (i < LEVELS) {
total = (total + LIFE[i]);
i++;
};
return (total);
}
public function get columns():int{
return (6);
}
public function get rows():int{
return (4);
}
public function get levelCount():int{
return (LEVELS);
}
public function get moveType():int{
return (MOVETYPE[(fLevel - 1)]);
}
public function get showingTime():int{
return (4);
}
public function get life():int{
return (LIFE[(fLevel - 1)]);
}
public function get secondsPerTry():int{
return (5);
}
}
}//package christmasmemory.gameplay
Section 5
//VeryHardLevelGame (christmasmemory.gameplay.VeryHardLevelGame)
package christmasmemory.gameplay {
public class VeryHardLevelGame implements ILevelGame {
private var fLevel:int;
private static const MOVETYPE:Array = new Array(15, 14, 19, 4, 5, 7, 8, 16, 19, 6, 9, 20, 16, 19, 6, 15, 14, 19, 6, 9, 16, 19, 6, 9, 19);
private static const LIFE:Array = new Array(450, 450, 420, 420, 420, 420, 420, 360, 360, 360, 420, 420, 420, 420, 420, 360, 360, 360, 420, 420, 420, 420, 420, 420, 420);
private static const MOVECOUNT:Array = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 2, 4);
private static const MOVETIME:Array = new Array(120, 90, 60, 90, 90, 90, 90, 45, 45, 45, 60, 45, 90, 90, 90, 45, 45, 45, 45, 45, 60, 60, 60, 60, 45);
private static const LEVELS:int = 25;
public function VeryHardLevelGame(aLevel:int=1){
super();
fLevel = aLevel;
}
public function get level():int{
return (fLevel);
}
public function get moveTime():int{
return (MOVETIME[(fLevel - 1)]);
}
public function nextLevel():void{
fLevel++;
}
public function get smileySize():int{
return (50);
}
public function get moveCount():int{
return (MOVECOUNT[(fLevel - 1)]);
}
public function get id():int{
return (3);
}
public function get totalLife():int{
var total:int;
var i:int;
while (i < LEVELS) {
total = (total + LIFE[i]);
i++;
};
return (total);
}
public function get columns():int{
return (8);
}
public function get rows():int{
return (6);
}
public function get levelCount():int{
return (LEVELS);
}
public function get moveType():int{
return (MOVETYPE[(fLevel - 1)]);
}
public function get showingTime():int{
return (5);
}
public function get life():int{
return (LIFE[(fLevel - 1)]);
}
public function get secondsPerTry():int{
return (3);
}
}
}//package christmasmemory.gameplay
Section 6
//CoordinateFilter (christmasmemory.movements.CoordinateFilter)
package christmasmemory.movements {
import flash.display.*;
import smileygamer.util.*;
class CoordinateFilter implements IFilter {
private var fRow:Boolean;
private var fSize:int;
private var fValue:int;
function CoordinateFilter(aRow:Boolean, aValue:int, aSize:int){
super();
fRow = aRow;
fValue = aValue;
fSize = aSize;
}
public function accept(aObject:Object):Boolean{
var obj:DisplayObject = (aObject as DisplayObject);
var value:int = int(((fValue * fSize) + (fSize / 2)));
return ((fRow) ? (int((obj.x + (fSize / 2))) == value) : (int((obj.y + (fSize / 2))) == value));
}
}
}//package christmasmemory.movements
Section 7
//MovementFactory (christmasmemory.movements.MovementFactory)
package christmasmemory.movements {
import flash.display.*;
import smileygamer.movement.*;
import smileygamer.util.*;
public class MovementFactory {
private var fSpeed:Number;
private var fObjectContainer:DisplayObjectContainer;
private var fRows:int;
private var fSize:int;
private var fCols:int;
private var fMovementsList:Array;
public static const TYPE_BOARD_RANDOM:int = 6;
public static const TYPE_LINE_COL_RND:int = 14;
public static const TYPE_BOARD_VER:int = 5;
public static const TYPE_LINE_COL_UP:int = 10;
public static const TYPE_BOARD_LEFT:int = 2;
public static const TYPE_BOARD_RIGHT:int = 3;
public static const TYPE_LINE_ROW_LEFT:int = 12;
public static const TYPE_LINE_COL_DOWN:int = 11;
public static const TYPE_LINE_ROW_RIGHT:int = 13;
public static const TYPE_BOARD_UP:int = 0;
public static const TYPE_NEIGHBOUR_SWAP_RND:int = 19;
public static const TYPE_BOARD_DOWN:int = 1;
public static const TYPE_TOTAL_RANDOM:int = 20;
public static const TYPE_NEIGHBOUR_SWAP_HOR:int = 17;
public static const TYPE_BOARD_VER_MESH:int = 8;
public static const TYPE_BOARD_RANDOM_MESH:int = 9;
public static const TYPE_LINE_ROW_RND:int = 15;
public static const TYPE_BOARD_HOR:int = 4;
public static const TYPE_LINE_RANDOM:int = 16;
public static const TYPE_NEIGHBOUR_SWAP_VER:int = 18;
public static const TYPE_BOARD_HOR_MESH:int = 7;
private static var SWAPMOVES:int = 24;
private static var MOVES:int = 25;
public function MovementFactory(aRows:int, aCols:int, aSize:int, aObjectContainer:DisplayObjectContainer){
fMovementsList = new Array();
super();
fRows = aRows;
fCols = aCols;
fSize = aSize;
fObjectContainer = aObjectContainer;
fSpeed = (Number(aSize) / MOVES);
}
public function createColMeshMovement():IMovement{
var speedY:int;
var movements:Array = new Array(fCols);
var i:int;
while (i < movements.length) {
speedY = (((i % 2) == 0)) ? fSpeed : -(fSpeed);
movements[i] = new LinearMovement(fObjectContainer, MOVES, 0, speedY, new CoordinateFilter(true, i, fSize));
i++;
};
return (new ComplexMovement(movements));
}
public function createVerSwapMovement():IMovement{
var bounds:DisplayObject;
var row:int = RandomUtil.generateRandom(0, (fRows - 1));
var col:int = RandomUtil.generateRandom(0, fCols);
var key1:String = ((row + "-") + col);
var key2:String = (((row + 1) + "-") + col);
while (((!((fMovementsList.indexOf(key1) == -1))) || (!((fMovementsList.indexOf(key2) == -1))))) {
row = RandomUtil.generateRandom(0, (fRows - 1));
col = RandomUtil.generateRandom(0, fCols);
key1 = ((row + "-") + col);
key2 = (((row + 1) + "-") + col);
};
fMovementsList.push(key1);
fMovementsList.push(key2);
var bounds1:DisplayObject;
var bounds2:DisplayObject;
var i:int;
while (i < fObjectContainer.numChildren) {
bounds = fObjectContainer.getChildAt(i);
if ((((Math.round(bounds.x) == (col * fSize))) && ((Math.round(bounds.y) == (row * fSize))))){
bounds1 = bounds;
} else {
if ((((Math.round(bounds.x) == (col * fSize))) && ((Math.round(bounds.y) == ((row + 1) * fSize))))){
bounds2 = bounds;
};
};
i++;
};
return (new SwapMovement(bounds1, bounds2, SWAPMOVES));
}
public function createComplexMovement(aType:int, aCount:int):IMovement{
if (aCount == 1){
return (createMovement(aType));
};
var movements:Array = new Array(aCount);
var i:int;
while (i < movements.length) {
movements[i] = createMovement(aType);
i++;
};
fMovementsList = new Array();
if ((((((aType == TYPE_NEIGHBOUR_SWAP_HOR)) || ((aType == TYPE_NEIGHBOUR_SWAP_VER)))) || ((aType == TYPE_NEIGHBOUR_SWAP_RND)))){
return (new ComplexMovement(movements));
};
return (new ComplexMovement(movements, ComplexMovement.TYPE_SEQUENTIAL));
}
public function createMovement(aType:int):IMovement{
var _local2:int;
var _local3:int;
switch (aType){
case TYPE_BOARD_UP:
return (new LinearMovement(fObjectContainer, MOVES, 0, -(fSpeed)));
case TYPE_BOARD_DOWN:
return (new LinearMovement(fObjectContainer, MOVES, 0, fSpeed));
case TYPE_BOARD_LEFT:
return (new LinearMovement(fObjectContainer, MOVES, -(fSpeed), 0));
case TYPE_BOARD_RIGHT:
return (new LinearMovement(fObjectContainer, MOVES, fSpeed, 0));
case TYPE_BOARD_HOR:
_local2 = (RandomUtil.randomBoolean()) ? -(fSpeed) : fSpeed;
return (new LinearMovement(fObjectContainer, MOVES, _local2, 0));
case TYPE_BOARD_VER:
_local3 = (RandomUtil.randomBoolean()) ? -(fSpeed) : fSpeed;
return (new LinearMovement(fObjectContainer, MOVES, 0, _local3));
case TYPE_BOARD_RANDOM:
return (createRandomBoardMovement());
case TYPE_BOARD_HOR_MESH:
return (createRowMeshMovement());
case TYPE_BOARD_VER_MESH:
return (createColMeshMovement());
case TYPE_BOARD_RANDOM_MESH:
if (RandomUtil.randomBoolean()){
return (createRowMeshMovement());
};
return (createColMeshMovement());
case TYPE_LINE_COL_UP:
return (createColMovement(true));
case TYPE_LINE_COL_DOWN:
return (createColMovement(false));
case TYPE_LINE_COL_RND:
return (createColMovement(RandomUtil.randomBoolean()));
case TYPE_LINE_ROW_LEFT:
return (createRowMovement(true));
case TYPE_LINE_ROW_RIGHT:
return (createRowMovement(false));
case TYPE_LINE_ROW_RND:
return (createRowMovement(RandomUtil.randomBoolean()));
case TYPE_LINE_RANDOM:
if (RandomUtil.randomBoolean()){
return (createRowMovement(RandomUtil.randomBoolean()));
};
return (createColMovement(RandomUtil.randomBoolean()));
case TYPE_NEIGHBOUR_SWAP_HOR:
return (createHorSwapMovement());
case TYPE_NEIGHBOUR_SWAP_VER:
return (createVerSwapMovement());
case TYPE_NEIGHBOUR_SWAP_RND:
if (RandomUtil.randomBoolean()){
return (createHorSwapMovement());
};
return (createVerSwapMovement());
case TYPE_TOTAL_RANDOM:
return (createMovement(RandomUtil.generateRandom(0, TYPE_NEIGHBOUR_SWAP_HOR)));
};
return (null);
}
public function createRowMovement(aLeft:Boolean):IMovement{
var speedX:int = (aLeft) ? -(fSpeed) : fSpeed;
var moves:int = (fSize / fSpeed);
var value:int = RandomUtil.generateRandom(0, fRows);
var key:String = (("row" + aLeft) + value);
while (fMovementsList.indexOf(key) != -1) {
value = RandomUtil.generateRandom(0, fRows);
key = (("row" + aLeft) + value);
};
fMovementsList.push(key);
return (new LinearMovement(fObjectContainer, MOVES, speedX, 0, new CoordinateFilter(false, value, fSize)));
}
public function createHorSwapMovement():IMovement{
var bounds:DisplayObject;
var row:int = RandomUtil.generateRandom(0, fRows);
var col:int = RandomUtil.generateRandom(0, (fCols - 1));
var key1:String = ((row + "-") + col);
var key2:String = ((row + "-") + (col + 1));
while (((!((fMovementsList.indexOf(key1) == -1))) || (!((fMovementsList.indexOf(key2) == -1))))) {
row = RandomUtil.generateRandom(0, fRows);
col = RandomUtil.generateRandom(0, (fCols - 1));
key1 = ((row + "-") + col);
key2 = ((row + "-") + (col + 1));
};
fMovementsList.push(key1);
fMovementsList.push(key2);
var bounds1:DisplayObject;
var bounds2:DisplayObject;
var i:int;
while (i < fObjectContainer.numChildren) {
bounds = fObjectContainer.getChildAt(i);
if ((((Math.round(bounds.x) == (col * fSize))) && ((Math.round(bounds.y) == (row * fSize))))){
bounds1 = bounds;
} else {
if ((((Math.round(bounds.x) == ((col + 1) * fSize))) && ((Math.round(bounds.y) == (row * fSize))))){
bounds2 = bounds;
};
};
i++;
};
return (new SwapMovement(bounds1, bounds2, SWAPMOVES));
}
public function createColMovement(aUp:Boolean):IMovement{
var speedY:int = (aUp) ? -(fSpeed) : fSpeed;
var moves:int = (fSize / fSpeed);
var value:int = RandomUtil.generateRandom(0, fCols);
var key:String = (("col" + aUp) + value);
while (fMovementsList.indexOf(key) != -1) {
value = RandomUtil.generateRandom(0, fRows);
key = (("col" + aUp) + value);
};
fMovementsList.push(key);
return (new LinearMovement(fObjectContainer, MOVES, 0, speedY, new CoordinateFilter(true, value, fSize)));
}
public function createRandomBoardMovement():IMovement{
var rnd:int = RandomUtil.generateRandom(0, 4);
var speedX:int;
var speedY:int;
switch (rnd){
case 0:
speedX = -(fSpeed);
break;
case 1:
speedX = fSpeed;
break;
case 2:
speedY = -(fSpeed);
break;
case 3:
speedY = fSpeed;
break;
};
return (new LinearMovement(fObjectContainer, MOVES, speedX, speedY));
}
public function createRowMeshMovement():IMovement{
var speedX:int;
var movements:Array = new Array(fRows);
var i:int;
while (i < movements.length) {
speedX = (((i % 2) == 0)) ? fSpeed : -(fSpeed);
movements[i] = new LinearMovement(fObjectContainer, MOVES, speedX, 0, new CoordinateFilter(false, i, fSize));
i++;
};
return (new ComplexMovement(movements));
}
}
}//package christmasmemory.movements
Section 8
//SwapMovement (christmasmemory.movements.SwapMovement)
package christmasmemory.movements {
import flash.display.*;
import christmasmemory.*;
import smileygamer.movement.*;
public class SwapMovement implements IMovement {
private var fSteps:int;
private var fCircleY:Array;
private var fCircleX:Array;
private var fObject1:PresentSprite;
private var fObject2:PresentSprite;
private var fStep:int;// = 0
public function SwapMovement(aBounds1:DisplayObject, aBounds2:DisplayObject, aSteps:int){
super();
fObject1 = (aBounds1 as PresentSprite);
fObject2 = (aBounds2 as PresentSprite);
fSteps = aSteps;
var centerX:Number = ((fObject1.x + fObject2.x) / 2);
var centerY:Number = ((fObject1.y + fObject2.y) / 2);
var dist:Number = Math.sqrt((Math.pow((fObject1.x - centerX), 2) + Math.pow((fObject1.y - centerY), 2)));
var startAngle:Number = Math.atan2((fObject1.y - centerY), (fObject1.x - centerX));
fCircleX = new Array((fSteps * 2));
fCircleY = new Array((fSteps * 2));
var i:int;
while (i < fCircleX.length) {
fCircleX[i] = ((Math.cos((((Math.PI * i) / (fSteps - 1)) + startAngle)) * dist) + centerX);
fCircleY[i] = ((Math.sin((((Math.PI * i) / (fSteps - 1)) + startAngle)) * dist) + centerY);
i++;
};
fCircleX[0] = (fCircleX[((fSteps * 2) - 1)] = fObject1.x);
fCircleY[0] = (fCircleY[((fSteps * 2) - 1)] = fObject1.y);
fCircleX[(fSteps - 1)] = (fCircleX[fSteps] = fObject2.x);
fCircleY[(fSteps - 1)] = (fCircleY[fSteps] = fObject2.y);
}
public function move():Boolean{
if (fStep < fSteps){
fObject1.x = fCircleX[fStep];
fObject1.y = fCircleY[fStep];
fObject2.x = fCircleX[(fStep + fSteps)];
fObject2.y = fCircleY[(fStep + fSteps)];
fObject1.moving = true;
fObject2.moving = true;
fStep++;
} else {
fObject1.moving = false;
fObject2.moving = false;
};
return ((fStep == fSteps));
}
}
}//package christmasmemory.movements
Section 9
//Awards (christmasmemory.Awards)
package christmasmemory {
public class Awards {
public static const AWARDTEXTS:Array = ["Easy: Finish a level with 5 thumbs up", "Easy: Finish 5 levels with 5 thumbs up", "Easy: Finish the game", "Easy: Finish the game with 4 thumbs up", "Easy: Finish all levels with 4 or 5 thumbs up", "Easy: Finish the game with 5 thumbs up", "Normal: Finish a level with 5 thumbs up", "Normal: Finish 5 levels with 5 thumbs up", "Normal: Finish the game ", "Normal: Finish the game with 4 thumbs up", "Normal: Finish all levels with 4 or 5 thumbs up", "Normal: Finish the game with 5 thumbs up", "Hard: Finish a level with 5 thumbs up", "Hard: Finish 5 levels with 5 thumbs up", "Hard: Finish the game ", "Hard: Finish the game with 4 thumbs up", "Hard: Finish all levels with 4 or 5 thumbs up", "Hard: Finish the game with 5 thumbs up", "Very Hard: Finish a level with 5 thumbs up", "Very Hard: Finish 5 levels with 5 thumbs up", "Very Hard: Finish the game ", "Very Hard: Finish the game with 4 thumbs up", "Very Hard: Finish all levels with 4 or 5 thumbs up", "Very Hard: Finish the game with 5 thumbs up"];
private static var fFourThumbsUp:Boolean;
private static var fHasNewAwards:Boolean = false;
private static var fAllThumbsUp:int;
private static var fCurrentMode:int;
private static var fAwards:Array = null;
public function Awards(){
super();
}
public static function newAwardsSeen():void{
fHasNewAwards = false;
}
public static function get hasNewAwards():Boolean{
return (fHasNewAwards);
}
public static function levelFinished(aThumbsUp:int):void{
if (aThumbsUp == 5){
fAllThumbsUp++;
};
if (aThumbsUp < 4){
fFourThumbsUp = false;
};
saveAwards();
}
public static function gameFinished(aThumbsUp:int):void{
if (!fAwards[((fCurrentMode * 6) + 2)]){
fHasNewAwards = true;
};
fAwards[((fCurrentMode * 6) + 2)] = true;
if (aThumbsUp > 3){
if (!fAwards[((fCurrentMode * 6) + 3)]){
fHasNewAwards = true;
};
fAwards[((fCurrentMode * 6) + 3)] = true;
};
if (fFourThumbsUp){
if (!fAwards[((fCurrentMode * 6) + 4)]){
fHasNewAwards = true;
};
fAwards[((fCurrentMode * 6) + 4)] = true;
};
if (aThumbsUp == 5){
if (!fAwards[((fCurrentMode * 6) + 5)]){
fHasNewAwards = true;
};
fAwards[((fCurrentMode * 6) + 5)] = true;
};
saveAwards();
}
public static function gameOver():void{
saveAwards();
}
public static function startGame(aMode:int, aSaveGame:Object=null):void{
fAwards = null;
awards;
fCurrentMode = aMode;
if (aSaveGame == null){
fAllThumbsUp = 0;
fFourThumbsUp = true;
} else {
fAllThumbsUp = aSaveGame.allThumbsUp;
fFourThumbsUp = aSaveGame.fourThumbsUp;
};
}
public static function get awardCount():int{
var cnt:int;
var i:int;
while (i < awards.length) {
if (fAwards[i]){
cnt++;
};
i++;
};
return (cnt);
}
private static function saveAwards():void{
if (fAllThumbsUp > 0){
if (!fAwards[(fCurrentMode * 6)]){
fHasNewAwards = true;
};
fAwards[(fCurrentMode * 6)] = true;
};
if (fAllThumbsUp > 4){
if (!fAwards[((fCurrentMode * 6) + 1)]){
fHasNewAwards = true;
};
fAwards[((fCurrentMode * 6) + 1)] = true;
};
SaveData.awards = fAwards;
}
public static function get allThumbsUp():int{
return (fAllThumbsUp);
}
public static function get awards():Array{
if (fAwards == null){
fAwards = SaveData.awards;
};
return (fAwards);
}
public static function get fourThumbsUp():Boolean{
return (fFourThumbsUp);
}
}
}//package christmasmemory
Section 10
//AwardsScreen (christmasmemory.AwardsScreen)
package christmasmemory {
import flash.events.*;
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
public class AwardsScreen extends Sprite {
private var fPresentText:TextField;
private var fGame:ChristmasMemory;
private var fPresents:Array;
private static var PresentsImg:Class = AwardsScreen_PresentsImg;
private static var sPresents:Array = BitmapUtil.splitImage(new PresentsImg(), 75, 75);
public function AwardsScreen(aGame:ChristmasMemory){
var i:int;
var present:Sprite;
super();
fGame = aGame;
var toptext:TextField = TextFactory.createTextField(TextFactory.SIZE_NORMAL, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
toptext.text = (("You collected " + Awards.awardCount) + " out of 24 presents!");
toptext.x = (250 - (toptext.width / 2));
toptext.y = 5;
addChild(toptext);
fPresents = new Array(24);
i = 0;
while (i < fPresents.length) {
present = new Sprite();
present.addChild(new Bitmap(Bitmap(sPresents[(i % 6)]).bitmapData));
if (!Awards.awards[i]){
present.alpha = 0.25;
};
present.x = (25 + ((i % 6) * 75));
present.y = (30 + (int((i / 6)) * 75));
fPresents[i] = present;
addChild(present);
present.buttonMode = true;
present.addEventListener(MouseEvent.MOUSE_OVER, showText);
present.addEventListener(MouseEvent.MOUSE_OUT, hideText);
i++;
};
fPresentText = TextFactory.createTextField(TextFactory.SIZE_SMALL);
fPresentText.text = "";
i = 0;
while (i < 100) {
fPresentText.text = (fPresentText.text + " ");
i++;
};
fPresentText.x = 5;
fPresentText.y = 335;
addChild(fPresentText);
addEventListener(MouseEvent.CLICK, showTitle);
addEventListener(Event.ADDED, added);
Awards.newAwardsSeen();
}
public function added(aEvent:Event):void{
removeEventListener(Event.ADDED, added);
new MoveAnimation(this, new Point(0, -380), new Point(0, 0), 15, InterpolationUtil.TYPE_COSINE);
}
private function showText(e:Event):void{
var i:int;
while (i < fPresents.length) {
if (e.target == fPresents[i]){
fPresentText.text = Awards.AWARDTEXTS[i];
};
i++;
};
}
function showTitle(e:Event):void{
var showTitle2:Function;
var e = e;
showTitle2 = function ():void{
fGame.showTitleScreen();
};
var anim:MoveAnimation = new MoveAnimation(this, new Point(0, 0), new Point(0, -380), 15, InterpolationUtil.TYPE_COSINE, 0, true);
anim.addCallback(showTitle2);
}
private function hideText(e:Event):void{
fPresentText.text = "";
}
}
}//package christmasmemory
Section 11
//AwardsScreen_PresentsImg (christmasmemory.AwardsScreen_PresentsImg)
package christmasmemory {
import mx.core.*;
public class AwardsScreen_PresentsImg extends BitmapAsset {
}
}//package christmasmemory
Section 12
//Background (christmasmemory.Background)
package christmasmemory {
import flash.display.*;
import flash.geom.*;
public class Background extends Shape {
public function Background(){
super();
var m:Matrix = new Matrix();
m.createGradientBox(360, 360, (Math.PI / 2));
graphics.beginGradientFill(GradientType.LINEAR, new Array(6075623, 14480619), new Array(1, 1), new Array(0, 0xFF), m);
graphics.drawRect(0, 0, 500, 360);
cacheAsBitmap = true;
}
}
}//package christmasmemory
Section 13
//BoardFrame (christmasmemory.BoardFrame)
package christmasmemory {
import flash.geom.*;
import flash.display.*;
import flash.filters.*;
public class BoardFrame extends Shape {
private var fBoardCorner:Point;
private var fLifeBarRect:Rectangle;
private static const MOVEBAR_RECT:Rectangle = new Rectangle(150, 330, 160, 15);
private static const COLOR:int = 1746233;
public function BoardFrame(aBoardWidth:int){
fLifeBarRect = new Rectangle(0, 25, 15, 280);
super();
var outerLeft:int = ((450 - aBoardWidth) / 2);
var innerRight:int = ((outerLeft + aBoardWidth) + 15);
fBoardCorner = new Point((outerLeft + 15), 15);
fLifeBarRect.x = (innerRight + 10);
graphics.beginFill(COLOR);
graphics.drawRoundRect(outerLeft, 0, (aBoardWidth + 50), 330, 40, 40);
graphics.drawRoundRect((fBoardCorner.x - 1), (fBoardCorner.y - 1), (aBoardWidth + 2), 302, 20, 20);
graphics.drawRoundRect(fLifeBarRect.x, fLifeBarRect.y, fLifeBarRect.width, fLifeBarRect.height, 6, 6);
graphics.endFill();
graphics.beginFill(COLOR);
graphics.drawRoundRect(0, 315, 500, 70, 40, 40);
graphics.drawRoundRect(MOVEBAR_RECT.x, MOVEBAR_RECT.y, MOVEBAR_RECT.width, MOVEBAR_RECT.height, 6, 6);
graphics.endFill();
var bevel:BevelFilter = new BevelFilter(6, 30, 0xFFFFFF, 1, 0, 0.8, 6, 6, 1, BitmapFilterQuality.HIGH);
var shadow:DropShadowFilter = new DropShadowFilter(3);
shadow.alpha = 0.6;
shadow.quality = BitmapFilterQuality.HIGH;
filters = [bevel, shadow];
cacheAsBitmap = true;
}
public function get boardCorner():Point{
return (fBoardCorner);
}
public function get moveBarRect():Rectangle{
return (MOVEBAR_RECT);
}
public function get lifeBarRect():Rectangle{
return (fLifeBarRect);
}
}
}//package christmasmemory
Section 14
//BoardLayer (christmasmemory.BoardLayer)
package christmasmemory {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
import smileygamer.movement.*;
import smileygamer.util.*;
import christmasmemory.movements.*;
public class BoardLayer extends Sprite {
private var fPresentsSprite:Sprite;
private var fMovement:IMovement;
private var fSize:int;
private var fState:int;// = 0
private var fTries:int;
private var fMovementFactory:MovementFactory;
private var fPresent1:int;
private var fPresent2:int;
private var fPresents:Array;
private var fRows:int;
private var fBoardBounds:Rectangle;
private var fCols:int;
public static const RES_MATCH:int = 1;
private static const NORMAL:int = 0;
public static const RES_MISMATCH:int = 2;
private static const MISMATCH:int = 2;
private static const FINISHED:int = 3;
private static const ONE_CLICKED:int = 1;
public static const RES_NONE:int = 0;
public function BoardLayer(aCols:int, aRows:int, aSize:int){
super();
fCols = aCols;
fRows = aRows;
fSize = aSize;
fPresents = new Array((fCols * fRows));
fBoardBounds = new Rectangle(0, 0, (fCols * fSize), (fRows * fSize));
fPresentsSprite = new Sprite();
addChild(fPresentsSprite);
fMovementFactory = new MovementFactory(fRows, fCols, fSize, fPresentsSprite);
var square:Sprite = new Sprite();
square.graphics.beginFill(0xFF0000);
square.graphics.drawRect(-1, -1, ((fCols * fSize) + 2), ((fRows * fSize) + 2));
addChild(square);
mask = square;
addEventListener(Event.ENTER_FRAME, update);
}
public function update(e:Event):void{
moveSmileys();
}
public function init():void{
var i:int = (fPresentsSprite.numChildren - 1);
while (i >= 0) {
fPresentsSprite.removeChildAt(i);
i--;
};
var types:Array = RandomUtil.generateRandomArray(((fSize)==75) ? 12 : 24);
var randoms:Array = RandomUtil.generateRandomArray((fCols * fRows));
var presentType:int = RandomUtil.generateRandom(0, 6);
var index:int;
while (index < fPresents.length) {
fPresents[index] = new PresentSprite(types[int((randoms[index] / 2))], presentType, fSize, fBoardBounds);
fPresents[index].x = ((index % fCols) * fSize);
fPresents[index].y = (int((index / fCols)) * fSize);
fPresentsSprite.addChild(fPresents[index]);
index++;
};
fState = NORMAL;
fTries = 0;
turnAll();
}
private function moveSmileys():void{
var i:int;
var smiley:PresentSprite;
if (fMovement != null){
if (fMovement.move()){
fMovement = null;
i = 0;
while (i < fPresents.length) {
smiley = fPresents[i];
smiley.moving = false;
i++;
};
};
i = 0;
while (i < fPresents.length) {
smiley = fPresents[i];
smiley.locationChanged();
if (smiley.moving){
fPresentsSprite.setChildIndex(smiley, (fPresentsSprite.numChildren - 1));
};
i++;
};
};
}
public function isFinished():Boolean{
return ((fState == FINISHED));
}
public function get tries():int{
return (fTries);
}
public function doMovement(aType:int, aCount:int):void{
fMovement = fMovementFactory.createComplexMovement(aType, aCount);
}
public function turnAll():void{
var smiley:PresentSprite;
var i:int;
while (i < fPresents.length) {
smiley = fPresents[i];
smiley.turn();
i++;
};
}
public function clicked(aX:int, aY:int):int{
var i:int;
var finished:Boolean;
var smiley:PresentSprite;
if (!fBoardBounds.contains(aX, aY)){
return (RES_NONE);
};
var clickedSmiley = -1;
i = 0;
while (i < fPresents.length) {
if (fPresents[i].containsPt(aX, aY)){
clickedSmiley = i;
break;
};
i++;
};
if (clickedSmiley == -1){
return (RES_NONE);
};
switch (fState){
case MISMATCH:
fPresents[fPresent1].turn();
fPresents[fPresent2].turn();
fState = NORMAL;
case NORMAL:
if (!fPresents[clickedSmiley].isVisible()){
fPresent1 = clickedSmiley;
fPresents[fPresent1].turn();
fState = ONE_CLICKED;
};
break;
case ONE_CLICKED:
if (!fPresents[clickedSmiley].isVisible()){
fTries++;
fPresent2 = clickedSmiley;
fPresents[fPresent2].turn();
if (fPresents[fPresent1].type == fPresents[fPresent2].type){
fState = NORMAL;
finished = true;
i = 0;
while (i < fPresents.length) {
smiley = fPresents[i];
finished = ((finished) && (smiley.isVisible()));
i++;
};
if (finished){
fState = FINISHED;
};
return (RES_MATCH);
} else {
fState = MISMATCH;
return (RES_MISMATCH);
};
};
break;
};
return (RES_NONE);
}
}
}//package christmasmemory
Section 15
//BonusAnimation (christmasmemory.BonusAnimation)
package christmasmemory {
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
public class BonusAnimation extends AAnimation {
private var fSteps:int;
public function BonusAnimation(aParent:DisplayObjectContainer, aText:String){
var bonusField:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
bonusField.defaultTextFormat.italic = true;
bonusField.text = aText;
fSteps = (ChristmasMemory.LOWFPS) ? 40 : 60;
super(bonusField);
looping = false;
aParent.addChild(bonusField);
}
override public function update():void{
if (frame == ((fSteps / 2) + 5)){
new MoveAnimation(displayObject, new Point((250 - (displayObject.width / 2)), 120), new Point(-(displayObject.width), 120), ((fSteps / 2) - 5), InterpolationUtil.TYPE_COSINE, 0, true);
};
}
override protected function get frameCount():int{
return (fSteps);
}
override public function reset():void{
super.reset();
new MoveAnimation(displayObject, new Point(510, 120), new Point((250 - (displayObject.width / 2)), 120), ((fSteps / 2) - 5), InterpolationUtil.TYPE_COSINE);
}
}
}//package christmasmemory
Section 16
//GameButton (christmasmemory.GameButton)
package christmasmemory {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.filters.*;
public class GameButton extends SimpleButton {
private static const COLOR:int = 1746233;
private static const HEIGHT:int = 30;
private static const COLOR_SEL:int = 14223111;
public function GameButton(aTitle:String){
var selected:Sprite;
var playSound:Function;
var aTitle = aTitle;
playSound = function (e:Event):void{
SoundManager.playButton();
};
var normal:Sprite = new Sprite();
var tf:TextField = TextFactory.createTextField(TextFactory.SIZE_NORMAL);
tf.text = aTitle;
var background:Shape = createBackground(tf.width);
normal.addChild(background);
tf.x = ((normal.width - tf.width) / 2);
tf.y = ((normal.height - tf.height) / 2);
normal.addChild(tf);
normal.cacheAsBitmap = true;
selected = new Sprite();
selected.addChild(createBackground(tf.width, true));
var tfsel:TextField = TextFactory.createTextField(TextFactory.SIZE_NORMAL, TextFactory.COLOR_SELECTED);
tfsel.text = aTitle;
tfsel.x = ((selected.width - tfsel.width) / 2);
tfsel.y = ((selected.height - tfsel.height) / 2);
selected.addChild(tfsel);
selected.cacheAsBitmap = true;
super(normal, selected, selected, background);
var bevel:BevelFilter = new BevelFilter(4, 30, 0xFFFFFF, 1, 0, 0.8, 4, 4, 1, BitmapFilterQuality.HIGH);
var shadow:DropShadowFilter = new DropShadowFilter(4);
shadow.alpha = 0.8;
shadow.quality = BitmapFilterQuality.HIGH;
filters = [bevel, shadow];
addEventListener(MouseEvent.MOUSE_OVER, playSound);
}
private function createBackground(aWidth:int, aSelected:Boolean=false):Shape{
var bg:Shape = new Shape();
var radius:int = (HEIGHT / 2);
bg.graphics.beginFill((aSelected) ? COLOR_SEL : COLOR);
bg.graphics.drawCircle(radius, radius, radius);
bg.graphics.endFill();
bg.graphics.beginFill((aSelected) ? COLOR_SEL : COLOR);
bg.graphics.drawRect(radius, 0, aWidth, HEIGHT);
bg.graphics.endFill();
bg.graphics.beginFill((aSelected) ? COLOR_SEL : COLOR);
bg.graphics.drawCircle((aWidth + radius), radius, radius);
bg.graphics.endFill();
return (bg);
}
}
}//package christmasmemory
Section 17
//GameCompleteAnimation (christmasmemory.GameCompleteAnimation)
package christmasmemory {
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
public class GameCompleteAnimation extends AAnimation {
private var fLevelField:TextField;
private var fCongrats:TextField;
private var fScoreField:TextField;
public function GameCompleteAnimation(aParent:DisplayObjectContainer, aScore:int, aTime:String, aThumbsUpLayer:ThumbsUpLayer){
var layer:Sprite;
var addThumbsLayer:Function;
var aParent = aParent;
var aScore = aScore;
var aTime = aTime;
var aThumbsUpLayer = aThumbsUpLayer;
addThumbsLayer = function ():void{
layer.addChild(aThumbsUpLayer);
};
layer = new Sprite();
fCongrats = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
fCongrats.text = "You did it!";
layer.addChild(fCongrats);
fScoreField = TextFactory.createTextField(TextFactory.SIZE_LARGE, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
fScoreField.text = ("Score: " + aScore);
layer.addChild(fScoreField);
var timeField:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGE, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
timeField.text = ("Time: " + aTime);
layer.addChild(timeField);
super(layer);
looping = true;
new MoveAnimation(fCongrats, new Point((200 - (fCongrats.width / 2)), -(fCongrats.height)), new Point((200 - (fCongrats.width / 2)), 15), 20, InterpolationUtil.TYPE_COSINE);
new MoveAnimation(fScoreField, new Point(500, 80), new Point((200 - (fScoreField.width / 2)), 80), 20, InterpolationUtil.TYPE_COSINE, 5);
var anim:MoveAnimation = new MoveAnimation(timeField, new Point(500, 120), new Point((200 - (timeField.width / 2)), 120), 20, InterpolationUtil.TYPE_COSINE, 10);
aThumbsUpLayer.x = (200 - (aThumbsUpLayer.width / 2));
aThumbsUpLayer.y = 160;
anim.addCallback(addThumbsLayer);
aParent.addChild(layer);
}
override public function update():void{
if ((frame % 10) == 0){
if (fCongrats.textColor == TextFactory.COLOR_DEFAULT){
fCongrats.textColor = TextFactory.COLOR_SELECTED;
} else {
fCongrats.textColor = TextFactory.COLOR_DEFAULT;
};
};
}
override protected function get frameCount():int{
return (20);
}
public function endAnimation():void{
new FadeAnimation(displayObject, 5, FadeAnimation.MODE_FADE_OUT_REMOVE);
}
}
}//package christmasmemory
Section 18
//GameOverAnimation (christmasmemory.GameOverAnimation)
package christmasmemory {
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
public class GameOverAnimation extends AAnimation {
private var fLevelField:TextField;
private var fScoreField:TextField;
public function GameOverAnimation(aParent:DisplayObjectContainer, aScore:int, aLevel:int, aTotalLevels:int){
var layer:Sprite = new Sprite();
var gameOver:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
gameOver.text = "Game Over";
layer.addChild(gameOver);
fLevelField = TextFactory.createTextField(TextFactory.SIZE_LARGE, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
fLevelField.text = ((("Level " + aLevel) + " of ") + aTotalLevels);
fLevelField.x = 510;
fLevelField.y = 110;
layer.addChild(fLevelField);
fScoreField = TextFactory.createTextField(TextFactory.SIZE_LARGE, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
fScoreField.text = ("Score: " + aScore);
fScoreField.x = 510;
fScoreField.y = 150;
layer.addChild(fScoreField);
super(layer);
looping = false;
new MoveAnimation(gameOver, new Point((200 - (gameOver.width / 2)), -(gameOver.height)), new Point((200 - (gameOver.width / 2)), 25), 20, InterpolationUtil.TYPE_COSINE);
aParent.addChild(layer);
}
public function endAnimation():void{
new FadeAnimation(displayObject, 5, FadeAnimation.MODE_FADE_OUT_REMOVE);
}
override protected function get frameCount():int{
return (50);
}
override public function update():void{
if (frame == 20){
new MoveAnimation(fLevelField, new Point(510, fLevelField.y), new Point((200 - (fLevelField.width / 2)), fLevelField.y), 20, InterpolationUtil.TYPE_COSINE);
};
if (frame == 30){
new MoveAnimation(fScoreField, new Point(510, fScoreField.y), new Point((200 - (fScoreField.width / 2)), fScoreField.y), 20, InterpolationUtil.TYPE_COSINE);
};
}
}
}//package christmasmemory
Section 19
//GameScreen (christmasmemory.GameScreen)
package christmasmemory {
import flash.events.*;
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import christmasmemory.gameplay.*;
import flash.text.*;
import smileygamer.util.*;
import flash.utils.*;
import flash.ui.*;
public class GameScreen extends Sprite implements ILogic {
private var fSubmitSprite:Sprite;
private var fStartTime:int;
private var fBoardLayer:BoardLayer;
private var fThumbsUpLayer:ThumbsUpLayer;
private var fShowButton:SimpleButton;
private var fPointsField:TextField;
private var fTotalLife:int;
private var fPointsFactor:Number;// = 1
private var fAdTab:Sprite;
private var fLevelCompleteAnimation:LevelCompleteAnimation;
private var fLifeBar:LifeBar;
private var fBoardFrame:BoardFrame;
private var fMessageField:TextField;
private var fMoveBar:MoveBar;
private var fLimitText:Sprite;
private var fEndShowingTimer:Timer;
private var fHelpLayer:Sprite;
private var fState:int;// = 0
private var fLastAdTime:int;// = -300000
private var fLevelGame:ILevelGame;
private var fTime:int;
private var fClickField:TextField;
private var fTriesField:TextField;
private var fPoints:int;
private var fTotalTime:int;
private var fMatches:int;// = 0
private var fBoardBackground:Sprite;
private var fNameField:TextField;
private var fTickTimer:Timer;
private var fDownloadSprite:Sprite;
private var fLevelCompleteTimer:Timer;
private var fTimeField:TextField;
private var fGame:ChristmasMemory;
private var fPausedLayer:Sprite;
private static const STATE_LIMIT_REACHED:int = 10;
private static const STATE_LEVEL_COMPLETE:int = 6;
private static const STATE_PAUSED:int = 5;
private static const STATE_INVALID:int = 0;
private static const STATE_HELP:int = 2;
private static const STATE_RUNNING:int = 4;
private static const STATE_SHOWING:int = 3;
private static const STATE_OUTRO:int = 9;
private static const BONUS_POINTS:int = 500;
private static const STATE_GAME_OVER:int = 7;
private static const STATE_GAME_WON:int = 8;
private static const MATCH_POINTS:int = 50;
private static const STATE_INTRO:int = 1;
private static var sHelpShown:Boolean = false;
public function GameScreen(aGame:ChristmasMemory, aLevelGame:ILevelGame, aSaveGame:Object=null){
super();
fGame = aGame;
fLevelGame = aLevelGame;
if (aSaveGame != null){
fPoints = aSaveGame.score;
fTotalLife = aSaveGame.totalLife;
fTotalTime = aSaveGame.totalTime;
Awards.startGame(fLevelGame.id, aSaveGame);
} else {
fPoints = 0;
fTotalLife = 0;
fTotalTime = 0;
Awards.startGame(fLevelGame.id);
};
y = 360;
addEventListener(Event.ADDED, added);
addEventListener(Event.REMOVED, removed);
}
public function added(aEvent:Event):void{
removeEventListener(Event.ADDED, added);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseUpdate);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpdate);
stage.addEventListener(MouseEvent.CLICK, mouseUpdate);
stage.addEventListener(KeyboardEvent.KEY_UP, doKey);
init();
}
private function endGame(e:Event):void{
var showTitle:Function;
var e = e;
showTitle = function ():void{
Mouse.hide();
fGame.showTitleScreen();
};
fState = STATE_OUTRO;
var anim:MoveAnimation = new MoveAnimation(this, new Point(0, 0), new Point(0, 360), 15, InterpolationUtil.TYPE_LINEAR, 0, true);
anim.addCallback(showTitle);
}
private function submitScore(e:Event):void{
var rankReceived:Function;
var e = e;
rankReceived = function (aRank:int):void{
if (aRank < 0){
fMessageField.text = "Not submitted";
} else {
if (aRank == 0){
fMessageField.text = "Submitted";
} else {
fMessageField.text = ("Rank " + aRank);
};
};
};
fSubmitSprite.visible = false;
fMessageField.visible = true;
fMessageField.text = "Submitting...";
fShowButton.visible = true;
var name:String = fNameField.text;
SaveData.name = name;
fGame.submitScore(name, fPoints, fLevelGame.id, rankReceived);
}
private function pauseGame(e:Event):void{
if (fState == STATE_RUNNING){
fState = STATE_PAUSED;
fTickTimer.stop();
fPausedLayer = createPausedLayer();
new MoveAnimation(fPausedLayer, new Point(0, -360), new Point(0, 0), 15, InterpolationUtil.TYPE_COSINE);
addChild(fPausedLayer);
} else {
if (fState == STATE_PAUSED){
unpauseGame(e);
};
};
}
private function createHelpLayer():Sprite{
var layer:Sprite = new Sprite();
var balloon1:TextBalloon = new TextBalloon(328, 116);
balloon1.x = 32;
balloon1.y = 20;
layer.addChild(balloon1);
var text1:TextField = TextFactory.createHelpTextField();
text1.text = (((("Goal: find all matching pairs of presents!\n" + "A level starts with all presents opened.\n") + "Remember as many as possible! \n\n") + "Click on an unopened present to open it.\n") + "Then try to find the matching present.");
text1.x = (balloon1.x + 12);
text1.y = (balloon1.y + 8);
layer.addChild(text1);
var startButton:GameButton = new GameButton("Start game");
startButton.x = (balloon1.x + ((balloon1.width - startButton.width) / 2));
startButton.y = ((balloon1.y + balloon1.height) + 8);
layer.addChild(startButton);
startButton.addEventListener(MouseEvent.CLICK, stopHelp);
var balloon2:TextBalloon = new TextBalloon(180, 100);
balloon2.x = (496 - balloon2.width);
balloon2.y = 150;
layer.addChild(balloon2);
var text2:TextField = TextFactory.createHelpTextField();
text2.text = (((("Life indicator: when it\n" + "runs empty, the game\n") + "is over! Decreases\n") + "with time and each\n") + "mismatch you make.");
text2.x = (balloon2.x + 12);
text2.y = (balloon2.y + 8);
layer.addChild(text2);
var balloon3:TextBalloon = new TextBalloon(286, 68);
balloon3.x = 32;
balloon3.y = 250;
layer.addChild(balloon3);
var text3:TextField = TextFactory.createHelpTextField();
text3.text = (("Next move indicator: when empty,\n" + "some presents will move around!\n") + "Decreases with time and mismatches.");
text3.x = (balloon3.x + 12);
text3.y = (balloon3.y + 8);
layer.addChild(text3);
var balloon4:TextBalloon = new TextBalloon(62, 26);
balloon4.x = 328;
balloon4.y = 300;
layer.addChild(balloon4);
var text4:TextField = TextFactory.createHelpTextField();
text4.text = "Pause";
text4.x = (balloon4.x + 8);
text4.y = (balloon4.y + 2);
layer.addChild(text4);
var balloon5:TextBalloon = new TextBalloon(62, 26);
balloon5.x = (490 - balloon5.width);
balloon5.y = 300;
layer.addChild(balloon5);
var text5:TextField = TextFactory.createHelpTextField();
text5.text = "Score";
text5.x = (balloon5.x + 8);
text5.y = (balloon5.y + 2);
layer.addChild(text5);
return (layer);
}
private function unpauseGame(e:Event):void{
fState = STATE_RUNNING;
fTickTimer.start();
new MoveAnimation(fPausedLayer, new Point(0, 0), new Point(0, -360), 15, InterpolationUtil.TYPE_COSINE, 0, true);
}
private function init():void{
var boardWidth:int = (fLevelGame.columns * fLevelGame.smileySize);
fBoardFrame = new BoardFrame(boardWidth);
fBoardLayer = new BoardLayer(fLevelGame.columns, fLevelGame.rows, fLevelGame.smileySize);
fBoardLayer.init();
fBoardLayer.x = fBoardFrame.boardCorner.x;
fBoardLayer.y = fBoardFrame.boardCorner.y;
addChild(fBoardLayer);
addChild(fBoardFrame);
fMoveBar = new MoveBar();
fMoveBar.maxValue = fLevelGame.moveTime;
fMoveBar.value = fLevelGame.moveTime;
fMoveBar.x = fBoardFrame.moveBarRect.x;
fMoveBar.y = fBoardFrame.moveBarRect.y;
fMoveBar.width = fBoardFrame.moveBarRect.width;
fMoveBar.height = fBoardFrame.moveBarRect.height;
addChild(fMoveBar);
fLifeBar = new LifeBar();
fLifeBar.maxValue = fLevelGame.life;
fLifeBar.value = fLevelGame.life;
fLifeBar.x = fBoardFrame.lifeBarRect.x;
fLifeBar.y = fBoardFrame.lifeBarRect.y;
fLifeBar.width = fBoardFrame.lifeBarRect.width;
fLifeBar.height = fBoardFrame.lifeBarRect.height;
addChild(fLifeBar);
fTriesField = TextFactory.createTextField();
fTriesField.x = 15;
fTriesField.y = 317;
fTriesField.width = 130;
fTriesField.height = 18;
fTriesField.text = (("TRIES: " + fBoardLayer.tries) + " ");
addChild(fTriesField);
fTimeField = TextFactory.createTextField();
fTimeField.x = 15;
fTimeField.y = 337;
fTimeField.width = 130;
fTimeField.height = 18;
fTimeField.text = "TIME: 0:00 ";
addChild(fTimeField);
fPointsField = TextFactory.createTextField(TextFactory.SIZE_LARGE);
fPointsField.autoSize = TextFieldAutoSize.RIGHT;
fPointsField.x = 355;
fPointsField.y = 319;
fPointsField.width = 135;
fPointsField.height = 30;
fPointsField.text = " ";
addChild(fPointsField);
var pauseButton:PauseButton = new PauseButton();
pauseButton.x = 325;
pauseButton.y = 322;
addChild(pauseButton);
pauseButton.addEventListener(MouseEvent.CLICK, pauseGame);
fClickField = TextFactory.createTextField(TextFactory.SIZE_MEDIUM, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
fClickField.autoSize = TextFieldAutoSize.CENTER;
fClickField.text = "Click to continue...";
fClickField.x = (250 - (fClickField.width / 2));
fClickField.y = 265;
fClickField.visible = false;
fClickField.selectable = false;
fClickField.mouseEnabled = true;
addChild(fClickField);
fClickField.addEventListener(MouseEvent.CLICK, nextLevel);
fState = STATE_INTRO;
var anim:MoveAnimation = new MoveAnimation(this, new Point(0, 360), new Point(0, 0), 20, InterpolationUtil.TYPE_LINEAR);
if (!sHelpShown){
anim.addCallback(startHelp);
} else {
anim.addCallback(startGame);
};
}
private function tick(e:TimerEvent):void{
fMoveBar.value = (fMoveBar.value - 0.1);
fLifeBar.value = (fLifeBar.value - 0.1);
checkBars();
}
private function levelFinished():void{
fTickTimer.stop();
if (fMatches > 2){
fLevelCompleteTimer.delay = 2000;
} else {
fLevelCompleteTimer.delay = 1000;
};
fTotalLife = (fTotalLife + fLifeBar.value);
fTotalTime = (fTotalTime + fTime);
fLevelCompleteTimer.start();
}
public function doLogic():void{
switch (fState){
case STATE_RUNNING:
if (((((getTimer() - fStartTime) > 1000)) && (fTickTimer.running))){
fStartTime = getTimer();
fTime++;
fTimeField.text = ("TIME: " + formatTime(fTime));
};
break;
case STATE_LEVEL_COMPLETE:
if (((fLevelCompleteAnimation.finished) && ((fLifeBar.value > 0)))){
fLifeBar.value--;
addPoints(10);
fThumbsUpLayer.count++;
if (((ChristmasMemory.LOWFPS) && ((fLifeBar.value > 0)))){
fLifeBar.value--;
addPoints(10);
fThumbsUpLayer.count++;
};
if (fLifeBar.value <= 0){
fClickField.visible = true;
};
};
break;
};
}
private function createPausedLayer():Sprite{
var toggleSound:Function;
toggleSound = function (e:Event):void{
SoundManager.toggleSound();
};
var layer:Sprite = new Sprite();
var paused:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGEST, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
paused.text = "PAUSED";
paused.x = (250 - (paused.width / 2));
paused.y = 35;
layer.addChild(paused);
var resumeButton:SimpleButton = new GameButton("RESUME GAME");
resumeButton.x = (250 - (resumeButton.width / 2));
resumeButton.y = 160;
layer.addChild(resumeButton);
resumeButton.addEventListener(MouseEvent.CLICK, unpauseGame);
var soundToggleButton:SimpleButton = new GameButton("TOGGLE SOUND");
soundToggleButton.x = (250 - (soundToggleButton.width / 2));
soundToggleButton.y = 210;
layer.addChild(soundToggleButton);
soundToggleButton.addEventListener(MouseEvent.CLICK, toggleSound);
var endgameButton:SimpleButton = new GameButton("SAVE & END GAME");
endgameButton.x = (250 - (endgameButton.width / 2));
endgameButton.y = 260;
layer.addChild(endgameButton);
endgameButton.addEventListener(MouseEvent.CLICK, endGame);
return (layer);
}
private function showHighscores(e:Event):void{
fGame.showHighscoresPage();
}
private function formatTime(aTime:int):String{
return ((((int((aTime / 60)) + ":") + (((aTime % 60) < 10)) ? "0" : "") + (aTime % 60)));
}
private function createEndGameButtonLayer():Sprite{
var lbclosed:Function;
var menuButton:SimpleButton;
var otherButton:SimpleButton;
lbclosed = function ():void{
Mouse.hide();
new MoveAnimation(fAdTab, new Point(500, fAdTab.y), new Point(400, fAdTab.y), 15, InterpolationUtil.TYPE_COSINE);
addChild(fAdTab);
};
var layer:Sprite = new Sprite();
fGame.submitScore("", fPoints, fLevelGame.id, lbclosed);
if (ChristmasMemory.SPONSORED){
menuButton = new GameButton("BACK TO MENU");
menuButton.x = 0;
menuButton.y = 240;
layer.addChild(menuButton);
menuButton.addEventListener(MouseEvent.CLICK, endGame);
} else {
var other:Function = function (e:Event):void{
fGame.showSponsorSite();
};
otherButton = new GameButton("PLAY MORE GAMES");
otherButton.x = 0;
otherButton.y = 240;
layer.addChild(otherButton);
otherButton.addEventListener(MouseEvent.CLICK, other);
menuButton = new GameButton("MENU");
menuButton.x = (otherButton.width + 20);
menuButton.y = 240;
layer.addChild(menuButton);
menuButton.addEventListener(MouseEvent.CLICK, endGame);
};
return (layer);
}
private function submitMindJolt(e:Event):void{
var modeStr:String = "Easy";
if (fLevelGame.id == 1){
modeStr = "Normal";
};
if (fLevelGame.id == 2){
modeStr = "Hard";
};
if (fLevelGame.id == 3){
modeStr = "VeryHard";
};
ChristmasMemory.MindJoltAPI.service.submitScore(fPoints, modeStr);
}
private function startHelp():void{
fState = STATE_HELP;
fBoardLayer.turnAll();
fPointsField.text = "32850";
fHelpLayer = createHelpLayer();
addChild(fHelpLayer);
sHelpShown = true;
}
private function nextLevel(e:Event):void{
var buttons:Sprite;
var thumbsUp:ThumbsUpLayer;
var t:Timer;
fLevelCompleteAnimation.endAnimation();
new FadeAnimation(fThumbsUpLayer, 5, FadeAnimation.MODE_FADE_OUT_REMOVE);
fClickField.visible = false;
if (fLevelGame.level < fLevelGame.levelCount){
Awards.levelFinished(fThumbsUpLayer.rank);
SaveData.saveGame(fLevelGame.id, (fLevelGame.level + 1), fPoints, fTotalLife, fTotalTime, Awards.allThumbsUp, Awards.fourThumbsUp);
fLevelGame.nextLevel();
fBoardLayer.init();
fMoveBar.maxValue = fLevelGame.moveTime;
fMoveBar.value = fLevelGame.moveTime;
fLifeBar.maxValue = fLevelGame.life;
fLifeBar.value = fLevelGame.life;
fState = STATE_SHOWING;
new LevelAnimation(this, fLevelGame.level);
fEndShowingTimer.start();
} else {
Awards.levelFinished(fThumbsUpLayer.rank);
fAdTab = new Sprite();
SmileyGamer.showSGMoreGamesTab(fAdTab, 4292413191);
fAdTab.y = 60;
buttons = createEndGameButtonLayer();
new MoveAnimation(buttons, new Point(500, 10), new Point((200 - (buttons.width / 2)), 10), 20, InterpolationUtil.TYPE_COSINE, 20);
addChild(buttons);
thumbsUp = new ThumbsUpLayer(fLevelGame.totalLife);
thumbsUp.count = fTotalLife;
new GameCompleteAnimation(this, fPoints, formatTime(fTotalTime), thumbsUp);
SaveData.endGame(fLevelGame.id, fLevelGame.level, fPoints, thumbsUp.rank);
SaveData.clearSavedGame(fLevelGame.id);
Awards.gameFinished(thumbsUp.rank);
fState = STATE_GAME_WON;
SoundManager.playGameWon();
if (ChristmasMemory.MINDJOLT){
t = new Timer(1000, 1);
t.addEventListener(TimerEvent.TIMER_COMPLETE, submitMindJolt);
t.start();
};
};
}
private function doKey(e:KeyboardEvent):void{
if ((((e.keyCode == 80)) || ((e.keyCode == 27)))){
pauseGame(e);
};
if (e.keyCode == 83){
SoundManager.toggleSound();
};
}
public function mouseUpdate(aEvent:MouseEvent):void{
var result:int;
switch (fState){
case STATE_RUNNING:
if (aEvent.type == MouseEvent.MOUSE_DOWN){
if (!fBoardLayer.isFinished()){
result = fBoardLayer.clicked(fBoardLayer.mouseX, fBoardLayer.mouseY);
if (result == BoardLayer.RES_MISMATCH){
fMoveBar.value = (fMoveBar.value - fLevelGame.secondsPerTry);
fLifeBar.value = (fLifeBar.value - fLevelGame.secondsPerTry);
fMatches = 0;
SoundManager.playMismatch();
} else {
if (result == BoardLayer.RES_MATCH){
fMatches++;
addPoints(MATCH_POINTS);
if (fMatches > 2){
addPoints(BONUS_POINTS);
new BonusAnimation(this, ("BONUS: " + (BONUS_POINTS * fPointsFactor)));
SoundManager.playBonus();
} else {
SoundManager.playMatch();
};
if (fBoardLayer.isFinished()){
levelFinished();
};
};
};
fTriesField.text = ("TRIES: " + fBoardLayer.tries);
checkBars();
};
};
break;
case STATE_LEVEL_COMPLETE:
if ((((aEvent.type == MouseEvent.CLICK)) && (fClickField.visible))){
nextLevel(aEvent);
};
break;
};
}
public function removed(aEvent:Event):void{
removeEventListener(Event.REMOVED, removed);
}
private function addPoints(aPoints:int):void{
fPoints = (fPoints + (aPoints * fPointsFactor));
fPointsField.text = ("" + fPoints);
}
private function checkBars():void{
var buttons:Sprite;
var t:Timer;
if (fLifeBar.value <= 0){
fTickTimer.stop();
fState = STATE_GAME_OVER;
new GameOverAnimation(this, fPoints, fLevelGame.level, fLevelGame.levelCount);
SoundManager.playGameOver();
fAdTab = new Sprite();
SmileyGamer.showSGMoreGamesTab(fAdTab, 4292413191);
fAdTab.y = 60;
buttons = createEndGameButtonLayer();
new MoveAnimation(buttons, new Point(500, 0), new Point((200 - (buttons.width / 2)), 0), 20, InterpolationUtil.TYPE_COSINE);
addChild(buttons);
SaveData.endGame(fLevelGame.id, fLevelGame.level, fPoints, 0);
SaveData.saveGame(fLevelGame.id, fLevelGame.level, 0, fTotalLife, fTotalTime, Awards.allThumbsUp, Awards.fourThumbsUp);
Awards.gameOver();
if (ChristmasMemory.MINDJOLT){
t = new Timer(1000, 1);
t.addEventListener(TimerEvent.TIMER_COMPLETE, submitMindJolt);
t.start();
};
} else {
if (fMoveBar.value <= 0){
fBoardLayer.doMovement(fLevelGame.moveType, fLevelGame.moveCount);
fMoveBar.value = fLevelGame.moveTime;
};
};
}
private function showLevelComplete(e:Event):void{
fLevelCompleteTimer.stop();
fLevelCompleteAnimation = new LevelCompleteAnimation(this, fLevelGame.level);
fBoardLayer.turnAll();
fThumbsUpLayer = new ThumbsUpLayer(fLevelGame.life);
fThumbsUpLayer.x = 150;
fThumbsUpLayer.y = 175;
new FadeAnimation(fThumbsUpLayer, 5, FadeAnimation.MODE_FADE_IN);
addChild(fThumbsUpLayer);
fState = STATE_LEVEL_COMPLETE;
SoundManager.playLevelComplete();
}
private function startGame():void{
fState = STATE_SHOWING;
fPointsField.text = ("" + fPoints);
fEndShowingTimer = new Timer((fLevelGame.showingTime * 1000), 1);
fEndShowingTimer.addEventListener(TimerEvent.TIMER_COMPLETE, endShowing);
fEndShowingTimer.start();
new LevelAnimation(this, fLevelGame.level);
fTickTimer = new Timer(100);
fTickTimer.addEventListener(TimerEvent.TIMER, tick);
fLevelCompleteTimer = new Timer(1000, 1);
fLevelCompleteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, showLevelComplete);
}
private function endShowing(e:Event):void{
fBoardLayer.turnAll();
fState = STATE_RUNNING;
fStartTime = getTimer();
fTime = 0;
fTickTimer.start();
fMatches = 0;
}
private function stopHelp(e:Event):void{
removeChild(fHelpLayer);
fBoardLayer.turnAll();
startGame();
}
}
}//package christmasmemory
Section 20
//HandSprite (christmasmemory.HandSprite)
package christmasmemory {
import smileygamer.*;
import flash.filters.*;
public class HandSprite extends SGSprite {
private var fMouseDown:Boolean;// = false
private var HandUp:Class;
private var fHotspotX:int;// = 8
private var fHotspotY:int;// = 4
private var HandDown:Class;
private static const STATE_DOWN:String = "down";
private static const STATE_NORMAL:String = "default";
public function HandSprite(){
HandUp = HandSprite_HandUp;
HandDown = HandSprite_HandDown;
super();
addAnimation(STATE_NORMAL, new ImageAnimation(new HandUp()));
addAnimation(STATE_DOWN, new ImageAnimation(new HandDown()));
var shadow:DropShadowFilter = new DropShadowFilter(2);
shadow.alpha = 0.6;
shadow.quality = BitmapFilterQuality.HIGH;
var innershadow:DropShadowFilter = new DropShadowFilter(1, -135);
innershadow.quality = BitmapFilterQuality.HIGH;
innershadow.alpha = 0.8;
innershadow.inner = true;
filters = [innershadow, shadow];
mouseEnabled = false;
}
public function button(aDown:Boolean):void{
fMouseDown = aDown;
if (fMouseDown){
state = STATE_DOWN;
} else {
state = STATE_NORMAL;
};
}
public function move(aX:int, aY:int):void{
x = (aX - fHotspotX);
y = (aY - fHotspotY);
}
public function isMouseDown():Boolean{
return (fMouseDown);
}
}
}//package christmasmemory
Section 21
//HandSprite_HandDown (christmasmemory.HandSprite_HandDown)
package christmasmemory {
import mx.core.*;
public class HandSprite_HandDown extends BitmapAsset {
}
}//package christmasmemory
Section 22
//HandSprite_HandUp (christmasmemory.HandSprite_HandUp)
package christmasmemory {
import mx.core.*;
public class HandSprite_HandUp extends BitmapAsset {
}
}//package christmasmemory
Section 23
//LevelAnimation (christmasmemory.LevelAnimation)
package christmasmemory {
import flash.events.*;
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
import flash.utils.*;
public class LevelAnimation extends AAnimation {
public function LevelAnimation(aParent:DisplayObjectContainer, aLevel:int){
var fade:Function;
var aParent = aParent;
var aLevel = aLevel;
fade = function (e:Event):void{
new FadeAnimation(displayObject, frame, FadeAnimation.MODE_FADE_OUT_REMOVE);
};
var levelField:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGEST, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
levelField.text = ("LEVEL " + aLevel);
super(levelField);
looping = false;
new MoveAnimation(displayObject, new Point((250 - (displayObject.width / 2)), -(displayObject.height)), new Point((250 - (displayObject.width / 2)), 80), 20, InterpolationUtil.TYPE_COSINE);
var fader:Timer = new Timer(1000, 1);
fader.addEventListener(TimerEvent.TIMER_COMPLETE, fade);
fader.start();
aParent.addChild(levelField);
}
override protected function get frameCount():int{
return (60);
}
}
}//package christmasmemory
Section 24
//LevelCompleteAnimation (christmasmemory.LevelCompleteAnimation)
package christmasmemory {
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
public class LevelCompleteAnimation extends AAnimation {
public function LevelCompleteAnimation(aParent:DisplayObjectContainer, aLevel:int){
var tf:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
tf.autoSize = TextFieldAutoSize.CENTER;
tf.text = ("LEVEL " + aLevel);
var tf2:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
tf2.autoSize = TextFieldAutoSize.CENTER;
tf2.text = "COMPLETE!";
var sprite:Sprite = new Sprite();
sprite.addChild(tf);
sprite.addChild(tf2);
super(sprite);
looping = false;
new FadeAnimation(sprite, 15, FadeAnimation.MODE_FADE_IN);
new MoveAnimation(tf, new Point(-(tf.width), 30), new Point((250 - (tf.width / 2)), 30), 20, InterpolationUtil.TYPE_COSINE);
new MoveAnimation(tf2, new Point(500, 100), new Point((250 - (tf2.width / 2)), 100), 20, InterpolationUtil.TYPE_COSINE);
aParent.addChild(sprite);
}
public function endAnimation():void{
new FadeAnimation(displayObject, 5, FadeAnimation.MODE_FADE_OUT_REMOVE);
}
override protected function get frameCount():int{
return (30);
}
}
}//package christmasmemory
Section 25
//LifeBar (christmasmemory.LifeBar)
package christmasmemory {
import flash.events.*;
import smileygamer.*;
import flash.filters.*;
public class LifeBar extends AProgressBar {
public function LifeBar(){
super(1, 1, false);
addEventListener(Event.ENTER_FRAME, drawProgress);
var bevel:BevelFilter = new BevelFilter(4, 30, 0xFFFFFF, 0.8, 0, 0.8, 4, 4, 1, BitmapFilterQuality.HIGH);
filters = [bevel];
}
private function drawProgress(e:Event):void{
if (valueChanged){
graphics.clear();
graphics.beginFill(14223111);
graphics.drawRoundRect(0, (height - progress), width, progress, 6, 6);
graphics.endFill();
};
}
}
}//package christmasmemory
Section 26
//MoveBar (christmasmemory.MoveBar)
package christmasmemory {
import flash.events.*;
import smileygamer.*;
import flash.filters.*;
public class MoveBar extends AProgressBar {
public function MoveBar(){
super();
addEventListener(Event.ENTER_FRAME, drawProgress);
var bevel:BevelFilter = new BevelFilter(4, 30, 0xFFFFFF, 0.8, 0, 0.8, 4, 4, 1, BitmapFilterQuality.HIGH);
filters = [bevel];
}
private function drawProgress(e:Event):void{
if (valueChanged){
graphics.clear();
graphics.beginFill(14223111);
graphics.drawRoundRect(0, 0, progress, height, 6, 6);
graphics.endFill();
};
}
}
}//package christmasmemory
Section 27
//PauseButton (christmasmemory.PauseButton)
package christmasmemory {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
public class PauseButton extends SimpleButton {
private static const COLOR_DEFAULT:int = 14223111;
private static const COLOR_SELECTED:int = 16713479;
public function PauseButton(){
var playSound:Function;
playSound = function (e:Event):void{
SoundManager.playButton();
};
var normal:Shape = createPauseShape(COLOR_DEFAULT);
var sel:Shape = createPauseShape(COLOR_SELECTED);
var hit:Shape = new Shape();
hit.graphics.beginFill(0);
hit.graphics.drawCircle(16, 16, 16);
hit.graphics.endFill();
super(normal, sel, sel, hit);
var bevel:BevelFilter = new BevelFilter(2, 45, 0xFFFFFF, 1, 0, 0.8, 2, 2, 0.7, BitmapFilterQuality.HIGH);
var shadow:DropShadowFilter = new DropShadowFilter(2);
shadow.alpha = 0.8;
shadow.quality = BitmapFilterQuality.HIGH;
filters = [bevel, shadow];
addEventListener(MouseEvent.MOUSE_OVER, playSound);
}
private function createPauseShape(aColor:int):Shape{
var s:Shape = new Shape();
s.graphics.beginFill(aColor);
s.graphics.drawCircle(16, 16, 16);
s.graphics.drawCircle(16, 16, 12);
s.graphics.drawRect(10, 9, 5, 14);
s.graphics.drawRect(17, 9, 5, 14);
s.graphics.endFill();
return (s);
}
}
}//package christmasmemory
Section 28
//PresentSprite (christmasmemory.PresentSprite)
package christmasmemory {
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import smileygamer.util.*;
public class PresentSprite extends SGSprite {
private var fType:int;
private var fBoard:Rectangle;
private var fMoving:Boolean;
private var fCloneRect:Rectangle;
private var fSize:int;
private static const STATE_PRESENT:String = "default";
private static const BIGSIZE:int = 75;
private static const STATE_HIDEITEM:String = "hideitem";
private static const STATE_SHOWITEM:String = "showitem";
private static const STATE_ITEM:String = "item";
private static const NORMALSIZE:int = 50;
private static var ItemsSmall:Class = PresentSprite_ItemsSmall;
private static var ItemsBig:Class = PresentSprite_ItemsBig;
private static var sPresentsBig:Array = BitmapUtil.splitImage(new PresentsBig(), BIGSIZE, BIGSIZE);
private static var sPresentsSmall:Array = BitmapUtil.splitImage(new PresentsSmall(), NORMALSIZE, NORMALSIZE);
private static var PresentsBig:Class = PresentSprite_PresentsBig;
private static var PresentsSmall:Class = PresentSprite_PresentsSmall;
private static var sItemsBig:Array = BitmapUtil.splitImage(new ItemsBig(), BIGSIZE, BIGSIZE);
private static var sItemsSmall:Array = BitmapUtil.splitImage(new ItemsSmall(), NORMALSIZE, NORMALSIZE);
public function PresentSprite(aType:int, aPresentType:int, aSize:int, aBoard:Rectangle){
var presentAnimation:ImageAnimation;
var itemAnimation:ImageAnimation;
var showItemAnimation:ImageTransitionAnimation;
var hideItemAnimation:ImageTransitionAnimation;
var present:Bitmap;
var item:Bitmap;
super();
fType = aType;
fSize = aSize;
fBoard = aBoard;
if (aSize == BIGSIZE){
present = (sPresentsBig[aPresentType] as Bitmap);
item = (sItemsBig[fType] as Bitmap);
presentAnimation = new ImageAnimation(present, true);
itemAnimation = new ImageAnimation(item, true);
showItemAnimation = new ImageTransitionAnimation(present, item, 24);
hideItemAnimation = new ImageTransitionAnimation(item, present, 24);
} else {
present = (sPresentsSmall[aPresentType] as Bitmap);
item = (sItemsSmall[fType] as Bitmap);
presentAnimation = new ImageAnimation(present, true);
itemAnimation = new ImageAnimation(item, true);
showItemAnimation = new ImageTransitionAnimation(present, item, 24);
hideItemAnimation = new ImageTransitionAnimation(item, present, 24);
};
addAnimation(STATE_PRESENT, presentAnimation);
addAnimation(STATE_ITEM, itemAnimation);
addAnimation(STATE_SHOWITEM, showItemAnimation);
addAnimation(STATE_HIDEITEM, hideItemAnimation);
state = STATE_PRESENT;
fCloneRect = new Rectangle(0, 0, fSize, fSize);
cacheAsBitmap = true;
}
public function containsPt(aX:Number, aY:Number):Boolean{
return ((((((((((aX > x)) && ((aY > y)))) && ((aX < (x + fSize))))) && ((aY < (y + fSize))))) || (((!((clonePos == null))) && (fCloneRect.contains(aX, aY))))));
}
public function locationChanged():void{
if (x < fBoard.x){
moveClone(fBoard.width, 0);
};
if ((x + fSize) > (fBoard.x + fBoard.width)){
moveClone(-(fBoard.width), 0);
};
if (y < fBoard.y){
moveClone(0, fBoard.height);
};
if ((y + fSize) > (fBoard.y + fBoard.height)){
moveClone(0, -(fBoard.height));
};
if (((!((clonePos == null))) && (fBoard.containsRect(fCloneRect)))){
x = (x + clonePos.x);
y = (y + clonePos.y);
clonePos = null;
};
}
private function moveClone(aX:Number, aY:Number):void{
if (clonePos == null){
clonePos = new Point(aX, aY);
};
fCloneRect.x = (x + aX);
fCloneRect.y = (y + aY);
}
public function get moving():Boolean{
return (fMoving);
}
public function isVisible():Boolean{
return ((((state == STATE_ITEM)) || ((state == STATE_SHOWITEM))));
}
public function get type():int{
return (fType);
}
public function set moving(aMoving:Boolean):void{
fMoving = aMoving;
if (!fMoving){
clonePos = null;
};
}
public function turn():void{
if ((((STATE_PRESENT == state)) || ((STATE_HIDEITEM == state)))){
state = STATE_SHOWITEM;
} else {
if ((((STATE_ITEM == state)) || ((STATE_SHOWITEM == state)))){
state = STATE_HIDEITEM;
};
};
}
override protected function nextState():String{
if (STATE_HIDEITEM == state){
return (STATE_PRESENT);
};
if (STATE_SHOWITEM == state){
return (STATE_ITEM);
};
return (STATE_PRESENT);
}
}
}//package christmasmemory
Section 29
//PresentSprite_ItemsBig (christmasmemory.PresentSprite_ItemsBig)
package christmasmemory {
import mx.core.*;
public class PresentSprite_ItemsBig extends BitmapAsset {
}
}//package christmasmemory
Section 30
//PresentSprite_ItemsSmall (christmasmemory.PresentSprite_ItemsSmall)
package christmasmemory {
import mx.core.*;
public class PresentSprite_ItemsSmall extends BitmapAsset {
}
}//package christmasmemory
Section 31
//PresentSprite_PresentsBig (christmasmemory.PresentSprite_PresentsBig)
package christmasmemory {
import mx.core.*;
public class PresentSprite_PresentsBig extends BitmapAsset {
}
}//package christmasmemory
Section 32
//PresentSprite_PresentsSmall (christmasmemory.PresentSprite_PresentsSmall)
package christmasmemory {
import mx.core.*;
public class PresentSprite_PresentsSmall extends BitmapAsset {
}
}//package christmasmemory
Section 33
//SaveData (christmasmemory.SaveData)
package christmasmemory {
import flash.net.*;
public class SaveData {
private static var fScoresObject:SharedObject = null;
private static var fHighscores:Array = [0, 0, 0, 0];
private static var fName:String;
private static var fSavedGame:Array = [null, null, null, null];
private static var fRank:Array = [0, 0, 0, 0];
private static var fAwards:Array = new Array(24);
private static var fLevel:Array = [1, 1, 1, 1];
public function SaveData(){
super();
}
public static function get name():String{
return (fName);
}
public static function saveGame(aDifficulty:int, aLevel:int, aScore:int, aTotalLife:int, aTotalTime:int, aAllThumbsUp:int, aFourThumbsUp:Boolean):void{
var saveGame:Object = new Object();
saveGame.level = aLevel;
saveGame.score = aScore;
saveGame.totalLife = aTotalLife;
saveGame.totalTime = aTotalTime;
saveGame.allThumbsUp = aAllThumbsUp;
saveGame.fourThumbsUp = aFourThumbsUp;
fSavedGame[aDifficulty] = saveGame;
writeScores();
}
public static function init():void{
var i:int;
while (i < fAwards.length) {
fAwards[i] = false;
i = (i + 1);
};
fScoresObject = SharedObject.getLocal("christmas-memory-data", "/");
if (fScoresObject.data.levels != null){
fHighscores = fScoresObject.data.scores;
fRank = fScoresObject.data.ranks;
fLevel = fScoresObject.data.levels;
fSavedGame = fScoresObject.data.savedgames;
fName = fScoresObject.data.name;
fAwards = fScoresObject.data.awards;
} else {
writeScores(true);
};
//unresolved jump
var _slot1 = e;
}
public static function set name(aName:String):void{
fName = aName;
writeScores();
}
public static function clearSavedGame(aDifficulty:int):void{
fSavedGame[aDifficulty] = null;
writeScores();
}
private static function writeScores(aFlush:Boolean=false):void{
if (fScoresObject != null){
fScoresObject.data.scores = fHighscores;
fScoresObject.data.ranks = fRank;
fScoresObject.data.levels = fLevel;
fScoresObject.data.savedgames = fSavedGame;
fScoresObject.data.name = fName;
fScoresObject.data.awards = fAwards;
if (aFlush){
fScoresObject.flush(500);
};
};
}
public static function getSavedGame(aDifficulty:int):Object{
var game:Object;
if (fSavedGame[aDifficulty] != null){
game = fSavedGame[aDifficulty];
return (game);
};
return (null);
}
public static function getStats(aDifficulty:int):Array{
return (new Array(fLevel[aDifficulty], fHighscores[aDifficulty], fRank[aDifficulty]));
}
public static function set awards(aAwards:Array):void{
fAwards = aAwards;
writeScores();
}
public static function endGame(aDifficulty:int, aLevel:int, aScore:int, aRank:int):void{
if (aScore >= fHighscores[aDifficulty]){
fLevel[aDifficulty] = aLevel;
fHighscores[aDifficulty] = aScore;
fRank[aDifficulty] = aRank;
writeScores();
};
}
public static function get awards():Array{
return (fAwards);
}
}
}//package christmasmemory
Section 34
//SoundManager (christmasmemory.SoundManager)
package christmasmemory {
import flash.events.*;
import flash.media.*;
public class SoundManager {
private static var Music:Class = SoundManager_Music;
private static var GameOver:Class = SoundManager_GameOver;
private static var Yes:Class = SoundManager_Yes;
private static var fSound:Boolean = true;
private static var Beep:Class = SoundManager_Beep;
private static var fApplause:Sound = (new Applause() as Sound);
private static var Applause:Class = SoundManager_Applause;
private static var fNo:Sound = (new No() as Sound);
private static var fLevelComplete:Sound = (new LevelComplete() as Sound);
private static var fBonus:Sound = (new Bonus() as Sound);
private static var fMusic:Sound = (new Music() as Sound);
private static var No:Class = SoundManager_No;
private static var fMusicChannel:SoundChannel;
private static var fYes:Sound = (new Yes() as Sound);
private static var fGameOver:Sound = (new GameOver() as Sound);
private static var fButtonSound:Sound = (new Beep() as Sound);
private static var LevelComplete:Class = SoundManager_LevelComplete;
private static var Bonus:Class = SoundManager_Bonus;
public function SoundManager(){
super();
}
public static function playGameOver():void{
if (fSound){
fGameOver.play();
};
}
public static function playMismatch():void{
if (fSound){
fNo.play();
};
}
public static function playBonus():void{
if (fSound){
fBonus.play();
};
}
public static function toggleSound():void{
sound = !(sound);
}
public static function get sound():Boolean{
return (fSound);
}
public static function playMusic():void{
var replay:Function;
replay = function (e:Event):void{
if (fMusic != null){
fMusicChannel = fMusic.play();
fMusicChannel.addEventListener(Event.SOUND_COMPLETE, replay);
};
};
if (((fSound) && ((fMusicChannel == null)))){
replay(null);
};
}
public static function set sound(aSound:Boolean):void{
fSound = aSound;
if (!fSound){
if (fMusicChannel != null){
fMusicChannel.stop();
};
} else {
fMusicChannel = null;
playMusic();
};
}
public static function playLevelComplete():void{
if (fSound){
fLevelComplete.play();
};
}
public static function playGameWon():void{
if (fSound){
fApplause.play();
};
}
public static function playMatch():void{
if (fSound){
fYes.play();
};
}
public static function playButton():void{
if (fSound){
fButtonSound.play();
};
}
}
}//package christmasmemory
Section 35
//SoundManager_Applause (christmasmemory.SoundManager_Applause)
package christmasmemory {
import mx.core.*;
public class SoundManager_Applause extends SoundAsset {
}
}//package christmasmemory
Section 36
//SoundManager_Beep (christmasmemory.SoundManager_Beep)
package christmasmemory {
import mx.core.*;
public class SoundManager_Beep extends SoundAsset {
}
}//package christmasmemory
Section 37
//SoundManager_Bonus (christmasmemory.SoundManager_Bonus)
package christmasmemory {
import mx.core.*;
public class SoundManager_Bonus extends SoundAsset {
}
}//package christmasmemory
Section 38
//SoundManager_GameOver (christmasmemory.SoundManager_GameOver)
package christmasmemory {
import mx.core.*;
public class SoundManager_GameOver extends SoundAsset {
}
}//package christmasmemory
Section 39
//SoundManager_LevelComplete (christmasmemory.SoundManager_LevelComplete)
package christmasmemory {
import mx.core.*;
public class SoundManager_LevelComplete extends SoundAsset {
}
}//package christmasmemory
Section 40
//SoundManager_Music (christmasmemory.SoundManager_Music)
package christmasmemory {
import mx.core.*;
public class SoundManager_Music extends SoundAsset {
}
}//package christmasmemory
Section 41
//SoundManager_No (christmasmemory.SoundManager_No)
package christmasmemory {
import mx.core.*;
public class SoundManager_No extends SoundAsset {
}
}//package christmasmemory
Section 42
//SoundManager_Yes (christmasmemory.SoundManager_Yes)
package christmasmemory {
import mx.core.*;
public class SoundManager_Yes extends SoundAsset {
}
}//package christmasmemory
Section 43
//TextBalloon (christmasmemory.TextBalloon)
package christmasmemory {
import flash.display.*;
public class TextBalloon extends Shape {
public function TextBalloon(aWidth:int, aHeight:int){
super();
graphics.beginFill(0xFFFFFF, 0.7);
graphics.lineStyle(2, 0x303030, 1);
graphics.drawRoundRect(0, 0, aWidth, aHeight, (aWidth / 4), (aWidth / 6));
graphics.endFill();
cacheAsBitmap = true;
}
}
}//package christmasmemory
Section 44
//TextFactory (christmasmemory.TextFactory)
package christmasmemory {
import flash.display.*;
import flash.text.*;
import flash.filters.*;
public class TextFactory {
public static const SIZE_LARGER:int = 48;
public static const COLOR_SELECTED:int = 1746233;
public static const SIZE_LARGE:int = 28;
public static const COLOR_DEFAULT:int = 14223111;
public static const SIZE_SMALL:int = 13;
public static const SIZE_NORMAL:int = 16;
public static const DEFAULT_FONT:String = "default";
public static const SIZE_MEDIUM:int = 22;
public static const SIZE_LARGEST:int = 64;
private static var DefaultFont:Class = TextFactory_DefaultFont;
public function TextFactory(){
super();
}
public static function createCopyrightTextField(aText:String, aColor:int=1746233):TextField{
var tf:TextField = new TextField();
var format:TextFormat = new TextFormat("Arial", 14, aColor);
format.bold = true;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.mouseEnabled = false;
tf.defaultTextFormat = format;
tf.multiline = false;
var glow:GlowFilter = new GlowFilter(0, 0.6, 4, 4);
var shadow:DropShadowFilter = new DropShadowFilter(1);
tf.filters = [glow, shadow];
tf.text = aText;
return (tf);
}
public static function createTextButton(aText:String, aSize:int=16, aColor:int=14223111, aSelectedColor:int=1746233, aFont:String="default"):SimpleButton{
var normal:TextField = createTextField(aSize, aColor, aFont);
normal.text = aText;
var selected:TextField = createTextField(aSize, aSelectedColor, aFont);
selected.text = aText;
var button:SimpleButton = new SimpleButton(normal, selected, selected, selected);
return (button);
}
private static function createFilters(aSize:int, aGlow:Boolean):Array{
var filters:Array = new Array();
switch (aSize){
case SIZE_SMALL:
case SIZE_NORMAL:
filters.push(new BevelFilter(1, 30, 0xFFFFFF, 1, 0, 0.8, 1.2, 1.2, 1, BitmapFilterQuality.HIGH));
filters.push(new DropShadowFilter(1, 45, 0, 1, 2, 2, 0.8, BitmapFilterQuality.HIGH));
if (aGlow){
filters.push(new GlowFilter(0xFFFFFF, 1, 8, 8, 2, BitmapFilterQuality.HIGH));
};
break;
case SIZE_MEDIUM:
case SIZE_LARGE:
case SIZE_LARGER:
filters.push(new BevelFilter(1, 30, 0xFFFFFF, 1, 0, 0.8, 2, 2, 1, BitmapFilterQuality.HIGH));
filters.push(new DropShadowFilter(2, 45, 0, 1, 2, 2, 0.8, BitmapFilterQuality.HIGH));
if (aGlow){
filters.push(new GlowFilter(0xFFFFFF, 1, 16, 16, 2, BitmapFilterQuality.HIGH));
};
break;
case SIZE_LARGEST:
filters.push(new BevelFilter(2, 30, 0xFFFFFF, 1, 0, 0.8, 3, 3, 1, BitmapFilterQuality.HIGH));
filters.push(new DropShadowFilter(3, 45, 0, 1, 3, 3, 0.8, BitmapFilterQuality.HIGH));
if (aGlow){
filters.push(new GlowFilter(0xFFFFFF, 1, 32, 32, 2, BitmapFilterQuality.HIGH));
};
break;
};
return (filters);
}
public static function createHelpTextField():TextField{
var tf:TextField = new TextField();
var format:TextFormat = new TextFormat("Arial", 14, 0x303030);
format.bold = true;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.mouseEnabled = false;
tf.defaultTextFormat = format;
tf.multiline = true;
return (tf);
}
public static function createTextField(aSize:int=16, aColor:int=14223111, aFont:String="default", aGlow:Boolean=false):TextField{
var tf:TextField = new TextField();
var format:TextFormat = new TextFormat(aFont, aSize, aColor);
format.letterSpacing = 1;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.mouseEnabled = false;
tf.embedFonts = true;
tf.defaultTextFormat = format;
tf.antiAliasType = AntiAliasType.ADVANCED;
tf.multiline = false;
tf.filters = createFilters(aSize, aGlow);
return (tf);
}
public static function createEditableTextField(aSize:int=16, aColor:int=14223111, aFont:String="default"):TextField{
var tf:TextField = createTextField(aSize, aColor, aFont);
tf.autoSize = TextFieldAutoSize.NONE;
tf.defaultTextFormat.align = TextFormatAlign.CENTER;
tf.mouseEnabled = true;
tf.type = TextFieldType.INPUT;
return (tf);
}
}
}//package christmasmemory
Section 45
//TextFactory_DefaultFont (christmasmemory.TextFactory_DefaultFont)
package christmasmemory {
import mx.core.*;
public class TextFactory_DefaultFont extends FontAsset {
}
}//package christmasmemory
Section 46
//ThumbsUpLayer (christmasmemory.ThumbsUpLayer)
package christmasmemory {
import flash.display.*;
import flash.filters.*;
public class ThumbsUpLayer extends Sprite {
private var fCount:int;
private var fMax:int;
private static var ThumbsUp:Class = ThumbsUpLayer_ThumbsUp;
public function ThumbsUpLayer(aMax:int){
var thumbsup:DisplayObject;
var shadow:DropShadowFilter;
var innershadow:DropShadowFilter;
super();
fMax = aMax;
fCount = 0;
var i:int;
while (i < 5) {
thumbsup = new ThumbsUp();
thumbsup.x = ((i * 40) - 5);
thumbsup.alpha = 0.3;
shadow = new DropShadowFilter(2);
shadow.alpha = 0.6;
shadow.quality = BitmapFilterQuality.HIGH;
innershadow = new DropShadowFilter(1, -135);
innershadow.quality = BitmapFilterQuality.HIGH;
innershadow.alpha = 0.8;
innershadow.inner = true;
thumbsup.filters = [innershadow, shadow];
addChild(thumbsup);
i++;
};
}
public function set count(aCount:int):void{
fCount = aCount;
if (fCount >= int((fMax / 20))){
getChildAt(0).alpha = 1;
};
if (fCount >= (fMax / 6)){
getChildAt(1).alpha = 1;
};
if (fCount >= ((2 * fMax) / 6)){
getChildAt(2).alpha = 1;
};
if (fCount >= ((3 * fMax) / 6)){
getChildAt(3).alpha = 1;
};
if (fCount >= ((4 * fMax) / 6)){
getChildAt(4).alpha = 1;
};
}
public function get rank():int{
var rank:int;
if (fCount >= int((fMax / 20))){
rank++;
};
if (fCount >= (fMax / 6)){
rank++;
};
if (fCount >= ((2 * fMax) / 6)){
rank++;
};
if (fCount >= ((3 * fMax) / 6)){
rank++;
};
if (fCount >= ((4 * fMax) / 6)){
rank++;
};
return (rank);
}
public function get count():int{
return (fCount);
}
}
}//package christmasmemory
Section 47
//ThumbsUpLayer_ThumbsUp (christmasmemory.ThumbsUpLayer_ThumbsUp)
package christmasmemory {
import mx.core.*;
public class ThumbsUpLayer_ThumbsUp extends BitmapAsset {
}
}//package christmasmemory
Section 48
//TitleButton (christmasmemory.TitleButton)
package christmasmemory {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.filters.*;
public class TitleButton extends SimpleButton {
private var fRadius:int;
private static const DIFFWIDTH:int = 175;
private static const COLOR:int = 1746233;
private static const WIDTH:int = 185;
private static const HEIGHT:int = 30;
private static const DIFFHEIGHT:int = 50;
private static const BIGWIDTH:int = 215;
private static const BIGHEIGHT:int = 70;
private static const COLOR_SEL:int = 14223111;
public function TitleButton(aTitle:String, aTitle2:String=null, aBigSize:Boolean=false, aSelTitle:String=null, aSelTitle2:String=null){
var butwidth:int;
var playSound:Function;
var tf2:TextField;
var tfsel2:TextField;
var aTitle = aTitle;
var aTitle2 = aTitle2;
var aBigSize = aBigSize;
var aSelTitle = aSelTitle;
var aSelTitle2 = aSelTitle2;
playSound = function (e:Event):void{
SoundManager.playButton();
};
var butheight:int = (aBigSize) ? BIGHEIGHT : ((aTitle2)!=null) ? DIFFHEIGHT : HEIGHT;
fRadius = (butheight / 2);
butwidth = (aBigSize) ? BIGWIDTH : ((aTitle2)!=null) ? DIFFWIDTH : WIDTH;
var normal:Sprite = new Sprite();
var background:Shape = createBackground(butwidth, butheight);
normal.addChild(background);
var textSize:int = (aBigSize) ? TextFactory.SIZE_LARGER : TextFactory.SIZE_NORMAL;
var tf:TextField = TextFactory.createTextField(textSize);
tf.text = aTitle;
tf.x = ((normal.width - tf.width) / 2);
tf.y = ((normal.height - tf.height) / 2);
if (aBigSize){
tf.y = (tf.y - 2);
};
normal.addChild(tf);
if (aTitle2 != null){
tf2 = TextFactory.createTextField(textSize);
tf2.text = aTitle2;
tf2.x = ((normal.width - tf2.width) / 2);
tf.y = (tf.y - ((textSize / 2) + 2));
tf2.y = ((((normal.height - tf2.height) / 2) + (textSize / 2)) + 1);
normal.addChild(tf2);
};
normal.cacheAsBitmap = true;
var selected:Sprite = new Sprite();
selected.addChild(createBackground(butwidth, butheight, true));
var tfsel:TextField = TextFactory.createTextField(textSize, TextFactory.COLOR_SELECTED);
tfsel.text = ((aSelTitle)!=null) ? aSelTitle : aTitle;
tfsel.x = ((selected.width - tfsel.width) / 2);
tfsel.y = ((selected.height - tfsel.height) / 2);
if (aBigSize){
tfsel.y = (tfsel.y - 2);
};
selected.addChild(tfsel);
if (aTitle2 != null){
tfsel2 = TextFactory.createTextField(textSize, TextFactory.COLOR_SELECTED);
tfsel2.text = ((aSelTitle2)!=null) ? aSelTitle2 : aTitle2;
tfsel2.x = ((selected.width - tfsel2.width) / 2);
tfsel.y = (tfsel.y - ((textSize / 2) + 2));
tfsel2.y = ((((selected.height - tfsel2.height) / 2) + (textSize / 2)) + 1);
selected.addChild(tfsel2);
};
selected.cacheAsBitmap = true;
super(normal, selected, selected, background);
var bevel:BevelFilter = new BevelFilter(4, 30, 0xFFFFFF, 1, 0, 0.8, 4, 4, 1, BitmapFilterQuality.HIGH);
var shadow:DropShadowFilter = new DropShadowFilter(4);
shadow.alpha = 0.8;
shadow.quality = BitmapFilterQuality.HIGH;
filters = [bevel, shadow];
addEventListener(MouseEvent.MOUSE_OVER, playSound);
}
private function createBackground(aWidth:int, aHeight:int, aSelected:Boolean=false):Shape{
var bg:Shape = new Shape();
bg.graphics.beginFill((aSelected) ? COLOR_SEL : COLOR);
bg.graphics.drawCircle(fRadius, fRadius, fRadius);
bg.graphics.endFill();
bg.graphics.beginFill((aSelected) ? COLOR_SEL : COLOR);
bg.graphics.drawRect((aHeight / 2), 0, aWidth, aHeight);
bg.graphics.endFill();
return (bg);
}
override public function get width():Number{
return ((super.width - fRadius));
}
}
}//package christmasmemory
Section 49
//TitleScreen (christmasmemory.TitleScreen)
package christmasmemory {
import flash.events.*;
import smileygamer.*;
import flash.geom.*;
import flash.display.*;
import flash.text.*;
import smileygamer.util.*;
import flash.filters.*;
public class TitleScreen extends Sprite implements ILogic {
private var fHardButton:SimpleButton;
private var fMoreGamesButton:SimpleButton;
private var fPlayButton:SimpleButton;
private var fNormalButton:SimpleButton;
private var fTitle:Sprite;
private var fChosenDiff:int;
private var fCreditsButton:SimpleButton;
private var fContinueLayer:Sprite;
private var fAddToSiteButton:SimpleButton;
private var fTree:DisplayObject;
private var fState:int;// = 0
private var fSavedGame:Boolean;
private var fVeryHardButton:SimpleButton;
private var fEasyButton:SimpleButton;
private var fHighscoresButton:SimpleButton;
private var fCreditsLayer:Sprite;
private var fBestResultLayer:Sprite;
private var fPresentsButton:SimpleButton;
private var fGame:ChristmasMemory;
private static const STATE_SHOWING:int = 1;
private static const STATE_INVALID:int = 0;
private static var SoundOnImage:Class = TitleScreen_SoundOnImage;
private static var ThumbsUp:Class = TitleScreen_ThumbsUp;
private static var SoundOffImage:Class = TitleScreen_SoundOffImage;
private static var SmileySmall:Class = TitleScreen_SmileySmall;
private static var Tree:Class = TitleScreen_Tree;
private static var Presents:Class = TitleScreen_Presents;
public function TitleScreen(aGame:ChristmasMemory){
super();
fGame = aGame;
addEventListener(Event.ADDED, added);
addEventListener(Event.REMOVED, removed);
}
public function added(aEvent:Event):void{
removeEventListener(Event.ADDED, added);
init();
}
private function showBestResult(e:Event):void{
var diff:int;
var thumbsup:DisplayObject;
var shadow:DropShadowFilter;
var innershadow:DropShadowFilter;
if (e.target == fEasyButton){
diff = ChristmasMemory.DIFF_EASY;
};
if (e.target == fNormalButton){
diff = ChristmasMemory.DIFF_NORMAL;
};
if (e.target == fHardButton){
diff = ChristmasMemory.DIFF_HARD;
};
if (e.target == fVeryHardButton){
diff = ChristmasMemory.DIFF_VERYHARD;
};
var stats:Array = SaveData.getStats(diff);
fBestResultLayer = new Sprite();
var balloon:TextBalloon = new TextBalloon(108, 108);
fBestResultLayer.addChild(balloon);
var tf:TextField = TextFactory.createHelpTextField();
tf.text = ((("Best Result\n\nLevel: " + stats[0]) + "\nScore: ") + stats[1]);
tf.x = 8;
tf.y = 5;
fBestResultLayer.addChild(tf);
var i:int;
while (i < 5) {
thumbsup = new ThumbsUp();
thumbsup.x = ((i * 20) + 5);
thumbsup.y = 75;
if (i >= stats[2]){
thumbsup.alpha = 0.3;
};
shadow = new DropShadowFilter(2);
shadow.alpha = 0.6;
shadow.quality = BitmapFilterQuality.HIGH;
innershadow = new DropShadowFilter(1, -135);
innershadow.quality = BitmapFilterQuality.HIGH;
innershadow.alpha = 0.6;
innershadow.inner = true;
thumbsup.filters = [innershadow, shadow];
fBestResultLayer.addChild(thumbsup);
i++;
};
fBestResultLayer.x = 210;
fBestResultLayer.y = 140;
new FadeAnimation(fBestResultLayer, 5, FadeAnimation.MODE_FADE_IN);
addChild(fBestResultLayer);
}
private function hideBestResult(e:Event):void{
new FadeAnimation(fBestResultLayer, 5, FadeAnimation.MODE_FADE_OUT_REMOVE);
}
private function init():void{
var border:GlowFilter;
var smileysel:DisplayObject;
var glow:GlowFilter;
var smileyButton:SimpleButton;
var addgame:TextField;
var addgameSel:TextField;
var agButton:SimpleButton;
var copyright:TextField;
var copyrightSel:TextField;
var crButton:SimpleButton;
fTitle = new Sprite();
var title1:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
title1.text = "Christmas";
fTitle.addChild(title1);
var title2:TextField = TextFactory.createTextField(TextFactory.SIZE_LARGER, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
title2.text = "Memory";
title2.x = ((title1.width - title2.width) / 2);
title2.y = 60;
fTitle.addChild(title2);
fTitle.x = 150;
fTitle.y = 5;
addChild(fTitle);
fTree = new Tree();
fTree.x = 10;
fTree.y = 15;
addChild(fTree);
var presents:Sprite = new Sprite();
presents.addChild(new Presents());
var prtf:TextField = TextFactory.createTextField(TextFactory.SIZE_SMALL, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
prtf.text = "Presents";
prtf.x = ((presents.width - prtf.width) / 2);
prtf.y = (presents.height - 40);
presents.addChild(prtf);
if (Awards.hasNewAwards){
border = new GlowFilter(0xFF00, 1, 10, 10, 6, BitmapFilterQuality.LOW);
presents.filters = [border];
};
var presentssel:Sprite = new Sprite();
presentssel.addChild(new Presents());
var prtfsel:TextField = TextFactory.createTextField(TextFactory.SIZE_SMALL, TextFactory.COLOR_DEFAULT, TextFactory.DEFAULT_FONT, true);
prtfsel.text = "Presents";
prtfsel.x = prtf.x;
prtfsel.y = prtf.y;
presentssel.addChild(prtfsel);
var bordersel:GlowFilter = new GlowFilter(0xFF0000, 1, 10, 10, 6, BitmapFilterQuality.LOW);
presentssel.filters = [bordersel];
fPresentsButton = new SimpleButton(presents, presentssel, presentssel, presentssel);
fPresentsButton.x = 145;
fPresentsButton.y = 175;
addChild(fPresentsButton);
fPresentsButton.addEventListener(MouseEvent.CLICK, showAwards);
var soundBtn:SimpleButton = createSoundToggleButton();
soundBtn.x = 10;
soundBtn.y = 10;
addChild(soundBtn);
var innershadow2:DropShadowFilter = new DropShadowFilter(1, -135);
innershadow2.alpha = 0.8;
innershadow2.quality = BitmapFilterQuality.HIGH;
innershadow2.inner = true;
var smallshadow:DropShadowFilter = new DropShadowFilter(2);
smallshadow.alpha = 0.8;
smallshadow.quality = BitmapFilterQuality.HIGH;
var smiley:DisplayObject = new SmileySmall();
smiley.filters = [innershadow2, smallshadow];
if (((!(ChristmasMemory.BFG)) && (!(fGame.isHomeSite())))){
smileysel = new SmileySmall();
glow = new GlowFilter(0xFF0000, 1, 8, 8, 4, BitmapFilterQuality.LOW);
smileysel.filters = [smallshadow, glow];
smileyButton = new SimpleButton(smiley, smileysel, smileysel, smileysel);
smileyButton.x = 5;
smileyButton.y = (355 - smileyButton.height);
if (!fGame.isHomeSite()){
smileyButton.addEventListener(MouseEvent.CLICK, showHome);
};
addChild(smileyButton);
} else {
smiley.x = 5;
smiley.y = (355 - smiley.height);
addChild(smiley);
};
fPlayButton = new TitleButton("PLAY", null, true);
fPlayButton.x = (500 - fPlayButton.width);
fPlayButton.y = 140;
addChild(fPlayButton);
fPlayButton.addEventListener(MouseEvent.CLICK, play);
fCreditsButton = new TitleButton("CREDITS");
fCreditsButton.x = (500 - fCreditsButton.width);
fCreditsButton.y = 230;
addChild(fCreditsButton);
fCreditsButton.addEventListener(MouseEvent.CLICK, credits);
if (!ChristmasMemory.BFG){
if (ChristmasMemory.SPONSORED){
} else {
fMoreGamesButton = new TitleButton("MORE GAMES");
fMoreGamesButton.addEventListener(MouseEvent.CLICK, moreGames);
fMoreGamesButton.x = (500 - fMoreGamesButton.width);
fMoreGamesButton.y = 280;
addChild(fMoreGamesButton);
addgame = TextFactory.createCopyrightTextField("Add this game to your site");
addgameSel = TextFactory.createCopyrightTextField("Add this game to your site", TextFactory.COLOR_DEFAULT);
agButton = new SimpleButton(addgame, addgameSel, addgameSel, addgameSel);
agButton.addEventListener(MouseEvent.CLICK, showGamesForSite);
agButton.x = 70;
agButton.y = 336;
addChild(agButton);
};
} else {
fPlayButton.y = 135;
fCreditsButton.y = 225;
};
var cologo:Sprite = CobrandingUtil.getSmallLogo();
if (cologo != null){
fCreditsButton.y = 220;
fMoreGamesButton.y = 260;
cologo.y = 295;
cologo.x = (415 - (cologo.width / 2));
addChild(cologo);
};
if (ChristmasMemory.SPONSORED){
};
fEasyButton = new TitleButton("EASY", "8 PAIRS");
fEasyButton.x = 510;
fEasyButton.y = 100;
addChild(fEasyButton);
fEasyButton.addEventListener(MouseEvent.CLICK, chooseDiff);
fEasyButton.addEventListener(MouseEvent.MOUSE_OVER, showBestResult);
fEasyButton.addEventListener(MouseEvent.MOUSE_OUT, hideBestResult);
fNormalButton = new TitleButton("NORMAL", "12 PAIRS");
fNormalButton.x = 510;
fNormalButton.y = 160;
addChild(fNormalButton);
fNormalButton.addEventListener(MouseEvent.CLICK, chooseDiff);
fNormalButton.addEventListener(MouseEvent.MOUSE_OVER, showBestResult);
fNormalButton.addEventListener(MouseEvent.MOUSE_OUT, hideBestResult);
fHardButton = new TitleButton("HARD", "18 PAIRS");
fHardButton.addEventListener(MouseEvent.CLICK, chooseDiff);
fHardButton.addEventListener(MouseEvent.MOUSE_OVER, showBestResult);
fHardButton.addEventListener(MouseEvent.MOUSE_OUT, hideBestResult);
fHardButton.x = 510;
fHardButton.y = 220;
addChild(fHardButton);
if (ChristmasMemory.KAISERGAMES){
fVeryHardButton = new TitleButton("VERY HARD", "24 PAIRS", false, "Only at", "SmileyGamer");
fVeryHardButton.addEventListener(MouseEvent.CLICK, showGameOnSite);
} else {
fVeryHardButton = new TitleButton("VERY HARD", "24 PAIRS");
fVeryHardButton.addEventListener(MouseEvent.CLICK, chooseDiff);
fVeryHardButton.addEventListener(MouseEvent.MOUSE_OVER, showBestResult);
fVeryHardButton.addEventListener(MouseEvent.MOUSE_OUT, hideBestResult);
};
fVeryHardButton.x = 510;
fVeryHardButton.y = 280;
addChild(fVeryHardButton);
if (!ChristmasMemory.BFG){
copyright = TextFactory.createCopyrightTextField("Copyright 2009 SmileyGamer");
copyrightSel = TextFactory.createCopyrightTextField("Copyright 2009 SmileyGamer", TextFactory.COLOR_DEFAULT);
crButton = new SimpleButton(copyright, copyrightSel, copyrightSel, copyrightSel);
crButton.addEventListener(MouseEvent.CLICK, showHome);
crButton.x = (490 - crButton.width);
crButton.y = 336;
addChild(crButton);
} else {
copyright = TextFactory.createCopyrightTextField("Copyright 2009 SmileyGamer");
copyright.x = 100;
copyright.y = 336;
addChild(copyright);
};
fState = STATE_SHOWING;
showTitle();
showMainButtons();
}
private function showAwards(e:Event):void{
var showAwardsScreen:Function;
var e = e;
showAwardsScreen = function ():void{
fGame.showAwardsScreen();
};
if (fPlayButton.x < 500){
hideMainButtons();
};
if (fEasyButton.x < 500){
hideDifficultyButtons();
};
hideTitleScreen(showAwardsScreen);
}
private function credits(e:Event):void{
hideMainButtons();
fCreditsLayer = new Sprite();
fCreditsLayer.y = 90;
var balloon:TextBalloon = new TextBalloon(400, 200);
fCreditsLayer.addChild(balloon);
var tf:TextField = TextFactory.createHelpTextField();
if (ChristmasMemory.BFG){
tf.text = ("Christmas Memory version 1.0.3 by SmileyGamer\n\nGame concept by\nJochen De Schepper and " + "Els Brunson\n\nCoding by\nJochen De Schepper\n\nArtwork by\nndesign-studio and Jochen De Schepper");
} else {
tf.text = ("Christmas Memory version 1.0.3 by SmileyGamer\n\nGame concept by\nJochen De Schepper and " + "Els Brunson\n\nCoding by\nJochen De Schepper\n\nArtwork by\nndesign-studio.com and Jochen De Schepper");
};
tf.x = (balloon.x + 20);
tf.y = (balloon.y + 15);
fCreditsLayer.addChild(tf);
new MoveAnimation(fCreditsLayer, new Point(510, fCreditsLayer.y), new Point((250 - (fCreditsLayer.width / 2)), fCreditsLayer.y), 15, InterpolationUtil.TYPE_COSINE, 20);
addChild(fCreditsLayer);
fCreditsLayer.addEventListener(MouseEvent.CLICK, hideCredits);
}
private function showHighscores(e:Event):void{
fGame.showHighscoresPage();
}
public function doLogic():void{
}
private function hideCredits(e:Event):void{
var anim:MoveAnimation = new MoveAnimation(fCreditsLayer, new Point((490 - fCreditsLayer.width), fCreditsLayer.y), new Point(510, fCreditsLayer.y), 15, InterpolationUtil.TYPE_COSINE, 0, true);
anim.addCallback(showMainButtons);
}
private function showGameOnSite(e:Event):void{
SmileyGamer.showGameAtHome();
}
private function createSoundToggleButton():SimpleButton{
var soundOn:DisplayObject;
var soundOff:DisplayObject;
var button:SimpleButton;
var toggleSound:Function;
var setButton:Function = function ():void{
if (SoundManager.sound){
button.overState = soundOn;
button.downState = soundOn;
button.upState = soundOn;
button.hitTestState = soundOn;
} else {
button.overState = soundOff;
button.downState = soundOff;
button.upState = soundOff;
button.hitTestState = soundOff;
};
};
toggleSound = function (e:Event):void{
SoundManager.toggleSound();
setButton();
};
soundOn = new SoundOnImage();
soundOff = new SoundOffImage();
button = new SimpleButton();
setButton();
button.addEventListener(MouseEvent.CLICK, toggleSound);
var soundborder:GlowFilter = new GlowFilter(0xFFFFFF, 1, 2, 2, 3, BitmapFilterQuality.LOW);
button.filters = [soundborder];
return (button);
}
private function play(e:Event):void{
hideMainButtons();
showDifficultyButtons();
}
private function chooseDiff(e:Event):void{
hideDifficultyButtons();
if (e.target == fEasyButton){
fChosenDiff = ChristmasMemory.DIFF_EASY;
};
if (e.target == fNormalButton){
fChosenDiff = ChristmasMemory.DIFF_NORMAL;
};
if (e.target == fHardButton){
fChosenDiff = ChristmasMemory.DIFF_HARD;
};
if (e.target == fVeryHardButton){
fChosenDiff = ChristmasMemory.DIFF_VERYHARD;
};
var params:Object = SaveData.getSavedGame(fChosenDiff);
if (params != null){
showContinueLayer(params);
} else {
fSavedGame = false;
startGame();
};
}
private function hideTitleScreen(aNextFunction:Function):void{
var anim:MoveAnimation = new MoveAnimation(fTitle, new Point(fTitle.x, fTitle.y), new Point(fTitle.x, -(fTitle.height)), 15, InterpolationUtil.TYPE_COSINE, 10);
new MoveAnimation(fTree, new Point(fTree.x, fTree.y), new Point((-10 - fTree.width), fTree.y), 15, InterpolationUtil.TYPE_COSINE, 10);
new MoveAnimation(fPresentsButton, new Point(fPresentsButton.x, fPresentsButton.y), new Point((-10 - fPresentsButton.width), fPresentsButton.y), 15, InterpolationUtil.TYPE_COSINE, 10);
anim.addCallback(aNextFunction);
}
private function showDifficultyButtons():void{
new MoveAnimation(fEasyButton, new Point(510, fEasyButton.y), new Point((500 - fEasyButton.width), fEasyButton.y), 15, InterpolationUtil.TYPE_COSINE, 20);
new MoveAnimation(fNormalButton, new Point(510, fNormalButton.y), new Point((500 - fNormalButton.width), fNormalButton.y), 15, InterpolationUtil.TYPE_COSINE, 22);
new MoveAnimation(fHardButton, new Point(510, fHardButton.y), new Point((500 - fHardButton.width), fHardButton.y), 15, InterpolationUtil.TYPE_COSINE, 24);
new MoveAnimation(fVeryHardButton, new Point(510, fVeryHardButton.y), new Point((500 - fVeryHardButton.width), fVeryHardButton.y), 15, InterpolationUtil.TYPE_COSINE, 26);
}
private function hideDifficultyButtons():void{
new MoveAnimation(fEasyButton, new Point((500 - fEasyButton.width), fEasyButton.y), new Point(510, fEasyButton.y), 15, InterpolationUtil.TYPE_COSINE, 6);
new MoveAnimation(fNormalButton, new Point((500 - fNormalButton.width), fNormalButton.y), new Point(510, fNormalButton.y), 15, InterpolationUtil.TYPE_COSINE, 4);
new MoveAnimation(fHardButton, new Point((500 - fHardButton.width), fHardButton.y), new Point(510, fHardButton.y), 15, InterpolationUtil.TYPE_COSINE, 2);
new MoveAnimation(fVeryHardButton, new Point((500 - fVeryHardButton.width), fVeryHardButton.y), new Point(510, fVeryHardButton.y), 15, InterpolationUtil.TYPE_COSINE);
}
private function showMainButtons():void{
new MoveAnimation(fPlayButton, new Point(510, fPlayButton.y), new Point((500 - fPlayButton.width), fPlayButton.y), 15, InterpolationUtil.TYPE_COSINE);
if (fHighscoresButton != null){
new MoveAnimation(fHighscoresButton, new Point(510, fHighscoresButton.y), new Point((500 - fHighscoresButton.width), fHighscoresButton.y), 15, InterpolationUtil.TYPE_COSINE, 2);
};
new MoveAnimation(fCreditsButton, new Point(510, fCreditsButton.y), new Point((500 - fCreditsButton.width), fCreditsButton.y), 15, InterpolationUtil.TYPE_COSINE, 4);
if (fMoreGamesButton != null){
new MoveAnimation(fMoreGamesButton, new Point(510, fMoreGamesButton.y), new Point((500 - fMoreGamesButton.width), fMoreGamesButton.y), 15, InterpolationUtil.TYPE_COSINE, 6);
};
if (fAddToSiteButton != null){
new MoveAnimation(fAddToSiteButton, new Point(510, fAddToSiteButton.y), new Point((500 - fAddToSiteButton.width), fAddToSiteButton.y), 15, InterpolationUtil.TYPE_COSINE, 8);
};
}
private function hideContinueLayer():void{
var anim:MoveAnimation;
if (ChristmasMemory.SPONSORED){
anim = new MoveAnimation(fContinueLayer, new Point((500 - fContinueLayer.getChildAt(0).width), 100), new Point(510, 100), 15, InterpolationUtil.TYPE_COSINE, 0, true);
} else {
anim = new MoveAnimation(fContinueLayer, new Point(fContinueLayer.x, fContinueLayer.y), new Point(510, fContinueLayer.y), 15, InterpolationUtil.TYPE_COSINE, 0, true);
};
}
private function showTitle():void{
new MoveAnimation(fTitle, new Point(fTitle.x, -(fTitle.height)), new Point(fTitle.x, fTitle.y), 15, InterpolationUtil.TYPE_COSINE);
new MoveAnimation(fTree, new Point((-10 - fTree.width), fTree.y), new Point(fTree.x, fTree.y), 15, InterpolationUtil.TYPE_COSINE);
new MoveAnimation(fPresentsButton, new Point(fPresentsButton.x, (-10 - fPresentsButton.height)), new Point(fPresentsButton.x, fPresentsButton.y), 15, InterpolationUtil.TYPE_COSINE);
}
private function showGamesForSite(e:Event):void{
SmileyGamer.showFreeContent();
}
private function hideMainButtons():void{
new MoveAnimation(fPlayButton, new Point((500 - fPlayButton.width), fPlayButton.y), new Point(510, fPlayButton.y), 15, InterpolationUtil.TYPE_COSINE, 8);
if (fHighscoresButton != null){
new MoveAnimation(fHighscoresButton, new Point((500 - fHighscoresButton.width), fHighscoresButton.y), new Point(510, fHighscoresButton.y), 15, InterpolationUtil.TYPE_COSINE, 6);
};
new MoveAnimation(fCreditsButton, new Point((500 - fCreditsButton.width), fCreditsButton.y), new Point(510, fCreditsButton.y), 15, InterpolationUtil.TYPE_COSINE, 4);
if (fMoreGamesButton != null){
new MoveAnimation(fMoreGamesButton, new Point((500 - fMoreGamesButton.width), fMoreGamesButton.y), new Point(510, fMoreGamesButton.y), 15, InterpolationUtil.TYPE_COSINE, 2);
};
if (fAddToSiteButton != null){
new MoveAnimation(fAddToSiteButton, new Point((500 - fAddToSiteButton.width), fAddToSiteButton.y), new Point(510, fAddToSiteButton.y), 15, InterpolationUtil.TYPE_COSINE);
};
}
public function removed(aEvent:Event):void{
}
private function moreGames(e:Event):void{
fGame.showSponsorSite();
}
private function showContinueLayer(aSaveGame:Object):void{
var continueGame:Function;
var newGame:Function;
var aSaveGame = aSaveGame;
continueGame = function (e:Event):void{
fSavedGame = true;
hideContinueLayer();
startGame();
};
newGame = function (e:Event):void{
fSavedGame = false;
hideContinueLayer();
startGame();
};
fContinueLayer = new Sprite();
var balloon:TextBalloon = new TextBalloon(160, 80);
balloon.x = 15;
fContinueLayer.addChild(balloon);
var tf:TextField = TextFactory.createHelpTextField();
tf.text = ((((("The game was last\nsaved in level " + aSaveGame.level) + ".\n") + "You can continue\nwith ") + aSaveGame.score) + " points.");
tf.x = (balloon.x + 8);
tf.y = (balloon.y + 5);
fContinueLayer.addChild(tf);
var continueButton:SimpleButton = new TitleButton("Continue");
continueButton.y = 95;
fContinueLayer.addChild(continueButton);
continueButton.addEventListener(MouseEvent.CLICK, continueGame);
var newButton:SimpleButton = new TitleButton("New Game");
newButton.y = 145;
fContinueLayer.addChild(newButton);
newButton.addEventListener(MouseEvent.CLICK, newGame);
if (ChristmasMemory.SPONSORED){
new MoveAnimation(fContinueLayer, new Point(510, 100), new Point((500 - newButton.width), 100), 15, InterpolationUtil.TYPE_COSINE, 20);
} else {
new MoveAnimation(fContinueLayer, new Point(510, 130), new Point((500 - newButton.width), 130), 15, InterpolationUtil.TYPE_COSINE, 20);
};
addChild(fContinueLayer);
}
private function startGame():void{
var showGame:Function;
showGame = function ():void{
fGame.showGameScreen(fChosenDiff, fSavedGame);
};
hideTitleScreen(showGame);
}
private function showHome(e:Event):void{
fGame.showSGSite();
}
}
}//package christmasmemory
Section 50
//TitleScreen_Presents (christmasmemory.TitleScreen_Presents)
package christmasmemory {
import mx.core.*;
public class TitleScreen_Presents extends BitmapAsset {
}
}//package christmasmemory
Section 51
//TitleScreen_SmileySmall (christmasmemory.TitleScreen_SmileySmall)
package christmasmemory {
import mx.core.*;
public class TitleScreen_SmileySmall extends BitmapAsset {
}
}//package christmasmemory
Section 52
//TitleScreen_SoundOffImage (christmasmemory.TitleScreen_SoundOffImage)
package christmasmemory {
import mx.core.*;
public class TitleScreen_SoundOffImage extends BitmapAsset {
}
}//package christmasmemory
Section 53
//TitleScreen_SoundOnImage (christmasmemory.TitleScreen_SoundOnImage)
package christmasmemory {
import mx.core.*;
public class TitleScreen_SoundOnImage extends BitmapAsset {
}
}//package christmasmemory
Section 54
//TitleScreen_ThumbsUp (christmasmemory.TitleScreen_ThumbsUp)
package christmasmemory {
import mx.core.*;
public class TitleScreen_ThumbsUp extends BitmapAsset {
}
}//package christmasmemory
Section 55
//TitleScreen_Tree (christmasmemory.TitleScreen_Tree)
package christmasmemory {
import mx.core.*;
public class TitleScreen_Tree extends BitmapAsset {
}
}//package christmasmemory
Section 56
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var cpmstarLoader:Loader;
private var contentspotid:String;
public function AdLoader(contentspotid:String){
super();
this.contentspotid = contentspotid;
addEventListener(Event.ADDED, addedHandler);
}
private function dispatchHandler(event:Event):void{
dispatchEvent(event);
}
private function addedHandler(event:Event):void{
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
var cpmstarViewSWFUrl:String = "http://server.cpmstar.com/adviewas3.swf";
var container:DisplayObjectContainer = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((cpmstarViewSWFUrl + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
}
}//package CPMStar
Section 57
//MochiAd (mochi.as3.MochiAd)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public function MochiAd(){
super();
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showClickAwayAd(options:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = options;
var DEFAULTS:Object = {ad_timeout:5500, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (width:Number, height:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
chk["onEnterFrame"] = function ():void{
var total:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var ad_clip:Object = this.parent._mochiad_ctr;
var elapsed:Number = (getTimer() - this.started);
var finished:Boolean;
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
finished = true;
chk.started = getTimer();
} else {
if (elapsed > chk.ad_timeout){
options.ad_failed();
finished = true;
};
};
};
if (this.root == null){
finished = true;
};
if (finished){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(server:String):String{
var hostname:String = server.split("/")[2].split(":")[0];
if (Security.sandboxType == "application"){
return (hostname);
};
Security.allowDomain("*");
Security.allowDomain(hostname);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(hostname);
return (hostname);
}
public static function unload(clip:Object):Boolean{
if (((clip.clip) && (clip.clip._mochiad))){
clip = clip.clip;
};
if (clip.origFrameRate != undefined){
clip.stage.frameRate = clip.origFrameRate;
};
if (!clip._mochiad){
return (false);
};
if (clip._mochiad._containerLCName != undefined){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"unload"});
};
if (clip._mochiad.onUnload){
clip._mochiad.onUnload();
};
delete clip._mochiad_loaded;
delete clip._mochiad;
return (true);
}
public static function showInterLevelAd(options:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = options;
var DEFAULTS:Object = {ad_timeout:5500, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (width:Number, height:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (p > 0){
this.parent.alpha = (p * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (msec:Number):void{
var _chk:Object = mc._mochiad_wait;
_chk.server_control = true;
_chk.showing = true;
_chk.started = getTimer();
_chk.ad_msec = (msec - 250);
};
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
chk["onEnterFrame"] = function ():void{
var total:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var ad_clip:Object = this.parent._mochiad_ctr;
var elapsed:Number = (getTimer() - this.started);
var finished:Boolean;
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (elapsed > chk.ad_timeout){
options.ad_failed();
finished = true;
};
};
};
if (elapsed > chk.ad_msec){
finished = true;
};
if (finished){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(options:Object, defaults:Object):Object{
var k:String;
var pairs:Array;
var i:Number;
var kv:Array;
var optcopy:Object = {};
for (k in defaults) {
optcopy[k] = defaults[k];
};
if (options){
for (k in options) {
optcopy[k] = options[k];
};
};
if (optcopy.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
options = optcopy.clip.loaderInfo.parameters.mochiad_options;
if (options){
pairs = options.split("&");
i = 0;
while (i < pairs.length) {
kv = pairs[i].split("=");
optcopy[unescape(kv[0])] = unescape(kv[1]);
i++;
};
};
if (optcopy.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (optcopy);
}
public static function _cleanup(mc:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = mc;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
lc.client = null;
lc.close();
//unresolved jump
var _slot1 = e;
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(options:Object):MovieClip{
var clip:Object;
var mc:MovieClip;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = options;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!(clip is DisplayObject)){
trace("Warning: Object passed as container clip not a descendant of the DisplayObject type");
return (null);
};
if (MovieClip(clip).stage == null){
trace("Warning: Container clip for ad is not attached to the stage");
return (null);
};
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip._mochiad_loaded){
return (null);
};
//unresolved jump
var _slot1 = e;
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
var depth:Number = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
loader = new Loader();
g = function (ev:Object):void{
ev.target.removeEventListener(ev.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (io:IOErrorEvent):void{
trace("[MochiAds] Blocked URL");
});
if (!options.skip){
loader.load(req);
};
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(base:Object, methodName:String, argsArray:Array):Object{
var nameArray:Array = methodName.split(".");
var i:Number = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return (undefined);
};
base = base[nameArray[i]];
i++;
};
if (typeof(base[nameArray[i]]) == "function"){
return (base[nameArray[i]].apply(base, argsArray));
};
return (undefined);
}
public static function createEmptyMovieClip(parent:Object, name:String, depth:Number):MovieClip{
var mc:MovieClip = new MovieClip();
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
parent[name] = mc;
mc["_name"] = name;
return (mc);
}
public static function _getRes(options:Object, clip:Object):Array{
var xy:Array;
var b:Object = clip.getBounds(clip.root);
var w:Number = 0;
var h:Number = 0;
if (typeof(options.res) != "undefined"){
xy = options.res.split("x");
w = parseFloat(xy[0]);
h = parseFloat(xy[1]);
} else {
w = (b.right - b.left);
h = (b.top - b.bottom);
};
if ((((w == 0)) || ((h == 0)))){
w = clip.stage.stageWidth;
h = clip.stage.stageHeight;
};
return ([w, h]);
}
public static function adShowing(mc:Object):void{
mc.origFrameRate = mc.stage.frameRate;
mc.stage.frameRate = 30;
}
public static function getValue(base:Object, objectName:String):Object{
var nameArray:Array = objectName.split(".");
var i:Number = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return (undefined);
};
base = base[nameArray[i]];
i++;
};
return (base[nameArray[i]]);
}
public static function rpc(clip:Object, callbackID:Number, arg:Object):void{
var _local4:Object;
var _local5:Object;
switch (arg.id){
case "setValue":
MochiAd.setValue(clip, arg.objectName, arg.value);
break;
case "getValue":
_local4 = MochiAd.getValue(clip, arg.objectName);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(clip, arg.method, arg.args);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + arg.id));
};
}
public static function setValue(base:Object, objectName:String, value:Object):void{
var nameArray:Array = objectName.split(".");
var i:Number = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return;
};
base = base[nameArray[i]];
i++;
};
base[nameArray[i]] = value;
}
public static function showPreGameAd(options:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = options;
var DEFAULTS:Object = {ad_timeout:5500, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (width:Number, height:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (percent:Number):void{
}, progress_override:function (_clip:Object):Number{
return (NaN);
}, bar_offset:0};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
if (options.skip){
ad_timeout = 0;
};
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = (10 + options.bar_offset);
bar.y = (h - 20);
};
var bar_w:Number = ((w - bar.x) - 10);
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo(bar_w, 0);
backing.lineTo(bar_w, 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo(bar_w, 0);
inside.lineTo(bar_w, 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo(bar_w, 0);
outline.lineTo(bar_w, 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (p > 0){
this.parent.alpha = (p * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var progress:Number = Math.min(1, options.progress_override(clip));
var f:Function = function (ev:Event):void{
ev.target.removeEventListener(ev.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
if (!isNaN(progress)){
complete = (progress == 1);
} else {
if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){
complete = true;
} else {
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
} else {
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
};
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (msec:Number):void{
var _chk:Object = mc._mochiad_wait;
_chk.server_control = true;
_chk.showing = true;
_chk.started = getTimer();
_chk.ad_msec = msec;
};
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
mc.rpcTestFn = function (s:String):Object{
trace(("[MOCHIAD rpcTestFn] " + s));
return (s);
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (lc_name:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var total:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _clip:Object = this.parent.parent.root;
var ad_clip:Object = this.parent._mochiad_ctr;
var elapsed:Number = (getTimer() - this.started);
var finished:Boolean;
var clip_total:Number = _clip.loaderInfo.bytesTotal;
var clip_loaded:Number = _clip.loaderInfo.bytesLoaded;
var clip_progress:Number = Math.min(1, options.progress_override(_clip));
if (clip_progress == 1){
complete = true;
};
if (complete){
clip_loaded = Math.max(1, clip_loaded);
clip_total = clip_loaded;
};
var clip_pcnt:Number = ((100 * clip_loaded) / clip_total);
if (!isNaN(clip_progress)){
clip_pcnt = (100 * clip_progress);
};
var ad_pcnt:Number = ((100 * elapsed) / chk.ad_msec);
var _inside:Object = this._mochiad_bar._inside;
var pcnt:Number = Math.min(100, Math.min(((clip_pcnt) || (0)), ad_pcnt));
pcnt = Math.max(this.last_pcnt, pcnt);
this.last_pcnt = pcnt;
_inside.scaleX = (pcnt * 0.01);
options.ad_progress(pcnt);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:clip_pcnt});
if (clip_pcnt >= 100){
sendHostProgress = false;
};
};
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((elapsed > chk.ad_timeout)) && ((clip_pcnt == 100)))){
options.ad_failed();
finished = true;
};
};
};
if (elapsed > chk.ad_msec){
finished = true;
};
if (((complete) && (finished))){
if (unloaded){
MochiAd.unload(_clip);
} else {
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(options:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(options);
}
public static function showTimedAd(options:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(options);
}
public static function doOnEnterFrame(mc:MovieClip):void{
var mc = mc;
var f:Function = function (ev:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
ev.target.removeEventListener(ev.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi.as3
Section 58
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const NO_USER:String = "NoUser";
public static const IO_ERROR:String = "IOError";
public static const ITEM_NEW:String = "ItemNew";
public static const ITEM_OWNED:String = "ItemOwned";
public static const STORE_ITEMS:String = "StoreItems";
public static const ERROR:String = "Error";
public static const STORE_SHOW:String = "StoreShow";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static var _inventory:MochiInventory;
public function MochiCoins(){
super();
}
public static function triggerEvent(eventType:String, args:Object):void{
_dispatcher.triggerEvent(eventType, args);
}
public static function removeEventListener(eventType:String, delegate:Function):void{
_dispatcher.removeEventListener(eventType, delegate);
}
public static function addEventListener(eventType:String, delegate:Function):void{
_dispatcher.addEventListener(eventType, delegate);
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function get inventory():MochiInventory{
return (_inventory);
}
public static function showStore(options:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:options}, null, null);
}
public static function requestFunding(properties:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestFunding", properties);
}
public static function showItem(options:Object=null):void{
if (((!(options)) || (!((typeof(options.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:options}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showVideo(options:Object=null):void{
if (((!(options)) || (!((typeof(options.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:options}, null, null);
}
addEventListener(MochiSocial.LOGGED_IN, function (args:Object):void{
_inventory = new MochiInventory();
});
addEventListener(MochiSocial.LOGGED_OUT, function (args:Object):void{
_inventory = null;
});
}
}//package mochi.as3
Section 59
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(digit:Number=0, index:uint=0):void{
super();
Encoder = 0;
setValue(digit, index);
}
public function reencode():void{
var newEncode:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (newEncode ^ Encoder));
Encoder = newEncode;
}
public function set value(v:Number):void{
setValue(v);
}
public function toString():String{
var s:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
s = (s + Sibling.toString());
};
return (s);
}
public function setValue(digit:Number=0, index:uint=0):void{
var s:String = digit.toString();
var _temp1 = index;
index = (index + 1);
Fragment = (s.charCodeAt(_temp1) ^ Encoder);
if (index < s.length){
Sibling = new MochiDigits(digit, index);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(inc:Number):void{
value = (value + inc);
}
}
}//package mochi.as3
Section 60
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
super();
eventTable = {};
}
public function triggerEvent(event:String, args:Object):void{
var i:Object;
if (eventTable[event] == undefined){
return;
};
for (i in eventTable[event]) {
var _local6 = eventTable[event];
_local6[i](args);
};
}
public function removeEventListener(event:String, delegate:Function):void{
var s:Object;
if (eventTable[event] == undefined){
eventTable[event] = [];
return;
};
for (s in eventTable[event]) {
if (eventTable[event][s] != delegate){
} else {
eventTable[event].splice(Number(s), 1);
};
};
}
public function addEventListener(event:String, delegate:Function):void{
removeEventListener(event, delegate);
eventTable[event].push(delegate);
}
}
}//package mochi.as3
Section 61
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const FORMAT_LONG:String = "LongForm";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const FORMAT_SHORT:String = "ShortForm";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_CENTER:String = "ALIGN_C";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var gameStart:Number;
private static var levelStart:Number;
public function MochiEvents(){
super();
}
public static function endPlay():void{
MochiServices.send("events_clearRoundID", null, null, null);
}
public static function addEventListener(eventType:String, delegate:Function):void{
_dispatcher.addEventListener(eventType, delegate);
}
public static function trackEvent(tag:String, value=null):void{
MochiServices.send("events_trackEvent", {tag:tag, value:value}, null, null);
}
public static function removeEventListener(eventType:String, delegate:Function):void{
_dispatcher.removeEventListener(eventType, delegate);
}
public static function startSession(achievementID:String):void{
MochiServices.send("events_beginSession", {achievementID:achievementID}, null, null);
}
public static function triggerEvent(eventType:String, args:Object):void{
_dispatcher.triggerEvent(eventType, args);
}
public static function setNotifications(clip:MovieClip, style:Object):void{
var s:Object;
var args:Object = {};
for (s in style) {
args[s] = style[s];
};
args.clip = clip;
MochiServices.send("events_setNotifications", args, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startPlay(tag:String="gameplay"):void{
MochiServices.send("events_setRoundID", {tag:String(tag)}, null, null);
}
}
}//package mochi.as3
Section 62
//MochiInventory (mochi.as3.MochiInventory)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
public dynamic class MochiInventory extends Proxy {
private var _timer:Timer;
private var _names:Array;
private var _syncID:Number;
private var _consumableProperties:Object;
private var _storeSync:Object;
private var _outstandingID:Number;
private var _syncPending:Boolean;
public static const READY:String = "InvReady";
public static const ERROR:String = "Error";
public static const IO_ERROR:String = "IoError";
private static const KEY_SALT:String = " syncMaint";
public static const WRITTEN:String = "InvWritten";
public static const NOT_READY:String = "InvNotReady";
public static const VALUE_ERROR:String = "InvValueError";
private static const CONSUMER_KEY:String = "MochiConsumables";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiInventory():void{
super();
MochiCoins.addEventListener(MochiCoins.ITEM_OWNED, itemOwned);
MochiCoins.addEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, loggedOut);
_storeSync = new Object();
_syncPending = false;
_outstandingID = 0;
_syncID = 0;
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, sync);
_timer.start();
if (MochiSocial.loggedIn){
loggedIn();
} else {
loggedOut();
};
}
private function newItems(event:Object):void{
if (!this[(event.id + KEY_SALT)]){
this[(event.id + KEY_SALT)] = 0;
};
if (!this[event.id]){
this[event.id] = 0;
};
this[(event.id + KEY_SALT)] = (this[(event.id + KEY_SALT)] + event.count);
this[event.id] = (this[event.id] + event.count);
if (((event.privateProperties) && (event.privateProperties.consumable))){
if (!this[event.privateProperties.tag]){
this[event.privateProperties.tag] = 0;
};
this[event.privateProperties.tag] = (this[event.privateProperties.tag] + (event.privateProperties.inc * event.count));
};
}
public function release():void{
MochiCoins.removeEventListener(MochiCoins.ITEM_NEW, newItems);
MochiSocial.removeEventListener(MochiSocial.LOGGED_IN, loggedIn);
MochiSocial.removeEventListener(MochiSocial.LOGGED_OUT, loggedOut);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (-1);
};
if (_consumableProperties[name]){
return (MochiDigits(_consumableProperties[name]).value);
};
return (undefined);
}
private function loggedIn(args:Object=null):void{
MochiUserData.get(CONSUMER_KEY, getConsumableBag);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return (false);
};
if (_consumableProperties[name] == undefined){
return (false);
};
return (true);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{
return (((index)>=_names.length) ? 0 : (index + 1));
}
private function putConsumableBag(userData:MochiUserData):void{
_syncPending = false;
if (userData.error){
triggerEvent(ERROR, {type:IO_ERROR, error:userData.error});
_outstandingID = -1;
};
triggerEvent(WRITTEN, {});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{
var d:MochiDigits;
if (_consumableProperties == null){
triggerEvent(ERROR, {type:NOT_READY});
return;
};
if (!(value is Number)){
triggerEvent(ERROR, {type:VALUE_ERROR, error:"Invalid type", arg:value});
return;
};
if (_consumableProperties[name]){
d = MochiDigits(_consumableProperties[name]);
if (d.value == value){
return;
};
d.value = value;
} else {
_names.push(name);
_consumableProperties[name] = new MochiDigits(value);
};
_syncID++;
}
private function itemOwned(event:Object):void{
_storeSync[event.id] = {properties:event.properties, count:event.count};
}
private function sync(e:Event=null):void{
var key:String;
if (((_syncPending) || ((_syncID == _outstandingID)))){
return;
};
_outstandingID = _syncID;
var output:Object = {};
for (key in _consumableProperties) {
output[key] = MochiDigits(_consumableProperties[key]).value;
};
MochiUserData.put(CONSUMER_KEY, output, putConsumableBag);
_syncPending = true;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{
return (_names[(index - 1)]);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(name):Boolean{
if (!_consumableProperties[name]){
return (false);
};
_names.splice(_names.indexOf(name), 1);
delete _consumableProperties[name];
return (true);
}
private function getConsumableBag(userData:MochiUserData):void{
var key:String;
var unsynced:Number;
if (userData.error){
triggerEvent(ERROR, {type:IO_ERROR, error:userData.error});
return;
};
_consumableProperties = {};
_names = new Array();
if (userData.data){
for (key in userData.data) {
_names.push(key);
_consumableProperties[key] = new MochiDigits(userData.data[key]);
};
};
for (key in _storeSync) {
unsynced = _storeSync[key].count;
if (_consumableProperties[(key + KEY_SALT)]){
unsynced = (unsynced - _consumableProperties[(key + KEY_SALT)].value);
};
if (unsynced == 0){
} else {
newItems({id:key, count:unsynced, properties:_storeSync[key].properties});
};
};
triggerEvent(READY, {});
}
private function loggedOut(args:Object=null):void{
_consumableProperties = null;
}
public static function triggerEvent(eventType:String, args:Object):void{
_dispatcher.triggerEvent(eventType, args);
}
public static function removeEventListener(eventType:String, delegate:Function):void{
_dispatcher.removeEventListener(eventType, delegate);
}
public static function addEventListener(eventType:String, delegate:Function):void{
_dispatcher.addEventListener(eventType, delegate);
}
}
}//package mochi.as3
Section 63
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public function MochiScores(){
super();
}
public static function showLeaderboard(options:Object=null):void{
var n:Number;
var options = options;
if (options != null){
delete options.clip;
MochiServices.setContainer();
MochiServices.bringToTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.warnID(options.boardID, true);
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(callbackObj:Object, callbackMethod:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, callbackObj, callbackMethod);
}
public static function requestList(callbackObj:Object, callbackMethod:Object=null):void{
MochiServices.send("scores_requestList", null, callbackObj, callbackMethod);
}
public static function scoresArrayToObjects(scores:Object):Object{
var i:Number;
var j:Number;
var o:Object;
var row_obj:Object;
var item:String;
var param:String;
var so:Object = {};
for (item in scores) {
if (typeof(scores[item]) == "object"){
if (((!((scores[item].cols == null))) && (!((scores[item].rows == null))))){
so[item] = [];
o = scores[item];
j = 0;
while (j < o.rows.length) {
row_obj = {};
i = 0;
while (i < o.cols.length) {
row_obj[o.cols[i]] = o.rows[j][i];
i++;
};
so[item].push(row_obj);
j++;
};
} else {
so[item] = {};
for (param in scores[item]) {
so[item][param] = scores[item][param];
};
};
} else {
so[item] = scores[item];
};
};
return (so);
}
public static function submit(score:Number, name:String, callbackObj:Object=null, callbackMethod:Object=null):void{
score = Number(score);
if (isNaN(score)){
trace((("ERROR: Submitted score '" + String(score)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((score == Number.NEGATIVE_INFINITY)) || ((score == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(score)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(score) != score){
trace((("WARNING: Submitted score '" + String(score)) + "' will be truncated"));
};
score = Number(score);
};
};
MochiServices.send("scores_submit", {score:score, name:name}, callbackObj, callbackMethod);
}
public static function onClose(args:Object=null):void{
if (((((args) && ((args.error == true)))) && (onErrorHandler))){
if (args.errorCode == null){
args.errorCode = "IOError";
};
onErrorHandler(args.errorCode);
MochiServices.doClose();
return;
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(boardID:String):void{
MochiServices.warnID(boardID, true);
MochiScores.boardID = boardID;
MochiServices.send("scores_setBoardID", {boardID:boardID});
}
}
}//package mochi.as3
Section 64
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
public static const CONNECTED:String = "onConnected";
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _queue:Array;
private static var _swfVersion:String;
private static var _preserved:Object;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _nextCallbackID:Number;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _services:String = "services.swf";
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var _callbacks:Object;
private static var _connecting:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _listenChannelName:String = "__ms_";
public static var onError:Object;
public static var netup:Boolean = true;
private static var _mochiLC:String = "MochiLC.swf";
public function MochiServices(){
super();
}
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function onReceive(pkg:Object):void{
var methodName:String;
var pkg = pkg;
var cb:String = pkg.callbackID;
var cblst:Object = _callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
method.apply(obj, pkg.args);
//unresolved jump
var _slot1 = error;
trace(((("Error invoking callback method '" + methodName) + "': ") + _slot1.toString()));
} else {
if (obj != null){
obj(pkg.args);
//unresolved jump
var _slot1 = error;
trace(("Error invoking method on object: " + _slot1.toString()));
};
};
delete _callbacks[cb];
}
public static function send(methodName:String, args:Object=null, callbackObject:Object=null, callbackMethod:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:methodName, args:args, callbackID:_nextCallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + methodName));
handleError(args, callbackObject, callbackMethod);
flush(true);
return;
};
_queue.push({methodName:methodName, args:args, callbackID:_nextCallbackID});
};
if (_clip != null){
if (_callbacks != null){
_callbacks[_nextCallbackID] = {callbackObject:callbackObject, callbackMethod:callbackMethod};
_nextCallbackID++;
};
};
}
private static function init(id:String, clip:Object):void{
_id = id;
if (clip != null){
_container = clip;
loadCommunicator(id, _container);
};
}
private static function clickMovie(url:String, cb:Function):MovieClip{
var b:int;
var loader:Loader;
var avm1_bytecode:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var header:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var footer:Array = [0, 64, 0, 0, 0];
var mc:MovieClip = new MovieClip();
var lc:LocalConnection = new LocalConnection();
var lc_name:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
lc = new LocalConnection();
mc.lc = lc;
mc.click = cb;
lc.client = mc;
lc.connect(lc_name);
var ba:ByteArray = new ByteArray();
var cpool:ByteArray = new ByteArray();
cpool.endian = Endian.LITTLE_ENDIAN;
cpool.writeShort(1);
cpool.writeUTFBytes(((url + " ") + lc_name));
cpool.writeByte(0);
var actionLength:uint = ((avm1_bytecode.length + cpool.length) + 4);
var fileLength:uint = (actionLength + 35);
ba.endian = Endian.LITTLE_ENDIAN;
ba.writeUTFBytes("FWS");
ba.writeByte(8);
ba.writeUnsignedInt(fileLength);
for each (b in header) {
ba.writeByte(b);
};
ba.writeUnsignedInt(actionLength);
ba.writeByte(136);
ba.writeShort(cpool.length);
ba.writeBytes(cpool);
for each (b in avm1_bytecode) {
ba.writeByte(b);
};
for each (b in footer) {
ba.writeByte(b);
};
loader = new Loader();
loader.loadBytes(ba);
mc.addChild(loader);
return (mc);
}
private static function detach(event:Event):void{
var loader:LoaderInfo = LoaderInfo(event.target);
loader.removeEventListener(Event.COMPLETE, detach);
loader.removeEventListener(IOErrorEvent.IO_ERROR, detach);
loader.removeEventListener(Event.COMPLETE, loadLCBridgeComplete);
loader.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
private static function loadLCBridgeComplete(e:Event):void{
var loader:Loader = LoaderInfo(e.target).loader;
_mochiLocalConnection = MovieClip(loader.content);
listen();
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
_mochiLocalConnection.close();
//unresolved jump
var _slot1 = error;
};
if (_timer != null){
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, connectWait);
_timer = null;
//unresolved jump
var _slot1 = error;
};
}
public static function allowDomains(server:String):String{
var hostname:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (server.indexOf("http://") != -1){
hostname = server.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(hostname);
Security.allowInsecureDomain(hostname);
};
};
return (hostname);
}
public static function getVersion():String{
return ("3.9.1 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
public static function warnID(bid:String, leaderboard:Boolean):void{
bid = bid.toLowerCase();
if (bid.length != 16){
trace((("WARNING: " + (leaderboard) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (bid == "1e113c7239048b3f"){
if (leaderboard){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (bid == "84993a1de4031cd8"){
if (leaderboard){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
var i:Number = 0;
while (i < bid.length) {
switch (bid.charAt(i)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + bid));
return;
};
i++;
};
}
private static function flush(error:Boolean):void{
var request:Object;
var callback:Object;
if (((_clip) && (_queue))){
while (_queue.length > 0) {
request = _queue.shift();
callback = null;
if (request != null){
if (request.callbackID != null){
callback = _callbacks[request.callbackID];
};
delete _callbacks[request.callbackID];
if (((error) && (!((callback == null))))){
handleError(request.args, callback.callbackObject, callback.callbackMethod);
};
};
};
};
}
public static function get id():String{
return (_id);
}
private static function onEvent(pkg:Object):void{
var target:String = pkg.target;
var event:String = pkg.event;
switch (target){
case "services":
MochiServices.triggerEvent(pkg.event, pkg.args);
break;
case "events":
MochiEvents.triggerEvent(pkg.event, pkg.args);
break;
case "coins":
MochiCoins.triggerEvent(pkg.event, pkg.args);
break;
case "social":
MochiSocial.triggerEvent(pkg.event, pkg.args);
break;
};
}
private static function urlOptions(clip:Object):Object{
var options:String;
var pairs:Array;
var i:Number;
var kv:Array;
var opts:Object = {};
if (clip.stage){
options = clip.stage.loaderInfo.parameters.mochiad_options;
} else {
options = clip.loaderInfo.parameters.mochiad_options;
};
if (options){
pairs = options.split("&");
i = 0;
while (i < pairs.length) {
kv = pairs[i].split("=");
opts[unescape(kv[0])] = unescape(kv[1]);
i++;
};
};
return (opts);
}
public static function addLinkEvent(url:String, burl:String, btn:DisplayObjectContainer, onClick:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = url;
var burl = burl;
var btn = btn;
var onClick = onClick;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://link.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (url:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(url, onClick);
var rect:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = rect.x;
avm1Click.y = rect.y;
avm1Click.scaleX = (0.01 * rect.width);
avm1Click.scaleY = (0.01 * rect.height);
};
err = function (ev:Object):void{
netup = false;
ev.target.removeEventListener(ev.type, arguments.callee);
setURL(burl);
};
complete = function (ev:Object):void{
ev.target.removeEventListener(ev.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function setContainer(container:Object=null, doAdd:Boolean=true):void{
if (_clip.parent){
_clip.parent.removeChild(_clip);
};
if (container != null){
if ((container is DisplayObjectContainer)){
_container = container;
};
};
if (doAdd){
if ((_container is DisplayObjectContainer)){
DisplayObjectContainer(_container).addChild(_clip);
};
};
}
private static function handleError(args:Object, callbackObject:Object, callbackMethod:Object):void{
var args = args;
var callbackObject = callbackObject;
var callbackMethod = callbackMethod;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
var _local5 = callbackObject;
_local5[callbackMethod](args);
//unresolved jump
var _slot1 = error;
} else {
if (callbackMethod != null){
callbackMethod.apply(args);
//unresolved jump
var _slot1 = error;
};
};
};
}
private static function loadError(ev:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
public static function get childClip():Object{
return (_clip);
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _queue.shift());
};
};
}
public static function triggerEvent(eventType:String, args:Object):void{
_dispatcher.triggerEvent(eventType, args);
}
public static function removeEventListener(eventType:String, delegate:Function):void{
_dispatcher.removeEventListener(eventType, delegate);
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (args:Object):void{
MochiServices.comChannelName = args.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
public static function addEventListener(eventType:String, delegate:Function):void{
_dispatcher.addEventListener(eventType, delegate);
}
private static function loadLCBridge(clip:Object):void{
var loader:Loader = new Loader();
var mochiLCURL:String = (_servURL + _mochiLC);
var req:URLRequest = new URLRequest(mochiLCURL);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, detach);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, detach);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadLCBridgeComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
loader.load(req);
clip.addChild(loader);
}
public static function set comChannelName(val:String):void{
if (val != null){
if (val.length > 3){
_sendChannelName = (val + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(id:String, clip:Object):MovieClip{
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(clip).servURL){
_servURL = urlOptions(clip).servURL;
};
var servicesURL:String = (_servURL + _services);
if (urlOptions(clip).servicesURL){
servicesURL = urlOptions(clip).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(servicesURL);
_clip = new MovieClip();
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, detach);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, detach);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var req:URLRequest = new URLRequest(servicesURL);
var vars:URLVariables = new URLVariables();
vars.listenLC = _listenChannelName;
vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options;
vars.api_version = getVersion();
if (widget){
vars.widget = true;
};
req.data = vars;
_loader.load(req);
_clip.addChild(_loader);
_sendChannel = new LocalConnection();
_queue = [];
_nextCallbackID = 0;
_callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function get clip():Object{
return (_container);
}
public static function connect(id:String, clip:Object, onError:Object=null):void{
var id = id;
var clip = clip;
var onError = onError;
warnID(id, false);
if ((clip is DisplayObject)){
if (clip.stage == null){
trace("MochiServices connect requires the containing clip be attached to the stage");
};
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (errorCode:String):void{
trace(errorCode);
};
};
};
}
public static function bringToTop(e:Event=null):void{
var e = e;
if (((!((MochiServices.clip == null))) && (!((MochiServices.childClip == null))))){
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
//unresolved jump
var _slot1 = errorObject;
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
}
public static function connectWait(e:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
} else {
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, connectWait);
_timer = null;
};
}
}
}//package mochi.as3
Section 65
//MochiSocial (mochi.as3.MochiSocial)
package mochi.as3 {
public class MochiSocial {
public static const LOGGED_IN:String = "LoggedIn";
public static const ACTION_CANCELED:String = "onCancel";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const IO_ERROR:String = "IOError";
public static const NO_USER:String = "NoUser";
public static const FRIEND_LIST:String = "FriendsList";
public static const PROFILE_DATA:String = "ProfileData";
public static const GAMEPLAY_DATA:String = "GameplayData";
public static const ACTION_COMPLETE:String = "onComplete";
public static const LOGIN_SHOW:String = "LoginShow";
public static const PROFILE_HIDE:String = "ProfileHide";
public static const USER_INFO:String = "UserInfo";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const ERROR:String = "Error";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_HIDE:String = "LoginHide";
public static const LOGIN_SHOWN:String = "LoginShown";
public static var _user_info:Object = null;
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public function MochiSocial(){
super();
}
public static function requestFan(properties:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestFan", properties);
}
public static function postToStream(properties:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_postToStream", properties);
}
public static function getFriendsList(properties:Object=null):void{
MochiServices.send("social_getFriendsList", properties);
}
public static function requestLogin(properties:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_requestLogin", properties);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function saveUserProperties(properties:Object):void{
MochiServices.send("social_saveUserProperties", properties);
}
public static function triggerEvent(eventType:String, args:Object):void{
_dispatcher.triggerEvent(eventType, args);
}
public static function removeEventListener(eventType:String, delegate:Function):void{
_dispatcher.removeEventListener(eventType, delegate);
}
public static function inviteFriends(properties:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_inviteFriends", properties);
}
public static function get loggedIn():Boolean{
return (!((_user_info == null)));
}
public static function addEventListener(eventType:String, delegate:Function):void{
_dispatcher.addEventListener(eventType, delegate);
}
public static function showLoginWidget(options:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("social_showLoginWidget", {options:options});
}
public static function getAPIURL():String{
if (!_user_info){
return (null);
};
return (_user_info.api_url);
}
public static function hideLoginWidget():void{
MochiServices.send("social_hideLoginWidget");
}
public static function getAPIToken():String{
if (!_user_info){
return (null);
};
return (_user_info.api_token);
}
MochiSocial.addEventListener(MochiSocial.LOGGED_IN, function (args:Object):void{
_user_info = args;
});
MochiSocial.addEventListener(MochiSocial.LOGGED_OUT, function (args:Object):void{
_user_info = null;
});
}
}//package mochi.as3
Section 66
//MochiUserData (mochi.as3.MochiUserData)
package mochi.as3 {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class MochiUserData extends EventDispatcher {
public var callback:Function;// = null
public var operation:String;// = null
public var error:Event;// = null
public var data;// = null
public var _loader:URLLoader;
public var key:String;// = null
public function MochiUserData(key:String="", callback:Function=null){
super();
this.key = key;
this.callback = callback;
}
public function serialize(obj):ByteArray{
var arr:ByteArray = new ByteArray();
arr.objectEncoding = ObjectEncoding.AMF3;
arr.writeObject(obj);
arr.compress();
return (arr);
}
public function errorHandler(event:IOErrorEvent):void{
data = null;
error = event;
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function putEvent(obj):void{
request("put", serialize(obj));
}
public function deserialize(arr:ByteArray){
arr.objectEncoding = ObjectEncoding.AMF3;
arr.uncompress();
return (arr.readObject());
}
public function securityErrorHandler(event:SecurityErrorEvent):void{
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + event.toString())));
}
public function getEvent():void{
request("get", serialize(null));
}
override public function toString():String{
return ((((((((("[MochiUserData operation=" + operation) + " key=\"") + key) + "\" data=") + data) + " error=\"") + error) + "\"]"));
}
public function performCallback():void{
callback(this);
//unresolved jump
var _slot1 = e;
trace(("[MochiUserData] exception during callback: " + _slot1));
}
public function request(_operation:String, _data:ByteArray):void{
var _operation = _operation;
var _data = _data;
operation = _operation;
var api_url:String = MochiSocial.getAPIURL();
var api_token:String = MochiSocial.getAPIToken();
if ((((api_url == null)) || ((api_token == null)))){
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "not logged in"));
return;
};
_loader = new URLLoader();
var args:URLVariables = new URLVariables();
args.op = _operation;
args.key = key;
var req:URLRequest = new URLRequest((((MochiSocial.getAPIURL() + "/") + "MochiUserData?") + args.toString()));
req.method = URLRequestMethod.POST;
req.contentType = "application/x-mochi-userdata";
req.requestHeaders = [new URLRequestHeader("x-mochi-services-version", MochiServices.getVersion()), new URLRequestHeader("x-mochi-api-token", api_token)];
req.data = _data;
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE, completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.load(req);
//unresolved jump
var _slot1 = e;
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("security error: " + _slot1.toString())));
}
public function completeHandler(event:Event):void{
var event = event;
if (_loader.data.length){
data = deserialize(_loader.data);
} else {
data = null;
};
//unresolved jump
var _slot1 = e;
errorHandler(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, ("deserialize error: " + _slot1.toString())));
return;
if (callback != null){
performCallback();
} else {
dispatchEvent(event);
};
close();
}
public function close():void{
if (_loader){
_loader.removeEventListener(Event.COMPLETE, completeHandler);
_loader.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_loader.close();
_loader = null;
};
error = null;
callback = null;
}
public static function get(key:String, callback:Function):void{
var userData:MochiUserData = new MochiUserData(key, callback);
userData.getEvent();
}
public static function put(key:String, obj, callback:Function):void{
var userData:MochiUserData = new MochiUserData(key, callback);
userData.putEvent(obj);
}
}
}//package mochi.as3
Section 67
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.0.0.0";
public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
super(bitmapData, pixelSnapping, smoothing);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
}
}//package mx.core
Section 68
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function ByteArrayAsset(){
super();
}
}
}//package mx.core
Section 69
//EdgeMetrics (mx.core.EdgeMetrics)
package mx.core {
public class EdgeMetrics {
public var top:Number;
public var left:Number;
public var bottom:Number;
public var right:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0);
;
public function EdgeMetrics(left:Number=0, top:Number=0, right:Number=0, bottom:Number=0){
super();
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public function clone():EdgeMetrics{
return (new EdgeMetrics(left, top, right, bottom));
}
}
}//package mx.core
Section 70
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
var bitmapData = bitmapData;
var pixelSnapping = pixelSnapping;
var smoothing = smoothing;
super(bitmapData, pixelSnapping, smoothing);
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 71
//FlexMovieClip (mx.core.FlexMovieClip)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexMovieClip extends MovieClip {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexMovieClip(){
super();
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 72
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function FontAsset(){
super();
}
}
}//package mx.core
Section 73
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 74
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 75
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(void:Point):Point;
function get name():String;
function set width(flash.display:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(flash.display:String):void;
function set scaleX(flash.display:Number):void;
function set scaleY(flash.display:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(flash.display:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(void:Point):Point;
function get height():Number;
function set blendMode(flash.display:String):void;
function get parent():DisplayObjectContainer;
function getBounds(String:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(flash.display:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(flash.display:Number):void;
function set accessibilityProperties(flash.display:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(flash.display:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(flash.display:Number):void;
function set mask(flash.display:DisplayObject):void;
function getRect(String:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(flash.display:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean;
function set opaqueBackground(flash.display:Object):void;
function set visible(flash.display:Boolean):void;
function get mask():DisplayObject;
function set x(flash.display:Number):void;
function set y(flash.display:Number):void;
function get transform():Transform;
function set filters(flash.display:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(flash.display:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 76
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get isDocument():Boolean;
function set repeaters(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function initializeRepeaterArrays(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 77
//MovieClipAsset (mx.core.MovieClipAsset)
package mx.core {
public class MovieClipAsset extends FlexMovieClip implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function MovieClipAsset(){
super();
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 78
//MovieClipLoaderAsset (mx.core.MovieClipLoaderAsset)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.system.*;
public class MovieClipLoaderAsset extends MovieClipAsset implements IFlexAsset, IFlexDisplayObject {
protected var initialHeight:Number;// = 0
private var loader:Loader;// = null
private var initialized:Boolean;// = false
protected var initialWidth:Number;// = 0
private var requestedHeight:Number;
private var requestedWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function MovieClipLoaderAsset(){
super();
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
if (("allowLoadBytesCodeExecution" in loaderContext)){
loaderContext["allowLoadBytesCodeExecution"] = true;
};
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.loadBytes(movieClipData, loaderContext);
addChild(loader);
}
override public function get width():Number{
if (!initialized){
return (initialWidth);
};
return (super.width);
}
override public function set width(value:Number):void{
if (!initialized){
requestedWidth = value;
} else {
loader.width = value;
};
}
override public function get measuredHeight():Number{
return (initialHeight);
}
private function completeHandler(event:Event):void{
initialized = true;
initialWidth = loader.width;
initialHeight = loader.height;
if (!isNaN(requestedWidth)){
loader.width = requestedWidth;
};
if (!isNaN(requestedHeight)){
loader.height = requestedHeight;
};
dispatchEvent(event);
}
override public function set height(value:Number):void{
if (!initialized){
requestedHeight = value;
} else {
loader.height = value;
};
}
override public function get measuredWidth():Number{
return (initialWidth);
}
override public function get height():Number{
if (!initialized){
return (initialHeight);
};
return (super.height);
}
public function get movieClipData():ByteArray{
return (null);
}
}
}//package mx.core
Section 79
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 80
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function SoundAsset(){
super();
}
}
}//package mx.core
Section 81
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public function NameUtil(){
super();
}
public static function displayObjectToString(displayObject:DisplayObject):String{
var result:String;
var s:String;
var indices:Array;
var o:DisplayObject = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
return (result);
}
public static function createUniqueName(object:Object):String{
if (!object){
return (null);
};
var name:String = getQualifiedClassName(object);
var index:int = name.indexOf("::");
if (index != -1){
name = name.substr((index + 2));
};
var charCode:int = name.charCodeAt((name.length - 1));
if ((((charCode >= 48)) && ((charCode <= 57)))){
name = (name + "_");
};
return ((name + counter++));
}
}
}//package mx.utils
Section 82
//ComplexMovement (smileygamer.movement.ComplexMovement)
package smileygamer.movement {
public class ComplexMovement implements IMovement {
private var fType:int;// = 0
private var fIndex:int;
private var fMovements:Array;
public static const TYPE_SIMULTANEOUS:int = 0;
public static const TYPE_SEQUENTIAL:int = 1;
public function ComplexMovement(aMovements:Array, aType:int=0){
super();
fMovements = aMovements;
fType = aType;
fIndex = 0;
}
public function move():Boolean{
if (fType == TYPE_SEQUENTIAL){
return (sequentialMove());
};
return (simultaneousMove());
}
private function simultaneousMove():Boolean{
var finished:Boolean;
var i:int;
while (i < fMovements.length) {
finished = ((fMovements[i].move()) && (finished));
i++;
};
return (finished);
}
private function sequentialMove():Boolean{
if (fMovements[fIndex].move()){
fIndex++;
};
return ((fIndex == fMovements.length));
}
}
}//package smileygamer.movement
Section 83
//IMovement (smileygamer.movement.IMovement)
package smileygamer.movement {
public interface IMovement {
function move():Boolean;
}
}//package smileygamer.movement
Section 84
//LinearMovement (smileygamer.movement.LinearMovement)
package smileygamer.movement {
import flash.display.*;
import smileygamer.util.*;
public class LinearMovement implements IMovement {
private var fMoves:int;
private var fObjects:Array;// = null
private var fMove:int;// = 0
private var fDX:Number;
private var fDY:Number;
private var fObjectContainer:DisplayObjectContainer;
private var fObjectFilter:IFilter;
public function LinearMovement(aObjectContainer:DisplayObjectContainer, aMoves:int, aDX:Number=1, aDY:Number=1, aObjectFilter:IFilter=null){
super();
fObjectContainer = aObjectContainer;
fObjectFilter = aObjectFilter;
fDX = aDX;
fDY = aDY;
fMoves = aMoves;
}
public function move():Boolean{
var i:int;
var object:DisplayObject;
var obj:DisplayObject;
if (fMove == fMoves){
return (true);
};
if (fObjects == null){
fObjects = new Array();
i = (fObjectContainer.numChildren - 1);
while (i >= 0) {
object = fObjectContainer.getChildAt(i);
if ((((fObjectFilter == null)) || (fObjectFilter.accept(object)))){
fObjects.push(object);
};
i--;
};
};
i = 0;
while (i < fObjects.length) {
obj = fObjects[i];
obj.x = (obj.x + fDX);
obj.y = (obj.y + fDY);
if ((fMove + 1) == fMoves){
obj.x = Math.round(obj.x);
obj.y = Math.round(obj.y);
};
i++;
};
fMove++;
return ((fMove == fMoves));
}
public function getObjects():DisplayObjectContainer{
return (fObjectContainer);
}
}
}//package smileygamer.movement
Section 85
//BitmapUtil (smileygamer.util.BitmapUtil)
package smileygamer.util {
import flash.geom.*;
import flash.display.*;
public class BitmapUtil {
public function BitmapUtil(){
super();
}
public static function splitImage(aImage:Bitmap, aWidth:int, aHeight:int, aBorder:int=0, aFilters:Array=null):Array{
var bitmapData:BitmapData;
var i:int;
var tiles:Array = new Array();
var rect:Rectangle = new Rectangle(0, 0, aWidth, aHeight);
var zero:Point = new Point(0, 0);
var origin:Point = new Point(aBorder, aBorder);
rect.y = 0;
while (rect.y < aImage.height) {
rect.x = 0;
while (rect.x < aImage.width) {
bitmapData = new BitmapData((aWidth + (2 * aBorder)), (aHeight + (2 * aBorder)), true, 0);
bitmapData.copyPixels(aImage.bitmapData, rect, origin);
if (aFilters != null){
i = 0;
while (i < aFilters.length) {
bitmapData.applyFilter(bitmapData, bitmapData.rect, zero, aFilters[i]);
i++;
};
};
tiles.push(new Bitmap(bitmapData));
rect.x = (rect.x + aWidth);
};
rect.y = (rect.y + aHeight);
};
return (tiles);
}
public static function createMaskedBitmap(aImage:Bitmap, aMask:Bitmap, aFilters:Array=null):Bitmap{
var i:int;
var result:Bitmap = new Bitmap(new BitmapData(aImage.width, aImage.height, true, 0));
result.bitmapData.draw(aImage);
var imgRect:Rectangle = new Rectangle(0, 0, result.width, result.height);
var origin:Point = new Point(0, 0);
result.bitmapData.copyChannel(aMask.bitmapData, imgRect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.ALPHA);
if (aFilters != null){
i = 0;
while (i < aFilters.length) {
result.bitmapData.applyFilter(result.bitmapData, imgRect, origin, aFilters[i]);
i++;
};
};
return (result);
}
}
}//package smileygamer.util
Section 86
//IFilter (smileygamer.util.IFilter)
package smileygamer.util {
public interface IFilter {
function accept(:Object):Boolean;
}
}//package smileygamer.util
Section 87
//InterpolationUtil (smileygamer.util.InterpolationUtil)
package smileygamer.util {
public class InterpolationUtil {
public static const TYPE_LINEAR:int = 0;
public static const TYPE_ACOS:int = 2;
public static const TYPE_COSINE:int = 1;
public function InterpolationUtil(){
super();
}
public static function createValues(aType:int, aBegin:Number, aEnd:Number, aSteps:int):Array{
var values:Array = new Array(aSteps);
var max:int = (aSteps - 1);
var i:int;
while (i < aSteps) {
if (aType == TYPE_COSINE){
values[i] = (aBegin + (((aEnd - aBegin) * Number((1 - Math.cos(((i * Math.PI) / max))))) / 2));
} else {
if (aType == TYPE_ACOS){
values[i] = (aBegin + ((aEnd - aBegin) * Number((Math.acos((1 - ((2 * Number(i)) / max))) / Math.PI))));
} else {
values[i] = (aBegin + (((aEnd - aBegin) * Number(i)) / max));
};
};
i++;
};
return (values);
}
}
}//package smileygamer.util
Section 88
//RandomUtil (smileygamer.util.RandomUtil)
package smileygamer.util {
public class RandomUtil {
public function RandomUtil(){
super();
}
public static function generateRandomArray(aLength:int):Array{
var r:int;
var temp:int;
var array:Array = new Array(aLength);
var i:int;
while (i < aLength) {
array[i] = i;
i++;
};
i = 0;
while (i < aLength) {
r = generateRandom(0, aLength);
temp = array[i];
array[i] = array[r];
array[r] = temp;
i++;
};
return (array);
}
public static function chance(aChance:int):Boolean{
if (aChance < 2){
return (true);
};
var r:int = (randomInt() % aChance);
return ((r == 0));
}
public static function randomBoolean():Boolean{
return (((randomInt() % 2) == 0));
}
public static function seed(aSeed:int):void{
}
public static function randomInt():int{
return (Math.round((Math.random() * int.MAX_VALUE)));
}
public static function generateRandom(aMin:int, aMax:int):int{
if (aMin == aMax){
return (aMin);
};
if (aMax > aMin){
return (((randomInt() % (aMax - aMin)) + aMin));
};
return (((randomInt() % (aMin - aMax)) + aMax));
}
}
}//package smileygamer.util
Section 89
//AAnimation (smileygamer.AAnimation)
package smileygamer {
import flash.events.*;
import flash.display.*;
public class AAnimation implements IAnimation {
private var fStopped:Boolean;
private var fCallbacks:Array;
private var fDisplayObject:DisplayObject;
private var fFrame:int;// = 0
private var fLooping:Boolean;
public function AAnimation(aDisplayObject:DisplayObject){
super();
fDisplayObject = aDisplayObject;
looping = true;
fCallbacks = new Array();
reset();
}
public function stop():void{
fStopped = true;
}
private function doCallbacks():void{
var callback:Function;
var i:int;
while (i < fCallbacks.length) {
callback = (fCallbacks[i] as Function);
callback.call(this);
i++;
};
}
public function get looping():Boolean{
return (fLooping);
}
public function addCallback(aCallback:Function):void{
if (aCallback != null){
fCallbacks.push(aCallback);
};
}
public function update():void{
}
public function reset():void{
fFrame = 0;
fStopped = false;
displayObject.removeEventListener(Event.ENTER_FRAME, next);
displayObject.addEventListener(Event.ENTER_FRAME, next);
update();
}
public function get displayObject():DisplayObject{
return (fDisplayObject);
}
protected function get frameCount():int{
return (1);
}
public function removeCallback(aCallback:Function):void{
var i:int;
while (i < fCallbacks.length) {
if (fCallbacks[i] == aCallback){
fCallbacks.splice(i, 1);
};
i++;
};
}
protected function get frame():int{
return (fFrame);
}
public function get finished():Boolean{
return ((((fFrame == frameCount)) || (fStopped)));
}
private function next(aEvent:Event):void{
if (displayObject.stage != null){
update();
fFrame++;
if (fLooping){
fFrame = (fFrame % frameCount);
};
if (finished){
displayObject.removeEventListener(Event.ENTER_FRAME, next);
doCallbacks();
};
} else {
displayObject.removeEventListener(Event.ENTER_FRAME, next);
};
}
public function set looping(aValue:Boolean):void{
fLooping = aValue;
}
}
}//package smileygamer
Section 90
//AGame (smileygamer.AGame)
package smileygamer {
import flash.events.*;
import flash.display.*;
public class AGame extends MovieClip {
public function AGame(){
super();
addEventListener(Event.ENTER_FRAME, mainLoop);
}
public function mainLoop(aEvent:Event):void{
var logic:ILogic;
var i:int;
while (i < numChildren) {
if ((getChildAt(i) is ILogic)){
logic = (getChildAt(i) as ILogic);
logic.doLogic();
};
i++;
};
}
}
}//package smileygamer
Section 91
//AProgressBar (smileygamer.AProgressBar)
package smileygamer {
import flash.display.*;
public class AProgressBar extends Shape {
private var fWidth:Number;
private var fValueChanged:Boolean;
private var fHorizontal:Boolean;
private var fValue:Number;
private var fHeight:Number;
private var fMaxValue:Number;
public function AProgressBar(aMaxValue:Number=1, aBeginValue:Number=0, aHorizontal:Boolean=true){
super();
fMaxValue = aMaxValue;
fValue = aBeginValue;
fHorizontal = aHorizontal;
fValueChanged = true;
}
public function set maxValue(aMaxValue:Number):void{
fMaxValue = aMaxValue;
if (fValue > fMaxValue){
fValue = fMaxValue;
};
}
protected function get valueChanged():Boolean{
return (fValueChanged);
}
public function set value(aValue:Number):void{
if (fValue != aValue){
fValueChanged = true;
};
fValue = aValue;
if (fValue < 0){
fValue = 0;
};
if (fValue > fMaxValue){
fValue = fMaxValue;
};
}
protected function get progress():Number{
fValueChanged = false;
if (fHorizontal){
return (((width * fValue) / fMaxValue));
};
return (((height * fValue) / fMaxValue));
}
override public function set width(aWidth:Number):void{
fWidth = aWidth;
}
override public function get height():Number{
return (fHeight);
}
public function get fraction():Number{
return ((fValue / fMaxValue));
}
public function get value():Number{
return (fValue);
}
override public function get width():Number{
return (fWidth);
}
public function get maxValue():Number{
return (fMaxValue);
}
override public function set height(aHeight:Number):void{
fHeight = aHeight;
}
}
}//package smileygamer
Section 92
//FadeAnimation (smileygamer.FadeAnimation)
package smileygamer {
import flash.display.*;
import smileygamer.util.*;
public class FadeAnimation extends AAnimation {
private var fSteps:int;
private var fValues:Array;
private var fMode:int;
private var fDelay:int;
public static const MODE_FADE_IN_OUT_REMOVE:int = 4;
public static const MODE_FADE_IN:int = 0;
public static const MODE_FADE_OUT:int = 1;
public static const MODE_FADE_IN_OUT:int = 3;
public static const MODE_FADE_OUT_REMOVE:int = 2;
public function FadeAnimation(aDisplayObject:DisplayObject, aSteps:int, aMode:int, aDelay:int=0){
var val2:Array;
var i:int;
fSteps = aSteps;
fMode = aMode;
fDelay = aDelay;
if (fMode == MODE_FADE_IN){
fValues = InterpolationUtil.createValues(InterpolationUtil.TYPE_COSINE, 0, 1, fSteps);
} else {
if ((((fMode == MODE_FADE_OUT)) || (MODE_FADE_OUT_REMOVE))){
fValues = InterpolationUtil.createValues(InterpolationUtil.TYPE_COSINE, 1, 0, fSteps);
} else {
fValues = InterpolationUtil.createValues(InterpolationUtil.TYPE_COSINE, 0, 1, (fSteps / 2));
val2 = InterpolationUtil.createValues(InterpolationUtil.TYPE_COSINE, 1, 0, (fSteps / 2));
i = 0;
while (i < val2.length) {
fValues.push(val2[i]);
i++;
};
};
};
super(aDisplayObject);
looping = false;
}
public function setFadeValues(aStart:Number, aEnd:Number):void{
fValues = InterpolationUtil.createValues(InterpolationUtil.TYPE_COSINE, aStart, aEnd, fSteps);
}
override protected function get frameCount():int{
return ((fSteps + fDelay));
}
override public function update():void{
if (frame >= fDelay){
displayObject.alpha = fValues[(frame - fDelay)];
if (fValues[(frame - fDelay)] > 0){
displayObject.visible = true;
} else {
displayObject.visible = false;
};
};
}
override public function get finished():Boolean{
var res:Boolean = super.finished;
if (((res) && ((((fMode == MODE_FADE_OUT_REMOVE)) || ((fMode == MODE_FADE_IN_OUT_REMOVE)))))){
displayObject.parent.removeChild(displayObject);
};
return (res);
}
}
}//package smileygamer
Section 93
//IAnimation (smileygamer.IAnimation)
package smileygamer {
public interface IAnimation {
function update():void;
function get finished():Boolean;
function get looping():Boolean;
}
}//package smileygamer
Section 94
//ILogic (smileygamer.ILogic)
package smileygamer {
public interface ILogic {
function doLogic():void;
}
}//package smileygamer
Section 95
//ImageAnimation (smileygamer.ImageAnimation)
package smileygamer {
import flash.display.*;
import flash.utils.*;
public class ImageAnimation extends AAnimation {
public function ImageAnimation(aImage:DisplayObject, aCopy:Boolean=false){
var targetClass:Class;
var obj:DisplayObject = aImage;
if (aCopy){
if ((aImage is Bitmap)){
obj = new Bitmap(Bitmap(aImage).bitmapData);
} else {
targetClass = (getDefinitionByName(getQualifiedClassName(aImage)) as Class);
obj = new (targetClass);
};
obj.x = aImage.x;
obj.y = aImage.y;
obj.transform = aImage.transform;
obj.filters = aImage.filters;
obj.cacheAsBitmap = aImage.cacheAsBitmap;
obj.opaqueBackground = aImage.opaqueBackground;
};
super(obj);
}
}
}//package smileygamer
Section 96
//ImageTransitionAnimation (smileygamer.ImageTransitionAnimation)
package smileygamer {
import flash.geom.*;
import flash.display.*;
import smileygamer.util.*;
public class ImageTransitionAnimation extends AAnimation {
private var fPointsPerStep:int;
private var fSteps:int;
private var fOrder:Array;
private var fRect:Rectangle;
private var fTopImage:Bitmap;
private var fBottomImage:Bitmap;
private var fOrigin:Point;
public function ImageTransitionAnimation(aTopImage:Bitmap, aBottomImage:Bitmap, aSteps:int){
var pointcount:int;
if (((!((aTopImage == null))) || (!((aBottomImage == null))))){
fTopImage = aTopImage;
if (fTopImage == null){
fTopImage = new Bitmap(new BitmapData(aBottomImage.width, aBottomImage.height, true, 0));
};
if (aBottomImage == null){
fBottomImage = new Bitmap(new BitmapData(fTopImage.width, fTopImage.height, true, 0));
} else {
fBottomImage = new Bitmap(aBottomImage.bitmapData);
};
if ((((fTopImage.width == fBottomImage.width)) && ((fTopImage.height == fBottomImage.height)))){
fSteps = aSteps;
pointcount = (fTopImage.width * fTopImage.height);
fOrder = RandomUtil.generateRandomArray(pointcount);
fPointsPerStep = Math.ceil((pointcount / (fSteps - 1)));
fRect = new Rectangle(0, 0, fTopImage.width, fTopImage.height);
fOrigin = new Point(0, 0);
super(new Bitmap(fTopImage.bitmapData.clone()));
looping = false;
} else {
throw (new Error("ImageTransitionAnimation: Both images have to have the same size!"));
};
} else {
throw (new Error("ImageTransitionAnimation: Both images can not be null!"));
};
}
override protected function get frameCount():int{
return (fSteps);
}
override public function update():void{
var start:int;
var i:int;
var x:int;
var y:int;
var bm:Bitmap = (displayObject as Bitmap);
if (frame == 0){
bm.bitmapData.copyPixels(fTopImage.bitmapData, fRect, fOrigin);
};
if (frame == (frameCount - 1)){
bm.bitmapData.copyPixels(fBottomImage.bitmapData, fRect, fOrigin);
} else {
start = (fPointsPerStep * frame);
bm.bitmapData.lock();
i = start;
while (i < (start + fPointsPerStep)) {
x = (fOrder[i] % bm.width);
y = int((fOrder[i] / bm.height));
bm.bitmapData.setPixel32(x, y, fBottomImage.bitmapData.getPixel32(x, y));
i++;
};
bm.bitmapData.unlock();
};
}
}
}//package smileygamer
Section 97
//MoveAnimation (smileygamer.MoveAnimation)
package smileygamer {
import flash.display.*;
import flash.geom.*;
import smileygamer.util.*;
public class MoveAnimation extends AAnimation {
private var fSteps:int;
private var fRemove:Boolean;
private var fXCoords:Array;
private var fYCoords:Array;
public function MoveAnimation(aDisplayObject:DisplayObject, aStartPos:Point, aStopPos:Point, aSteps:int, aType:int=0, aDelay:int=0, aRemove:Boolean=false, aReturnToStart:Boolean=false){
fSteps = (aSteps + aDelay);
fXCoords = new Array();
fYCoords = new Array();
var i:int;
while (i < aDelay) {
fXCoords.push(aStartPos.x);
fYCoords.push(aStartPos.y);
i++;
};
var xs:Array = InterpolationUtil.createValues(aType, aStartPos.x, aStopPos.x, aSteps);
var ys:Array = InterpolationUtil.createValues(aType, aStartPos.y, aStopPos.y, aSteps);
fXCoords.push(Math.round(xs[0]));
fYCoords.push(Math.round(ys[0]));
i = 1;
while (i < (xs.length - 1)) {
fXCoords.push(xs[i]);
fYCoords.push(ys[i]);
i++;
};
fXCoords.push(Math.round(xs[(xs.length - 1)]));
fYCoords.push(Math.round(ys[(xs.length - 1)]));
if (aReturnToStart){
fSteps = ((aSteps * 2) + aDelay);
i = (xs.length - 1);
while (i >= 0) {
fXCoords.push(fXCoords[i]);
fYCoords.push(fYCoords[i]);
i--;
};
};
fRemove = aRemove;
super(aDisplayObject);
looping = false;
}
override protected function get frameCount():int{
return (fSteps);
}
override public function get finished():Boolean{
var res:Boolean = super.finished;
if (((res) && (fRemove))){
displayObject.parent.removeChild(displayObject);
};
return (res);
}
override public function update():void{
displayObject.x = fXCoords[frame];
displayObject.y = fYCoords[frame];
}
}
}//package smileygamer
Section 98
//SGSprite (smileygamer.SGSprite)
package smileygamer {
import flash.events.*;
import flash.geom.*;
import flash.display.*;
import flash.utils.*;
public class SGSprite extends Sprite {
private var fState:String;// = "default"
private var fSpriteClone:DisplayObject;// = null
private var fAnimations:Object;
private var fClonePos:Point;// = null
public static const STATE_DEFAULT:String = "default";
public function SGSprite(){
fAnimations = new Object();
super();
addEventListener(Event.ENTER_FRAME, update);
}
public function set state(aState:String):void{
fState = aState;
var i:int = (numChildren - 1);
while (i >= 0) {
removeChildAt(i);
i--;
};
var animation:AAnimation = (fAnimations[fState] as AAnimation);
animation.reset();
addChild(animation.displayObject);
if (fClonePos != null){
fSpriteClone = clone(animation.displayObject);
fSpriteClone.x = fClonePos.x;
fSpriteClone.y = fClonePos.y;
addChild(fSpriteClone);
};
}
public function addAnimation(aState:String, aAnimation:AAnimation):void{
fAnimations[aState] = aAnimation;
if (state == aState){
state = aState;
};
}
public function update(e:Event):void{
var animation:AAnimation;
if (((!((fState == null))) && (!((fAnimations[fState] == null))))){
animation = (fAnimations[fState] as AAnimation);
if (animation.finished){
state = nextState();
};
};
}
private function clone(aObject:DisplayObject):DisplayObject{
var copy:DisplayObject;
var original:Bitmap;
var targetClass:Class;
if ((aObject is Bitmap)){
original = (aObject as Bitmap);
copy = new Bitmap(original.bitmapData);
} else {
targetClass = (getDefinitionByName(getQualifiedClassName(aObject)) as Class);
copy = new (targetClass);
};
copy.x = aObject.x;
copy.y = aObject.y;
copy.opaqueBackground = aObject.opaqueBackground;
copy.transform = aObject.transform;
copy.filters = aObject.filters;
copy.cacheAsBitmap = aObject.cacheAsBitmap;
var sprite:Sprite = new Sprite();
sprite.addChild(copy);
return (sprite);
}
public function set clonePos(aClonePos:Point):void{
var animation:AAnimation;
fClonePos = aClonePos;
if (fClonePos == null){
if (fSpriteClone != null){
removeChild(fSpriteClone);
};
fSpriteClone = null;
} else {
if (fSpriteClone == null){
animation = (fAnimations[fState] as AAnimation);
fSpriteClone = clone(animation.displayObject);
addChild(fSpriteClone);
};
fSpriteClone.x = fClonePos.x;
fSpriteClone.y = fClonePos.y;
};
}
public function get state():String{
return (fState);
}
public function get clonePos():Point{
return (fClonePos);
}
public function get finished():Boolean{
return (false);
}
protected function nextState():String{
return (STATE_DEFAULT);
}
}
}//package smileygamer
Section 99
//AdBox (AdBox)
package {
import flash.display.*;
public dynamic class AdBox extends MovieClip {
public function AdBox(){
super();
}
}
}//package
Section 100
//AdStrategy (AdStrategy)
package {
import flash.events.*;
import flash.display.*;
import mochi.as3.*;
import CPMStar.*;
public class AdStrategy {
private static const ONLY_SG_AD_DOMAINS:Array = ["kaisergames.de", "vo.llnwd.net", "y8.com", "kongregate.com", "gamesclub.com", "smalldressup.com", "freeonlinegames.com", "ungrounded.net", "media.jaludo.com", "rainbowdressup.com", "dressupgal.com"];
public static const ALL_ADS:int = 4;
public static const NO_ADS:int = 0;
public static const CPMSTAR_ADS:int = 3;
public static const SG_ADS:int = 1;
private static const NO_AD_DOMAINS:Array = ["www8.agame.com", "addictinggames.com", "armorgames.com", "www.flashgamelicense.com"];
private static const MOCHI_DOMAINS:Array = ["mochiads.com", "mochimedia.com", "mochigames.com"];
public static const MOCHI_ADS:int = 2;
private static var sDisplayCount:int = 0;
private static var sAdStrategy:int = -1;
public function AdStrategy(){
super();
}
public static function showClickAwayAdBox(aCPMStarID:String=null, aMochiID:String=null, aLoadedCallback:Function=null):AdBox{
var adloaded:Function;
var showad:Function;
var aCPMStarID = aCPMStarID;
var aMochiID = aMochiID;
var aLoadedCallback = aLoadedCallback;
adloaded = function (e:Event):void{
var w:Number;
var h:Number;
if (aLoadedCallback != null){
w = Loader(Sprite(e.target).getChildAt(0)).contentLoaderInfo.width;
h = Loader(Sprite(e.target).getChildAt(0)).contentLoaderInfo.height;
aLoadedCallback.apply(Sprite(e.target), [w, h]);
};
};
showad = function (e:Event):void{
var cpmAd:AdLoader;
sDisplayCount++;
if (((!((aCPMStarID == null))) && ((((strategy == CPMSTAR_ADS)) || ((((strategy == ALL_ADS)) && ((aMochiID == null)))))))){
if ((sDisplayCount % 2) == 1){
cpmAd = new AdLoader(aCPMStarID);
if (aLoadedCallback != null){
cpmAd.addEventListener(Event.COMPLETE, adloaded);
};
AdBox(e.target).addChild(cpmAd);
} else {
AdBox(e.target).addEventListener(Event.COMPLETE, adloaded);
SmileyGamer.showSGAd(AdBox(e.target));
};
return;
};
if (((!((aMochiID == null))) && ((((strategy == MOCHI_ADS)) || ((((strategy > MOCHI_ADS)) && ((aCPMStarID == null)))))))){
if ((sDisplayCount % 3) == 2){
AdBox(e.target).addEventListener(Event.COMPLETE, aLoadedCallback);
SmileyGamer.showSGAd(AdBox(e.target));
} else {
MochiAd.showClickAwayAd({clip:AdBox(e.target), id:aMochiID, ad_loaded:aLoadedCallback});
};
return;
};
if ((((((strategy == ALL_ADS)) && (!((aCPMStarID == null))))) && (!((aMochiID == null))))){
if ((sDisplayCount % 3) == 0){
MochiAd.showClickAwayAd({clip:AdBox(e.target), id:aMochiID, ad_loaded:aLoadedCallback});
} else {
if ((sDisplayCount % 3) == 2){
AdBox(e.target).addEventListener(Event.COMPLETE, adloaded);
SmileyGamer.showSGAd(AdBox(e.target));
} else {
cpmAd = new AdLoader(aCPMStarID);
if (aLoadedCallback != null){
cpmAd.addEventListener(Event.COMPLETE, adloaded);
};
AdBox(e.target).addChild(cpmAd);
};
};
return;
};
AdBox(e.target).addEventListener(Event.COMPLETE, adloaded);
SmileyGamer.showSGAd(AdBox(e.target));
};
var adbox:AdBox = new AdBox();
adbox.addEventListener(Event.ADDED_TO_STAGE, showad);
return (adbox);
}
public static function get clickAwayAd():Boolean{
return (!((strategy == NO_ADS)));
}
private static function determineStrategy():void{
if (SmileyGamer.isInDomains(NO_AD_DOMAINS)){
sAdStrategy = NO_ADS;
return;
};
if (SmileyGamer.isInDomains(ONLY_SG_AD_DOMAINS)){
sAdStrategy = SG_ADS;
return;
};
if (SmileyGamer.isInDomains(MOCHI_DOMAINS)){
sAdStrategy = MOCHI_ADS;
return;
};
sAdStrategy = ALL_ADS;
}
public static function showPreloaderAdBox(aCPMStarID:String=null, aMochiID:String=null, aLoadedCallback:Function=null):AdBox{
var adloaded:Function;
var showad:Function;
var aCPMStarID = aCPMStarID;
var aMochiID = aMochiID;
var aLoadedCallback = aLoadedCallback;
adloaded = function (e:Event):void{
var w:Number;
var h:Number;
if (aLoadedCallback != null){
w = Loader(Sprite(e.target).getChildAt(0)).contentLoaderInfo.width;
h = Loader(Sprite(e.target).getChildAt(0)).contentLoaderInfo.height;
aLoadedCallback.apply(Sprite(e.target), [w, h]);
};
};
showad = function (e:Event):void{
var cpmAd:AdLoader;
if ((((((strategy == ALL_ADS)) || ((strategy == CPMSTAR_ADS)))) && (!((aCPMStarID == null))))){
cpmAd = new AdLoader(aCPMStarID);
if (aLoadedCallback != null){
cpmAd.addEventListener(Event.COMPLETE, adloaded);
};
AdBox(e.target).addChild(cpmAd);
return;
};
if ((((strategy >= MOCHI_ADS)) && (!((aMochiID == null))))){
MochiAd.showClickAwayAd({clip:AdBox(e.target), id:aMochiID, ad_loaded:aLoadedCallback});
return;
};
AdBox(e.target).addEventListener(Event.COMPLETE, adloaded);
SmileyGamer.showSGAd(AdBox(e.target));
};
var adbox:AdBox = new AdBox();
adbox.addEventListener(Event.ADDED_TO_STAGE, showad);
return (adbox);
}
public static function get strategy():int{
if (sAdStrategy == -1){
determineStrategy();
};
return (sAdStrategy);
}
public static function get preloaderAd():Boolean{
return ((((strategy >= 2)) && (!(SmileyGamer.isHome()))));
}
}
}//package
Section 101
//ChristmasMemory (ChristmasMemory)
package {
import flash.events.*;
import smileygamer.*;
import flash.display.*;
import christmasmemory.gameplay.*;
import flash.text.*;
import christmasmemory.*;
import flash.utils.*;
import mochi.as3.*;
import flash.net.*;
import flash.ui.*;
public dynamic class ChristmasMemory extends AGame {
private var fMLTimer:Timer;
private var fFrame:int;// = 0
private var fFPSTime:int;
private var fHand:HandSprite;
private var fFPSField:TextField;
public static const BFG:Boolean = false;
public static const GAMEID:int = 2116;
public static const DIFF_VERYHARD:int = 3;
public static const DIFF_NORMAL:int = 1;
public static const DOWNLOADABLE:Boolean = false;
public static const DIFF_HARD:int = 2;
public static const DIFF_EASY:int = 0;
public static var NOSCORE:Boolean = false;
public static var KAISERGAMES:Boolean = false;
public static var LOWFPS:Boolean = false;
public static var SPONSORED:Boolean = false;
public static var MINDJOLT:Boolean = false;
public static var MindJoltAPI:Object;
public function ChristmasMemory(){
var added:Function;
fHand = new HandSprite();
added = function (e:Event):void{
var gameParams:Object;
var urlLoader:Loader;
var e = e;
removeEventListener(Event.ADDED, added);
NOSCORE = SmileyGamer.isDomain("www8.agame.com");
MINDJOLT = SmileyGamer.isDomain("mindjolt.com");
if (MINDJOLT){
var loadFinished:Function = function (e:Event):void{
MindJoltAPI = e.currentTarget.content;
MindJoltAPI.service.connect();
trace("[MindJoltAPI] service manually loaded");
};
gameParams = LoaderInfo(root.loaderInfo).parameters;
urlLoader = new Loader();
urlLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadFinished);
urlLoader.load(new URLRequest(((gameParams.mjPath) || ("http://static.mindjolt.com/api/as3/scoreapi_as3_local.swf"))));
addChild(urlLoader);
} else {
MochiServices.connect("3bbd91de01aa4142", root);
};
fFPSTime = getTimer();
Mouse.show();
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseUpdate);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpdate);
stage.addEventListener(MouseEvent.CLICK, mouseUpdate);
addChild(fHand);
fHand.x = mouseX;
fHand.y = mouseY;
showTitleScreen();
};
super();
SaveData.init();
addEventListener(Event.ADDED, added);
}
public function showGameScreen(aDifficulty:int, aSavedGame:Boolean):void{
var levelGame:ILevelGame;
var screen:GameScreen;
var params:Object;
if (aSavedGame){
params = SaveData.getSavedGame(aDifficulty);
switch (aDifficulty){
case DIFF_EASY:
levelGame = new EasyLevelGame(params.level);
break;
case DIFF_NORMAL:
levelGame = new NormalLevelGame(params.level);
break;
case DIFF_HARD:
levelGame = new HardLevelGame(params.level);
break;
case DIFF_VERYHARD:
levelGame = new VeryHardLevelGame(params.level);
break;
};
screen = new GameScreen(this, levelGame, params);
} else {
switch (aDifficulty){
case DIFF_EASY:
levelGame = new EasyLevelGame();
break;
case DIFF_NORMAL:
levelGame = new NormalLevelGame();
break;
case DIFF_HARD:
levelGame = new HardLevelGame();
break;
case DIFF_VERYHARD:
levelGame = new VeryHardLevelGame();
break;
};
screen = new GameScreen(this, levelGame);
};
removeChildAt(0);
addChildAt(screen, 0);
}
public function showSponsorSite():void{
SmileyGamer.showHome();
}
public function isHomeSite():Boolean{
return (((SPONSORED) || (SmileyGamer.isHome())));
}
public function mouseUpdate(aEvent:MouseEvent):void{
if (aEvent.type == MouseEvent.CLICK){
} else {
fHand.button(aEvent.buttonDown);
};
}
public function showTitleScreen():void{
addChildAt(new TitleScreen(this), 0);
SoundManager.playMusic();
}
public function showSGSite():void{
SmileyGamer.showHome();
}
public function submitScore(aName:String, aScore:int, aMode:int=0, aListener:Function=null):void{
var closeML:Function;
var aName = aName;
var aScore = aScore;
var aMode = aMode;
var aListener = aListener;
closeML = function (e:Event):void{
MochiScores.closeLeaderboard();
aListener.call(this);
};
if (NOSCORE){
if (aListener != null){
aListener.call(this);
};
return;
};
fMLTimer = new Timer(7000, 1);
fMLTimer.addEventListener(TimerEvent.TIMER_COMPLETE, closeML);
fMLTimer.start();
Mouse.show();
var boardCode:Array = [9, 2, 7, 3, 3, 7, 1, 14, 5, 7, 0, 5, 14, 2, 5, 6];
if (aMode == DIFF_NORMAL){
boardCode = [9, 4, 4, 11, 6, 8, 13, 2, 0, 13, 8, 14, 10, 15, 6, 15];
};
if (aMode == DIFF_HARD){
boardCode = [14, 3, 8, 15, 8, 4, 8, 1, 9, 6, 11, 4, 8, 2, 10, 13];
};
if (aMode == DIFF_VERYHARD){
boardCode = [11, 2, 9, 14, 15, 6, 7, 3, 13, 5, 3, 12, 9, 15, 3, 4];
};
var o:Object = {n:boardCode, f:function (i:Number, s:String):String{
if (s.length == 16){
return (s);
};
return (this.f((i + 1), (s + this.n[i].toString(16))));
}};
var boardID:String = o.f(0, "");
MochiScores.showLeaderboard({boardID:boardID, score:aScore, onDisplay:function (){
fMLTimer.stop();
}, onClose:aListener, showTableRank:true, scoreMessage:{highscore:"Beat my highscore of ${highscore} on ${board} in ${game}!", latestscore:"I just scored ${score} on ${board} in ${game}!", gameinvite:"Come play ${game}!"}});
}
override public function mainLoop(aEvent:Event):void{
var fps:int;
super.mainLoop(aEvent);
fHand.move(stage.mouseX, stage.mouseY);
fFrame++;
if ((fFrame % 30) == 0){
fps = int(((fFrame * 1000) / (getTimer() - fFPSTime)));
LOWFPS = (fps < 20);
fFrame = 0;
fFPSTime = getTimer();
};
}
public function showHighscoresPage():void{
SmileyGamer.showHighscores();
}
public function showAwardsScreen():void{
var awards:AwardsScreen = new AwardsScreen(this);
removeChildAt(0);
addChildAt(awards, 0);
}
}
}//package
Section 102
//CobrandingUtil (CobrandingUtil)
package {
import flash.events.*;
import flash.display.*;
public class CobrandingUtil {
private static var sConfig:Object = null;
public function CobrandingUtil(){
super();
}
public static function getIntroLogo():Sprite{
var logo:DisplayObject;
if (sConfig == null){
return (null);
};
var coLogo:Sprite = new Sprite();
if ((((sConfig.domain == null)) || (SmileyGamer.isDomain(sConfig.domain)))){
logo = DisplayObject(sConfig.logo);
if (sConfig.logoTf != null){
logo.transform.matrix = sConfig.logoTf;
};
coLogo.addChild(logo);
} else {
return (null);
};
if (sConfig.logoURL != null){
var coclick:Function = function (e:Event):void{
SmileyGamer.showURL(sConfig.logoURL);
};
coLogo.addEventListener(MouseEvent.CLICK, coclick);
coLogo.buttonMode = true;
};
return (coLogo);
}
public static function getMochiBot():String{
return (((sConfig == null)) ? null : sConfig.mochibot);
}
public static function getSmallLogo():Sprite{
var logo:DisplayObject;
if (sConfig == null){
return (null);
};
var coLogo:Sprite = new Sprite();
if ((((sConfig.domain == null)) || (SmileyGamer.isDomain(sConfig.domain)))){
logo = ((sConfig.smallLogo)!=null) ? DisplayObject(sConfig.smallLogo) : DisplayObject(sConfig.logo);
if (sConfig.smallTf != null){
logo.transform.matrix = sConfig.smallTf;
};
coLogo.addChild(logo);
} else {
return (null);
};
if (sConfig.logoURL != null){
var coclick:Function = function (e:Event):void{
SmileyGamer.showURL(sConfig.logoURL);
};
coLogo.addEventListener(MouseEvent.CLICK, coclick);
coLogo.buttonMode = true;
};
return (coLogo);
}
}
}//package
Section 103
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public function MochiBot(){
super();
}
public static function track(parent:Sprite, tag:String):MochiBot{
if (Security.sandboxType == "localWithFile"){
return (null);
};
var self:MochiBot = new (MochiBot);
parent.addChild(self);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
var server:String = "http://core.mochibot.com/my/core.swf";
var lv:URLVariables = new URLVariables();
lv["sb"] = Security.sandboxType;
lv["v"] = Capabilities.version;
lv["swfid"] = tag;
lv["mv"] = "8";
lv["fv"] = "9";
var url:String = self.root.loaderInfo.loaderURL;
if (url.indexOf("http") == 0){
lv["url"] = url;
} else {
lv["url"] = "local";
};
var req:URLRequest = new URLRequest(server);
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
var loader:Loader = new Loader();
self.addChild(loader);
loader.load(req);
return (self);
}
}
}//package
Section 104
//PreloaderFactory (PreloaderFactory)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import smileygamer.*;
import smileygamer.util.*;
import christmasmemory.*;
import flash.filters.*;
public dynamic class PreloaderFactory extends MovieClip {
private var fAdBox:Sprite;
private var fIntro:Sprite;
private var fStartTime:int;
private var fPlayButton:SimpleButton;
private var fProgress:Shape;
private var PlayButtonSel:Class;
private var PlayButton:Class;
private var fLoadTime:int;
private var fShowAd:Boolean;
private static const MAIN_CLASS:String = "ChristmasMemory";
public static const WIDTH:int = 500;
public static const HEIGHT:int = 360;
private static const SG_COLOR:int = 3353614;
private static var SGLogo:Class = PreloaderFactory_SGLogo;
public function PreloaderFactory(){
var playgame:Function;
var border:Shape;
PlayButton = PreloaderFactory_PlayButton;
PlayButtonSel = PreloaderFactory_PlayButtonSel;
playgame = function (e:Event):void{
var t:Timer;
if (fShowAd){
showIntro();
new FadeAnimation(fAdBox, 20, FadeAnimation.MODE_FADE_OUT_REMOVE);
new FadeAnimation(fPlayButton, 20, FadeAnimation.MODE_FADE_OUT_REMOVE);
t = new Timer(5000, 1);
t.addEventListener(TimerEvent.TIMER_COMPLETE, init);
t.start();
} else {
init();
};
};
super();
var f:Function = function (e:IOErrorEvent):void{
};
loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
stage.frameRate = 32;
stage.scaleMode = StageScaleMode.NO_SCALE;
stop();
SmileyGamer.init(stage, 2116, "Christmas Memory");
fLoadTime = 7000;
fShowAd = false;
addChild(new Background());
fStartTime = getTimer();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
addEventListener(Event.ENTER_FRAME, displayed);
if (fShowAd){
var adloaded:Function = function (w:Number, h:Number):void{
if (w > 300){
fAdBox.getChildAt(1).x = ((WIDTH - w) / 2);
};
if (h > 250){
fAdBox.getChildAt(1).y = (((HEIGHT - h) / 2) - 15);
};
};
fAdBox = new Sprite();
border = new Shape();
border.graphics.beginFill(3353614, 0.5);
border.graphics.drawRoundRect(-5, -5, 310, 260, 15, 15);
border.graphics.endFill();
border.filters = [new GlowFilter(3353614, 0.75, 4, 4, 2, BitmapFilterQuality.HIGH)];
fAdBox.addChild(border);
fAdBox.addChild(AdStrategy.showPreloaderAdBox("1243Q17E5984C", "3bbd91de01aa4142", adloaded));
fAdBox.x = ((WIDTH - 310) / 2);
fAdBox.y = (((HEIGHT - 260) / 2) - 10);
addChild(fAdBox);
} else {
showIntro();
};
fProgress = new Shape();
fProgress.filters = [new GlowFilter(SG_COLOR, 0.75, 2, 2, 2, BitmapFilterQuality.HIGH)];
addChild(fProgress);
var playBtn:DisplayObject = new PlayButton();
var playbackground:Shape = new Shape();
playbackground.graphics.beginFill(0, 1);
playbackground.graphics.drawRect(-3, -3, (playBtn.width + 5), (playBtn.height + 5));
fPlayButton = new SimpleButton(playBtn, new PlayButtonSel(), new PlayButtonSel(), playbackground);
fPlayButton.x = 200;
fPlayButton.y = 320;
fPlayButton.addEventListener(MouseEvent.CLICK, playgame);
}
public function onEnterFrame(event:Event):void{
var p1:Number;
var p2:Number;
var percent:Number;
if ((((framesLoaded == totalFrames)) && (((getTimer() - fStartTime) > fLoadTime)))){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
fProgress.graphics.clear();
fProgress.graphics.lineStyle(1, SG_COLOR);
fProgress.graphics.drawRect(10, (HEIGHT - 30), (WIDTH - 20), 10);
fProgress.graphics.beginFill(SG_COLOR);
fProgress.graphics.drawRect(11, (HEIGHT - 29), (WIDTH - 22), 8);
fProgress.graphics.endFill();
removeChild(fProgress);
addChild(fPlayButton);
} else {
if (fProgress != null){
p1 = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
p2 = ((getTimer() - fStartTime) / fLoadTime);
percent = Math.min(p1, p2, 1);
fProgress.graphics.clear();
fProgress.graphics.lineStyle(1, SG_COLOR);
fProgress.graphics.drawRect(10, (HEIGHT - 30), (WIDTH - 20), 10);
fProgress.graphics.beginFill(SG_COLOR);
fProgress.graphics.drawRect(11, (HEIGHT - 29), ((WIDTH - 22) * percent), 8);
fProgress.graphics.endFill();
};
};
}
private function clicked(e:Event):void{
SmileyGamer.showHome();
}
private function showIntro():void{
fIntro = new Sprite();
fIntro.addChild(new SGLogo());
fIntro.x = ((WIDTH - 400) / 2);
fIntro.y = ((HEIGHT - 280) / 2);
if (!fShowAd){
fIntro.y = (fIntro.y - 10);
};
addChild(fIntro);
new MoveAnimation(fIntro, new Point((WIDTH + 10), fIntro.y), new Point(fIntro.x, fIntro.y), 30, InterpolationUtil.TYPE_COSINE);
if (!SmileyGamer.isHome()){
var clicked:Function = function (e:Event):void{
SmileyGamer.showHome();
};
fIntro.addEventListener(MouseEvent.CLICK, clicked);
fIntro.buttonMode = true;
};
}
private function displayed(e:Event):void{
removeEventListener(Event.ENTER_FRAME, displayed);
MochiBot.track(this, "8b27b4b1");
}
public function init(e:Event=null):void{
var mainClass:Class;
var app:Object;
var e = e;
nextFrame();
mainClass = (getDefinitionByName(MAIN_CLASS) as Class);
app = new (mainClass);
addChildAt((app as DisplayObject), 1);
if (!fShowAd){
new FadeAnimation(fPlayButton, 20, FadeAnimation.MODE_FADE_OUT_REMOVE);
};
new MoveAnimation(fIntro, new Point(fIntro.x, fIntro.y), new Point(-420, fIntro.y), 20, InterpolationUtil.TYPE_COSINE, 0, true);
//unresolved jump
var _slot1 = re;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package
Section 105
//PreloaderFactory_PlayButton (PreloaderFactory_PlayButton)
package {
import mx.core.*;
import flash.utils.*;
public class PreloaderFactory_PlayButton extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function PreloaderFactory_PlayButton(){
dataClass = PreloaderFactory_PlayButton_dataClass;
super();
initialWidth = (2040 / 20);
initialHeight = (560 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 106
//PreloaderFactory_PlayButton_dataClass (PreloaderFactory_PlayButton_dataClass)
package {
import mx.core.*;
public class PreloaderFactory_PlayButton_dataClass extends ByteArrayAsset {
}
}//package
Section 107
//PreloaderFactory_PlayButtonSel (PreloaderFactory_PlayButtonSel)
package {
import mx.core.*;
import flash.utils.*;
public class PreloaderFactory_PlayButtonSel extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function PreloaderFactory_PlayButtonSel(){
dataClass = PreloaderFactory_PlayButtonSel_dataClass;
super();
initialWidth = (2040 / 20);
initialHeight = (560 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 108
//PreloaderFactory_PlayButtonSel_dataClass (PreloaderFactory_PlayButtonSel_dataClass)
package {
import mx.core.*;
public class PreloaderFactory_PlayButtonSel_dataClass extends ByteArrayAsset {
}
}//package
Section 109
//PreloaderFactory_SGLogo (PreloaderFactory_SGLogo)
package {
import mx.core.*;
import flash.utils.*;
public class PreloaderFactory_SGLogo extends MovieClipLoaderAsset {
public var dataClass:Class;
private static var bytes:ByteArray = null;
public function PreloaderFactory_SGLogo(){
dataClass = PreloaderFactory_SGLogo_dataClass;
super();
initialWidth = (8000 / 20);
initialHeight = (5600 / 20);
}
override public function get movieClipData():ByteArray{
if (bytes == null){
bytes = ByteArray(new dataClass());
};
return (bytes);
}
}
}//package
Section 110
//PreloaderFactory_SGLogo_dataClass (PreloaderFactory_SGLogo_dataClass)
package {
import mx.core.*;
public class PreloaderFactory_SGLogo_dataClass extends ByteArrayAsset {
}
}//package
Section 111
//SmileyGamer (SmileyGamer)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
import flash.external.*;
public class SmileyGamer {
public static const HOME:String = "http://www.smileygamer.com";
private static var sGame:String;
private static var sStage:Stage;
private static var sID:int;
private static var sReferer:String;
public function SmileyGamer(){
super();
}
public static function isInDomains(aDomains:Array):Boolean{
var allowed:Boolean;
var i:int;
while (i < aDomains.length) {
allowed = ((allowed) || (isDomain(aDomains[i])));
i++;
};
return (allowed);
}
public static function showSGMoreGamesTab(aClip:DisplayObjectContainer, aColor:uint=4281543694):void{
var aClip = aClip;
var aColor = aColor;
Security.allowDomain("smileygamer.com");
var url = "http://www.smileygamer.com/sgads/SGMoreGamesTab.swf";
var ldr:Loader = new Loader();
ldr.load(new URLRequest(((((url + "?gameid=") + sID) + "&color=") + aColor)));
//unresolved jump
var _slot1 = e;
aClip.addChild(ldr);
}
public static function init(aStage:Stage, aID:int, aGame:String):void{
sStage = aStage;
sID = aID;
sGame = aGame;
sReferer = getReferer();
}
public static function showSGAd(aClip:DisplayObjectContainer):void{
var dispatchHandler:Function;
var aClip = aClip;
dispatchHandler = function (event:Event):void{
aClip.dispatchEvent(event);
};
Security.allowDomain("smileygamer.com");
var url = "http://www.smileygamer.com/sgads/SGMoreGamesAd.swf";
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
ldr.load(new URLRequest(((((url + "?gameid=") + sID) + "&siteref=") + sReferer)));
//unresolved jump
var _slot1 = e;
aClip.addChild(ldr);
}
public static function isDomain(aDomain:String):Boolean{
if (((isLocal()) && ((sStage.loaderInfo.loaderURL.toLowerCase().indexOf(aDomain) > -1)))){
return (true);
};
return ((((sReferer.indexOf(aDomain) == 0)) || (((!((sReferer.indexOf(("." + aDomain)) == -1))) && ((sReferer.indexOf(("." + aDomain)) == ((sReferer.length - aDomain.length) - 1)))))));
}
public static function submitScore(aName:String, aScore:int, aMode:int=0, aRankListener:Function=null):void{
var rank:int;
var loader:URLLoader;
var error:Function;
var infoReceived:Function;
var aName = aName;
var aScore = aScore;
var aMode = aMode;
var aRankListener = aRankListener;
error = function (aEvent:Event):void{
rank = -1;
if (aRankListener != null){
aRankListener.call(null, rank);
};
};
infoReceived = function (aEvent:Event):void{
rank = int(loader.data);
if (aRankListener != null){
aRankListener.call(null, rank);
};
};
rank = 0;
var score:int = ((aScore * 100) + (aScore % 97));
var url:String = ((((((((HOME + "/scripts/highscores.php?id=") + sID) + "&mode=") + aMode) + "&score=") + score) + "&player=") + aName);
var req:URLRequest = new URLRequest(url);
loader = new URLLoader(req);
loader.addEventListener(IOErrorEvent.IO_ERROR, error);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
loader.addEventListener(Event.COMPLETE, infoReceived);
}
public static function showHighscores():void{
showURL((((((HOME + "/highscores/") + sID) + "/") + getGameSlug()) + ".html"), true);
}
public static function isLocal():Boolean{
return ((sReferer == "local"));
}
public static function showGameAtHome():void{
showURL(((((((HOME + "/play/") + sID) + "/") + getGameSlug()) + ".html?gameref=") + sID));
}
public static function isHome():Boolean{
return (isDomain("smileygamer.com"));
}
public static function showFreeContent():void{
showURL((HOME + "/freecontent.html"), true);
}
public static function showURL(aURL:String, aAddRef:Boolean=false):void{
var aURL = aURL;
var aAddRef = aAddRef;
if (aAddRef){
aURL = ((aURL + "?gameref=") + sID);
};
ExternalInterface.call("window.open", aURL, "_blank", "");
//unresolved jump
var _slot1 = e;
navigateToURL(new URLRequest(aURL), "_blank");
//unresolved jump
var _slot1 = e;
}
public static function getGameSlug():String{
var name:String = sGame.toLowerCase();
name = name.replace(/\s/g, "-");
return (name);
}
public static function getReferer():String{
var referer:String;
if (sStage != null){
referer = sStage.loaderInfo.loaderURL.toLowerCase();
if (referer.indexOf("file://") == 0){
referer = "local";
} else {
referer = referer.split("/")[2];
};
return (referer);
//unresolved jump
};
return ("");
}
public static function showHome():void{
showURL(HOME, true);
}
}
}//package