Section 1
//IdmGameMode (com.darkmoon.enigmatica.IdmGameMode)
package com.darkmoon.enigmatica {
public interface IdmGameMode {
function get points():int;
function get level():int;
function get maxMoves():int;
function boardCompleted(_arg1:int, _arg2:int):int;
function get timeLimit():int;
}
}//package com.darkmoon.enigmatica
Section 2
//TdmBlinkAnimation (com.darkmoon.enigmatica.TdmBlinkAnimation)
package com.darkmoon.enigmatica {
import flash.display.*;
import com.darkmoon.*;
public class TdmBlinkAnimation extends AdmAnimation {
public function TdmBlinkAnimation(_arg1:DisplayObject){
super(_arg1);
}
override protected function get frameCount():int{
return (20);
}
override public function update():void{
displayObject.visible = (frame < 12);
}
}
}//package com.darkmoon.enigmatica
Section 3
//TdmBoard (com.darkmoon.enigmatica.TdmBoard)
package com.darkmoon.enigmatica {
import flash.display.*;
import com.darkmoon.*;
import com.darkmoon.util.*;
public class TdmBoard extends Sprite implements IdmLogic {
private var fOriginalField:Array;
private var fMoves:int;
private var fGrabbing:Boolean;
private var fField:Array;
private var fLockedCol:int;
private var fTileSize:int;
private var fSize:int;
private var fGrabbedCol:int;
private var fLockedRow:int;
private var fGrabbedTile:TdmTile;
private var fGrabbedX:int;
private var fGrabbedY:int;
private var fGrabbedRow:int;
private static const TILE_SIZES:Array = new Array(75, 60, 50, 43, 38);
public static var SIZE:int = 300;
public function TdmBoard(_arg1:int){
this.size = _arg1;
mouseEnabled = false;
}
public function get size():int{
return (fSize);
}
private function isTooEasy():Boolean{
var _local1:int;
var _local2:Boolean;
var _local3:Boolean;
var _local4:int;
_local1 = 0;
while (_local1 < fSize) {
_local2 = true;
_local3 = true;
_local4 = 1;
while (_local4 < fSize) {
_local2 = ((_local2) && ((fOriginalField[(_local1 * fSize)] == fOriginalField[((_local1 * fSize) + _local4)])));
_local3 = ((_local3) && ((fOriginalField[_local1] == fOriginalField[((_local4 * fSize) + _local1)])));
_local4++;
};
if (((_local2) || (_local3))){
return (true);
};
_local1++;
};
return (false);
}
private function movedColumnDir(_arg1:Boolean):void{
var _local2:int;
var _local3:int;
if (fGrabbedRow != fGrabbedTile.row){
if (_arg1){
_local2 = (((fGrabbedTile.row - fGrabbedRow) + fSize) % fSize);
_local3 = 0;
while (_local3 < _local2) {
moved();
_local3++;
};
} else {
_local2 = (((fGrabbedRow - fGrabbedTile.row) + fSize) % fSize);
_local3 = 0;
while (_local3 < _local2) {
moved();
_local3++;
};
};
fGrabbedRow = fGrabbedTile.row;
};
}
public function set size(_arg1:int):void{
fSize = _arg1;
fTileSize = TILE_SIZES[(fSize - 4)];
SIZE = (fSize * fTileSize);
fMoves = 0;
fOriginalField = new Array((fSize * fSize));
fField = new Array((fSize * fSize));
newBoard();
}
private function slideInPosition():void{
var _local1:int;
var _local2:TdmTile;
_local1 = 0;
while (_local1 < numChildren) {
_local2 = (getChildAt(_local1) as TdmTile);
_local2.slideInPosition();
_local1++;
};
}
public function newBoard():void{
var _local1:Array;
var _local2:int;
_local1 = TdmRandomUtil.generateRandomArray(8);
fOriginalField = TdmRandomUtil.generateRandomArray((fSize * fSize));
_local2 = 0;
while (_local2 < fOriginalField.length) {
fOriginalField[_local2] = _local1[(fOriginalField[_local2] % fSize)];
_local2++;
};
if (isTooEasy()){
newBoard();
} else {
resetBoard();
};
fGrabbing = false;
fLockedRow = -1;
fLockedCol = -1;
fGrabbedRow = -1;
fGrabbedCol = -1;
fGrabbedX = -1;
fGrabbedY = -1;
fGrabbedTile = null;
}
private function movedRow():void{
if ((((((fGrabbedCol + 1) % fSize) == fGrabbedTile.column)) || ((fGrabbedCol == ((fGrabbedTile.column + 1) % fSize))))){
fGrabbedCol = fGrabbedTile.column;
moved();
};
}
private function drag(_arg1:int, _arg2:int):void{
var _local3:int;
var _local4:TdmTile;
var _local5:int;
var _local6:Boolean;
if ((((fLockedCol == -1)) && ((fLockedRow == -1)))){
if (Math.abs((fGrabbedX - _arg1)) > 10){
fLockedRow = (_arg2 / fTileSize);
} else {
if (Math.abs((fGrabbedY - _arg2)) > 10){
fLockedCol = (_arg1 / fTileSize);
};
};
_local3 = 0;
while (_local3 < numChildren) {
_local4 = (getChildAt(_local3) as TdmTile);
if (_local4.containsPoint(fGrabbedX, fGrabbedY)){
fGrabbedTile = _local4;
fGrabbedRow = fGrabbedTile.row;
fGrabbedCol = fGrabbedTile.column;
};
_local3++;
};
};
if (fLockedCol > -1){
_local5 = (_arg2 - fGrabbedY);
_local6 = moveColumn(_local5);
fGrabbedY = _arg2;
movedColumnDir((_local5 > 0));
};
if (fLockedRow > -1){
_local5 = (_arg1 - fGrabbedX);
_local6 = moveRow(_local5);
fGrabbedX = _arg1;
movedRowDir((_local5 > 0));
};
}
public function isCompleted():Boolean{
var _local1:Boolean;
var _local2:Array;
var _local3:int;
var _local4:int;
_local1 = true;
_local2 = new Array((fSize * fSize));
_local3 = 0;
while (_local3 < fSize) {
_local4 = 0;
while (_local4 < fSize) {
_local1 = ((_local1) && ((fField[(_local4 * fSize)] == fField[((_local4 * fSize) + _local3)])));
_local4++;
};
_local3++;
};
if (!_local1){
_local1 = true;
_local3 = 0;
while (_local3 < fSize) {
_local4 = 0;
while (_local4 < fSize) {
_local1 = ((_local1) && ((fField[_local3] == fField[((_local4 * fSize) + _local3)])));
_local4++;
};
_local3++;
};
};
return (_local1);
}
private function moveRow(_arg1:int):Boolean{
var _local2:Boolean;
var _local3:int;
var _local4:TdmTile;
_local2 = false;
_local3 = 0;
while (_local3 < numChildren) {
_local4 = (getChildAt(_local3) as TdmTile);
if (_local4.row == fLockedRow){
_local4.x = (_local4.x + _arg1);
_local4.selected = true;
_local2 = _local4.isXLocked();
};
_local3++;
};
return (_local2);
}
public function grab(_arg1:int, _arg2:int):Boolean{
if ((((((((_arg1 < 0)) || ((_arg1 >= SIZE)))) || ((_arg2 < 0)))) || ((_arg2 >= SIZE)))){
return (false);
};
if ((((fGrabbedX == -1)) && ((fGrabbedY == -1)))){
fGrabbedX = _arg1;
fGrabbedY = _arg2;
return (true);
};
return (false);
}
private function moveColumn(_arg1:int):Boolean{
var _local2:Boolean;
var _local3:int;
var _local4:TdmTile;
_local2 = false;
_local3 = 0;
while (_local3 < numChildren) {
_local4 = (getChildAt(_local3) as TdmTile);
if (_local4.column == fLockedCol){
_local4.y = (_local4.y + _arg1);
_local4.selected = true;
_local2 = _local4.isYLocked();
};
_local3++;
};
return (_local2);
}
public function doLogic():void{
var _local1:int;
var _local2:TdmTile;
_local1 = 0;
while (_local1 < numChildren) {
_local2 = (getChildAt(_local1) as TdmTile);
_local2.doLogic();
_local1++;
};
}
private function moved():void{
var _local1:int;
var _local2:TdmTile;
fMoves++;
TdmSoundManager.playClick();
_local1 = 0;
while (_local1 < numChildren) {
_local2 = (getChildAt(_local1) as TdmTile);
fField[((_local2.row * fSize) + _local2.column)] = _local2.type;
_local1++;
};
}
public function get moves():int{
return (fMoves);
}
public function demoBoard():void{
size = 4;
fOriginalField = new Array(0, 0, 0, 3, 1, 2, 1, 0, 1, 3, 2, 3, 3, 1, 2, 2);
resetBoard();
fGrabbing = false;
fLockedRow = -1;
fLockedCol = -1;
fGrabbedRow = -1;
fGrabbedCol = -1;
fGrabbedX = -1;
fGrabbedY = -1;
fGrabbedTile = null;
}
public function mouseUpdate(_arg1:int, _arg2:int, _arg3:Boolean):void{
var _local4:int;
var _local5:TdmTile;
_local4 = 0;
while (_local4 < numChildren) {
_local5 = (getChildAt(_local4) as TdmTile);
_local5.selected = false;
_local4++;
};
if (_arg3){
if (fGrabbing){
drag(_arg1, _arg2);
} else {
if (!grab(_arg1, _arg2)){
return;
};
};
} else {
if (fGrabbing){
drag(_arg1, _arg2);
drop();
} else {
moveHand(_arg1, _arg2);
};
};
fGrabbing = _arg3;
}
public function resetBoard():void{
var _local1:int;
var _local2:TdmTile;
fMoves = 0;
_local1 = 0;
while (_local1 < numChildren) {
removeChildAt(0);
_local1++;
};
_local1 = 0;
while (_local1 < fOriginalField.length) {
fField[_local1] = fOriginalField[_local1];
_local2 = new TdmTile(fSize, fOriginalField[_local1]);
_local2.x = ((_local1 % fSize) * fTileSize);
_local2.y = (Math.floor((_local1 / fSize)) * fTileSize);
addChild(_local2);
_local1++;
};
mouseChildren = false;
}
private function moveHand(_arg1:int, _arg2:int):void{
var _local3:int;
var _local4:int;
var _local5:TdmTile;
if ((((((((_arg1 < 0)) || ((_arg1 >= SIZE)))) || ((_arg2 < 0)))) || ((_arg2 >= SIZE)))){
return;
};
_local4 = 0;
while (_local4 < numChildren) {
_local5 = (getChildAt(_local4) as TdmTile);
if (_local5.containsPoint(_arg1, _arg2)){
_local3 = _local5.type;
};
_local4++;
};
_local4 = 0;
while (_local4 < numChildren) {
_local5 = (getChildAt(_local4) as TdmTile);
if (_local5.type == _local3){
_local5.selected = true;
};
_local4++;
};
}
private function movedRowDir(_arg1:Boolean):void{
var _local2:int;
var _local3:int;
if (fGrabbedCol != fGrabbedTile.column){
if (_arg1){
_local2 = (((fGrabbedTile.column - fGrabbedCol) + fSize) % fSize);
_local3 = 0;
while (_local3 < _local2) {
moved();
_local3++;
};
} else {
_local2 = (((fGrabbedCol - fGrabbedTile.column) + fSize) % fSize);
_local3 = 0;
while (_local3 < _local2) {
moved();
_local3++;
};
};
fGrabbedCol = fGrabbedTile.column;
};
}
private function movedColumn():void{
if ((((((fGrabbedRow + 1) % fSize) == fGrabbedTile.row)) || ((fGrabbedRow == ((fGrabbedTile.row + 1) % fSize))))){
fGrabbedRow = fGrabbedTile.row;
moved();
};
}
public function drop():void{
slideInPosition();
if (fLockedCol > -1){
movedColumn();
} else {
if (fLockedRow > -1){
movedRow();
};
};
fLockedCol = -1;
fLockedRow = -1;
fGrabbedRow = -1;
fGrabbedCol = -1;
fGrabbedX = -1;
fGrabbedY = -1;
fGrabbedTile = null;
}
}
}//package com.darkmoon.enigmatica
Section 4
//TdmBoardCompleteAnimation (com.darkmoon.enigmatica.TdmBoardCompleteAnimation)
package com.darkmoon.enigmatica {
import flash.display.*;
import com.darkmoon.*;
import flash.geom.*;
import com.darkmoon.util.*;
public class TdmBoardCompleteAnimation extends AdmAnimation {
private var fScales:Array;
public function TdmBoardCompleteAnimation(_arg1:DisplayObject){
var _local2:Array;
var _local3:int;
super(_arg1);
_local2 = TdmInterpolationUtil.createValues(TdmInterpolationUtil.TYPE_COSINE, 0.85, 1.05, (frameCount / 2));
fScales = new Array(frameCount);
_local3 = 0;
while (_local3 < _local2.length) {
fScales[_local3] = _local2[_local3];
fScales[((frameCount - _local3) - 1)] = _local2[_local3];
_local3++;
};
}
override protected function get frameCount():int{
return (30);
}
override public function update():void{
var _local1:Matrix;
_local1 = new Matrix(1, 0, 0, 1, (-(displayObject.width) / 2), (-(displayObject.height) / 2));
_local1.concat(new Matrix(fScales[frame], 0, 0, fScales[frame], 0, 0));
_local1.concat(new Matrix(1, 0, 0, 1, (displayObject.width / 2), (displayObject.height / 2)));
displayObject.transform.matrix = _local1;
}
}
}//package com.darkmoon.enigmatica
Section 5
//TdmButtonBackground (com.darkmoon.enigmatica.TdmButtonBackground)
package com.darkmoon.enigmatica {
import flash.display.*;
public class TdmButtonBackground extends Shape {
public function TdmButtonBackground(_arg1:int, _arg2:int){
graphics.beginFill(0xFFFFFF, 0.6);
graphics.lineStyle(4, 0, 1);
graphics.drawRoundRect(0, 0, _arg1, _arg2, (_arg1 / 2), (_arg2 / 2));
cacheAsBitmap = true;
}
}
}//package com.darkmoon.enigmatica
Section 6
//TdmChallengeMode (com.darkmoon.enigmatica.TdmChallengeMode)
package com.darkmoon.enigmatica {
public class TdmChallengeMode implements IdmGameMode {
private var fBoardSize:int;
private var fMaxMoves:int;
private var fChallenge:int;
private var fTimeLimit:int;
private var fPoints:int;// = 0
private static const MOVES_LOWER_LIMIT:Array = new Array(8, 16, 35, 60, 100);
private static const MOVES_UPPER_LIMIT:Array = new Array(50, 75, 100, 150, 200);
private static const TIME_LOWER_LIMIT:Array = new Array(30, 60, 90, 150, 180);
private static const TIME_UPPER_LIMIT:Array = new Array(90, 120, 180, 270, 360);
public function TdmChallengeMode(_arg1:int){
fPoints = 0;
super();
fBoardSize = _arg1;
fChallenge = 1;
calculateChallenge();
}
public function boardCompleted(_arg1:int, _arg2:int):int{
var _local3:int;
_local3 = (fChallenge * (((4 * (fMaxMoves - _arg1)) + fTimeLimit) - _arg2));
fPoints = (fPoints + _local3);
fChallenge++;
calculateChallenge();
return (_local3);
}
public function get level():int{
return (fChallenge);
}
public function get maxMoves():int{
return (fMaxMoves);
}
public function get points():int{
return (fPoints);
}
private function calculateChallenge():void{
var _local1:int;
var _local2:int;
_local1 = (11 - fChallenge);
if (_local1 < 0){
_local1 = 0;
};
_local2 = (fBoardSize - 4);
fMaxMoves = int((((MOVES_UPPER_LIMIT[_local2] * _local1) + (MOVES_LOWER_LIMIT[_local2] * (10 - _local1))) / 10));
fTimeLimit = int((((TIME_UPPER_LIMIT[_local2] * _local1) + (TIME_LOWER_LIMIT[_local2] * (10 - _local1))) / 10));
fTimeLimit = (Math.round((fTimeLimit / 5)) * 5);
}
public function resume(_arg1:int, _arg2:int):void{
fChallenge = _arg1;
fPoints = _arg2;
calculateChallenge();
}
public function get timeLimit():int{
return (fTimeLimit);
}
}
}//package com.darkmoon.enigmatica
Section 7
//TdmGame (com.darkmoon.enigmatica.TdmGame)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.display.*;
import com.darkmoon.*;
import flash.net.*;
public dynamic class TdmGame extends AdmGame {
private var fBoardSize:int;
private var fChallengeMode:Boolean;
public function TdmGame(){
var added:Function;
added = function (_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, added);
stage.frameRate = 30;
TdmScores.getScores();
};
try {
sendToURL(new URLRequest("http://www.smileygamer.com/scripts/tracking.php?id=433"));
} catch(e:SecurityError) {
};
MochiAd.showPreloaderAd({id:"80a03e6a297e4912", res:"384x384", clip:this});
super();
addEventListener(Event.ADDED_TO_STAGE, added);
}
public function get sponsorURL():String{
return (null);
}
public function stop():void{
}
public function play():void{
showIntroScreen();
}
public function startGame(_arg1:int, _arg2:Boolean):void{
fBoardSize = _arg1;
fChallengeMode = _arg2;
if (TdmScores.getScores().plays == 0){
showHelpScreen();
} else {
showGameScreen();
};
}
public function showTitleScreen():void{
var _local1:DisplayObject;
_local1 = new TdmTitleScreen(this);
_local1.alpha = 0;
addChild(_local1);
new TdmFadeAnimation(_local1, 15, TdmFadeAnimation.MODE_FADE_IN);
if (numChildren > 1){
new TdmFadeAnimation(getChildAt(0), 30, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
};
TdmSoundManager.playMusic();
}
private function showIntroScreen():void{
var _local1:TdmIntroScreen;
_local1 = new TdmIntroScreen(this);
_local1.alpha = 0;
addChild(_local1);
new TdmFadeAnimation(_local1, 15, TdmFadeAnimation.MODE_FADE_IN);
}
public function resumeGame():void{
var _local1:TdmChallengeMode;
fBoardSize = TdmScores.getScores().savedBoard;
fChallengeMode = true;
_local1 = new TdmChallengeMode(fBoardSize);
_local1.resume(TdmScores.getScores().savedChallenge, TdmScores.getScores().savedPoints);
addChildAt(new TdmGameScreen(this, fBoardSize, _local1), 0);
new TdmFadeAnimation(getChildAt(1), 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
}
public function showGameScreen():void{
var _local1:IdmGameMode;
if (fChallengeMode){
_local1 = new TdmChallengeMode(fBoardSize);
} else {
_local1 = new TdmRelaxedMode(fBoardSize);
};
addChildAt(new TdmGameScreen(this, fBoardSize, _local1), 0);
new TdmFadeAnimation(getChildAt(1), 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
}
public function showHelpScreen():void{
addChildAt(new TdmHelpScreen(this), 0);
new TdmFadeAnimation(getChildAt(1), 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
}
}
}//package com.darkmoon.enigmatica
Section 8
//TdmGameScreen (com.darkmoon.enigmatica.TdmGameScreen)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.darkmoon.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
public class TdmGameScreen extends Sprite implements IdmLogic {
private var fButtonLayer:Sprite;
private var fResetButton:SimpleButton;
private var fBoard:TdmBoard;
private var fGameMode:IdmGameMode;
private var fStartGameLayer:Sprite;
private var fNameField:TextField;
private var fEndGameLayer:Sprite;
private var fScoreFont:TdmNumberFont;
private var fGame:TdmGame;
private var fStartTime:int;
private var fBoardComplete:DisplayObject;
private var fLeftBar:TdmProgressBar;
private var fScoreBar:TdmScoreBar;
private var fHandCursor:TdmHandSprite;
private var fState:int;
private var fRightBar:TdmProgressBar;
private var fChallengeMode:Boolean;
private static const STATE_GAME:int = 2;
private static const STATE_GAME_OVER:int = 4;
private static const STATE_START:int = 1;
private static const STATE_COMPLETED:int = 3;
private static const STATE_INIT:int = 0;
public function TdmGameScreen(_arg1:TdmGame, _arg2:int, _arg3:IdmGameMode){
fGame = _arg1;
fGameMode = _arg3;
fBoard = new TdmBoard(_arg2);
if (_arg2 == 8){
fBoard.x = 40;
fBoard.y = 40;
} else {
fBoard.x = 42;
fBoard.y = 42;
};
addChild(fBoard);
fChallengeMode = !((fGameMode.maxMoves == -1));
addChild(TdmImageFactory.createBackground(fChallengeMode));
if (fChallengeMode){
fLeftBar = new TdmProgressBar(TdmImageFactory.createLeftBar(), fGameMode.maxMoves, fGameMode.maxMoves);
fLeftBar.x = 10;
fLeftBar.y = 52;
addChild(fLeftBar);
fRightBar = new TdmProgressBar(TdmImageFactory.createRightBar(), fGameMode.timeLimit, fGameMode.timeLimit);
fRightBar.x = 352;
fRightBar.y = 52;
addChild(fRightBar);
};
fScoreBar = new TdmScoreBar();
addChild(fScoreBar);
fButtonLayer = createButtonLayer();
fButtonLayer.y = 342;
addChild(fButtonLayer);
fBoardComplete = TdmImageFactory.createBoardComplete();
fHandCursor = new TdmHandSprite();
addChild(fHandCursor);
fScoreFont = TdmImageFactory.createRedFont();
addEventListener(Event.ADDED_TO_STAGE, added);
addEventListener(Event.REMOVED_FROM_STAGE, removed);
}
private function showMenu(_arg1:Event):void{
fGame.showTitleScreen();
}
public function added(_arg1:Event):void{
Mouse.hide();
addEventListener(MouseEvent.MOUSE_MOVE, mouseUpdate);
addEventListener(MouseEvent.MOUSE_DOWN, mouseUpdate);
addEventListener(MouseEvent.MOUSE_UP, mouseUpdate);
addEventListener(MouseEvent.CLICK, mouseUpdate);
newBoard(_arg1);
}
private function createStartChallengeLayer():Sprite{
var _local1:Sprite;
var _local2:TdmButtonBackground;
var _local3:DisplayObject;
var _local4:Bitmap;
var _local5:DisplayObject;
var _local6:Bitmap;
var _local7:DisplayObject;
var _local8:Bitmap;
_local1 = new Sprite();
_local1.x = 52;
_local1.y = 102;
_local1.alpha = 0;
_local2 = new TdmButtonBackground(280, 180);
_local1.addChild(_local2);
_local3 = TdmTextFactory.createGameGreenText("CHALLENGE");
_local3.x = 25;
_local3.y = 23;
_local1.addChild(_local3);
_local4 = fScoreFont.createNumber(fGameMode.level);
_local4.x = (0xFF - _local4.width);
_local4.y = 25;
_local1.addChild(_local4);
_local5 = TdmTextFactory.createNarrowGreenText("MAX MOVES");
_local5.x = 25;
_local5.y = 73;
_local1.addChild(_local5);
_local6 = fScoreFont.createNumber(fGameMode.maxMoves);
_local6.x = (0xFF - _local6.width);
_local6.y = 75;
_local1.addChild(_local6);
_local7 = TdmTextFactory.createNarrowGreenText("TIME LIMIT");
_local7.x = 25;
_local7.y = 123;
_local1.addChild(_local7);
_local8 = fScoreFont.createTime(fGameMode.timeLimit);
_local8.x = (0xFF - _local8.width);
_local8.y = 125;
_local1.addChild(_local8);
new TdmFadeAnimation(_local1, 10, TdmFadeAnimation.MODE_FADE_IN);
return (_local1);
}
private function newBoard(_arg1:Event):void{
fBoard.newBoard();
fState = STATE_INIT;
}
private function createEndGameLayer(_arg1:int, _arg2:Boolean):Sprite{
var _local3:Sprite;
var _local4:Sprite;
var _local5:TdmButtonBackground;
var _local6:DisplayObject;
var _local7:Bitmap;
var _local8:Sprite;
var _local9:DisplayObject;
var _local10:Bitmap;
var _local11:SimpleButton;
var _local12:SimpleButton;
var _local13:SimpleButton;
_local3 = new Sprite();
_local3.y = 45;
_local3.alpha = 0;
_local3.addChild(fBoardComplete);
new TdmBoardCompleteAnimation(fBoardComplete);
_local4 = new Sprite();
_local4.x = 52;
_local4.y = 85;
_local3.addChild(_local4);
_local5 = new TdmButtonBackground(280, 200);
_local4.addChild(_local5);
_local6 = TdmTextFactory.createGameGreenText("POINTS");
_local6.x = 25;
_local6.y = 23;
_local4.addChild(_local6);
_local7 = fScoreFont.createNumber(_arg1);
_local7.x = (0xFF - _local7.width);
_local7.y = 25;
_local4.addChild(_local7);
_local8 = new Sprite();
_local9 = TdmTextFactory.createGameGreenText("BEST");
_local9.x = 25;
_local9.y = 63;
_local8.addChild(_local9);
_local10 = fScoreFont.createNumber(TdmScores.getScores().getBestScore(fBoard.size));
_local10.x = (0xFF - _local10.width);
_local10.y = 65;
_local8.addChild(_local10);
_local4.addChild(_local8);
if (_arg2){
new TdmBlinkAnimation(_local8);
_local12 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "SUBMIT SCORE!", false);
_local12.addEventListener(MouseEvent.CLICK, submitScore);
_local12.x = ((280 - _local12.width) / 2);
_local12.y = 103;
_local4.addChild(_local12);
} else {
_local13 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "REPLAY", false);
_local13.addEventListener(MouseEvent.CLICK, reset);
_local13.x = ((280 - _local13.width) / 2);
_local13.y = 103;
_local4.addChild(_local13);
};
_local11 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "NEW BOARD", false);
_local11.addEventListener(MouseEvent.CLICK, newBoard);
_local11.x = ((280 - _local11.width) / 2);
_local11.y = 143;
_local4.addChild(_local11);
new TdmFadeAnimation(_local3, 10, TdmFadeAnimation.MODE_FADE_IN);
return (_local3);
}
public function removed(_arg1:Event):void{
Mouse.show();
}
private function createGameOverLayer(_arg1:int, _arg2:Boolean):Sprite{
var _local3:Sprite;
var _local4:DisplayObject;
var _local5:Sprite;
var _local6:TdmButtonBackground;
var _local7:DisplayObject;
var _local8:Bitmap;
var _local9:Sprite;
var _local10:DisplayObject;
var _local11:Bitmap;
var _local12:SimpleButton;
var _local13:SimpleButton;
_local3 = new Sprite();
_local3.y = 55;
_local3.alpha = 0;
_local4 = TdmImageFactory.createGameOver();
_local3.addChild(_local4);
new TdmBoardCompleteAnimation(_local4);
_local5 = new Sprite();
_local5.x = 52;
_local5.y = 85;
_local3.addChild(_local5);
_local6 = new TdmButtonBackground(280, 180);
_local5.addChild(_local6);
_local7 = TdmTextFactory.createGameGreenText("TOTAL");
_local7.x = 25;
_local7.y = 23;
_local5.addChild(_local7);
_local8 = fScoreFont.createNumber(fGameMode.points);
_local8.x = (0xFF - _local8.width);
_local8.y = 25;
_local5.addChild(_local8);
_local9 = new Sprite();
_local10 = TdmTextFactory.createGameGreenText("BEST");
_local10.x = 25;
_local10.y = 73;
_local9.addChild(_local10);
_local11 = fScoreFont.createNumber(TdmScores.getScores().getBestChallengeScore(fBoard.size));
_local11.x = (0xFF - _local11.width);
_local11.y = 75;
_local9.addChild(_local11);
_local5.addChild(_local9);
if (_arg2){
new TdmBlinkAnimation(_local9);
_local12 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "SUBMIT SCORE!", false);
_local12.addEventListener(MouseEvent.CLICK, submitScore);
_local12.x = ((280 - _local12.width) / 2);
_local12.y = 123;
_local5.addChild(_local12);
} else {
_local13 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "MORE GAMES", false);
_local13.addEventListener(MouseEvent.CLICK, moreGames);
_local13.x = ((280 - _local13.width) / 2);
_local13.y = 123;
_local5.addChild(_local13);
};
new TdmFadeAnimation(_local3, 10, TdmFadeAnimation.MODE_FADE_IN);
return (_local3);
}
private function reset(_arg1:Event):void{
if (((!((_arg1.target == fResetButton))) || (fResetButton.enabled))){
fBoard.resetBoard();
fState = STATE_INIT;
};
}
private function startGame():void{
fResetButton.visible = true;
fStartTime = getTimer();
fState = STATE_GAME;
if (fChallengeMode){
new TdmFadeAnimation(fStartGameLayer, 10, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
} else {
if (fEndGameLayer != null){
new TdmFadeAnimation(fEndGameLayer, 10, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
};
};
}
private function submitScore(_arg1:Event):void{
removeChild(fEndGameLayer);
fEndGameLayer = createEnterNameLayer();
addChildAt(fEndGameLayer, (numChildren - 2));
}
private function moreGames(_arg1:Event):void{
var _local2:String;
if (fGame.sponsorURL != null){
_local2 = fGame.sponsorURL;
} else {
_local2 = "http://www.smileygamer.com";
};
navigateToURL(new URLRequest(_local2), "_blank");
}
private function createEnterNameLayer():Sprite{
var _local1:Sprite;
var _local2:TdmButtonBackground;
var _local3:DisplayObject;
var _local4:SimpleButton;
_local1 = new Sprite();
_local1.y = 102;
_local1.x = 52;
_local2 = new TdmButtonBackground(280, 180);
_local1.addChild(_local2);
_local3 = TdmTextFactory.createDefaultGreenText("ENTER NAME");
_local3.x = ((280 - _local3.width) / 2);
_local3.y = 23;
_local1.addChild(_local3);
fNameField = TdmTextFactory.createEnterNameField();
fNameField.x = 20;
fNameField.y = 70;
fNameField.width = 192;
fNameField.height = 36;
fNameField.maxChars = 16;
_local1.addChild(fNameField);
if (TdmScores.getScores().name != null){
fNameField.text = TdmScores.getScores().name;
};
_local4 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "SUBMIT", true);
_local4.addEventListener(MouseEvent.CLICK, nameChosen);
_local4.x = ((280 - _local4.width) / 2);
_local4.y = 120;
_local1.addChild(_local4);
return (_local1);
}
public function doLogic():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Boolean;
var _local6:Boolean;
switch (fState){
case STATE_INIT:
if (fChallengeMode){
fLeftBar.maxValue = fGameMode.maxMoves;
fRightBar.maxValue = fGameMode.timeLimit;
fLeftBar.value = fGameMode.maxMoves;
fRightBar.value = fGameMode.timeLimit;
fStartGameLayer = createStartChallengeLayer();
addChildAt(fStartGameLayer, (numChildren - 2));
fState = STATE_START;
if (fEndGameLayer != null){
new TdmFadeAnimation(fEndGameLayer, 10, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
};
} else {
startGame();
};
break;
case STATE_START:
fScoreBar.update(fGameMode.maxMoves, fGameMode.timeLimit);
break;
case STATE_GAME:
fBoard.mouseUpdate((fHandCursor.x - fBoard.x), (fHandCursor.y - fBoard.y), fHandCursor.grabbing);
fBoard.doLogic();
_local1 = Math.round(((getTimer() - fStartTime) / 1000));
if (fChallengeMode){
_local2 = (fGameMode.maxMoves - fBoard.moves);
_local3 = (fGameMode.timeLimit - _local1);
fScoreBar.update(_local2, _local3);
fLeftBar.value = _local2;
fRightBar.value = _local3;
} else {
fScoreBar.update(fBoard.moves, _local1);
};
if (fBoard.isCompleted()){
fHandCursor.grabbing = false;
fBoard.mouseUpdate((fHandCursor.x - fBoard.x), (fHandCursor.y - fBoard.y), fHandCursor.grabbing);
_local4 = fGameMode.boardCompleted(fBoard.moves, _local1);
TdmSoundManager.playApplause();
fState = STATE_COMPLETED;
fResetButton.visible = false;
if (fChallengeMode){
TdmScores.getScores().updateScores(fBoard.size, fBoard.moves, _local1, 0);
TdmScores.getScores().saveChallenge(fBoard.size, fGameMode.level, fGameMode.points);
fEndGameLayer = createEndChallengeLayer((fGameMode.level - 1), _local4);
} else {
_local5 = TdmScores.getScores().updateScores(fBoard.size, fBoard.moves, _local1, _local4);
fEndGameLayer = createEndGameLayer(_local4, _local5);
};
addChildAt(fEndGameLayer, (numChildren - 2));
fStartTime = getTimer();
} else {
if (((fChallengeMode) && ((((_local2 <= 0)) || ((_local3 <= 0)))))){
fHandCursor.grabbing = false;
fBoard.mouseUpdate((fHandCursor.x - fBoard.x), (fHandCursor.y - fBoard.y), fHandCursor.grabbing);
TdmSoundManager.playGameOver();
fState = STATE_GAME_OVER;
_local6 = TdmScores.getScores().updateChallengeScore(fBoard.size, fGameMode.points);
fEndGameLayer = createGameOverLayer(fGameMode.level, _local6);
addChildAt(fEndGameLayer, (numChildren - 2));
fResetButton.visible = false;
fStartTime = getTimer();
};
};
break;
case STATE_COMPLETED:
fBoard.doLogic();
break;
case STATE_GAME_OVER:
fBoard.doLogic();
break;
};
}
private function createButtonLayer():Sprite{
var _local1:Sprite;
var _local2:SimpleButton;
var _local3:SimpleButton;
_local1 = new Sprite();
fResetButton = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "RESET", false);
fResetButton.addEventListener(MouseEvent.CLICK, reset);
fResetButton.x = 15;
fResetButton.y = 4;
fResetButton.visible = false;
_local1.addChild(fResetButton);
_local2 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "HELP!", false);
_local2.addEventListener(MouseEvent.CLICK, showHelp);
_local2.x = ((384 - _local2.width) / 2);
_local2.y = 4;
_local1.addChild(_local2);
_local3 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "MENU", false);
_local3.addEventListener(MouseEvent.CLICK, showMenu);
_local3.x = (369 - _local3.width);
_local3.y = 4;
_local1.addChild(_local3);
return (_local1);
}
private function createEndChallengeLayer(_arg1:int, _arg2:int):Sprite{
var _local3:Sprite;
var _local4:Sprite;
var _local5:TdmButtonBackground;
var _local6:DisplayObject;
var _local7:Bitmap;
var _local8:DisplayObject;
var _local9:Bitmap;
var _local10:DisplayObject;
var _local11:Bitmap;
_local3 = new Sprite();
_local3.y = 45;
_local3.alpha = 0;
_local3.addChild(fBoardComplete);
new TdmBoardCompleteAnimation(fBoardComplete);
_local4 = new Sprite();
_local4.x = 52;
_local4.y = 85;
_local3.addChild(_local4);
_local5 = new TdmButtonBackground(280, 180);
_local4.addChild(_local5);
_local6 = TdmTextFactory.createGameGreenText("CHALLENGE");
_local6.x = 25;
_local6.y = 23;
_local4.addChild(_local6);
_local7 = fScoreFont.createNumber(_arg1);
_local7.x = (0xFF - _local7.width);
_local7.y = 25;
_local4.addChild(_local7);
_local8 = TdmTextFactory.createGameGreenText("POINTS");
_local8.x = 25;
_local8.y = 73;
_local4.addChild(_local8);
_local9 = fScoreFont.createNumber(_arg2);
_local9.x = (0xFF - _local9.width);
_local9.y = 75;
_local4.addChild(_local9);
_local10 = TdmTextFactory.createGameGreenText("TOTAL");
_local10.x = 25;
_local10.y = 123;
_local4.addChild(_local10);
_local11 = fScoreFont.createNumber(fGameMode.points);
_local11.x = (0xFF - _local11.width);
_local11.y = 125;
_local4.addChild(_local11);
new TdmFadeAnimation(_local3, 10, TdmFadeAnimation.MODE_FADE_IN);
return (_local3);
}
public function mouseUpdate(_arg1:MouseEvent):void{
fHandCursor.x = _arg1.stageX;
fHandCursor.y = _arg1.stageY;
switch (fState){
case STATE_INIT:
break;
case STATE_START:
if (_arg1.type == MouseEvent.CLICK){
startGame();
};
break;
case STATE_GAME:
if (_arg1.type != MouseEvent.CLICK){
fHandCursor.grabbing = _arg1.buttonDown;
};
break;
case STATE_COMPLETED:
if (((((fChallengeMode) && ((_arg1.type == MouseEvent.CLICK)))) && (((getTimer() - fStartTime) > 1000)))){
fBoard.newBoard();
fState = STATE_INIT;
};
break;
case STATE_GAME_OVER:
break;
};
}
private function scoring():void{
var gamemode:int;
var score:int;
if (fChallengeMode){
gamemode = (fBoard.size + 1);
score = TdmScores.getScores().getBestChallengeScore(fBoard.size);
} else {
gamemode = (fBoard.size - 4);
score = TdmScores.getScores().getBestScore(fBoard.size);
};
score = ((score * 100) + (score % 97));
try {
sendToURL(new URLRequest(((((("http://www.smileygamer.com/scripts/hiscore.php?id=433&mode=" + gamemode) + "&player=") + TdmScores.getScores().name) + "&score=") + score)));
} catch(e:SecurityError) {
};
}
private function showHelp(_arg1:Event):void{
fGame.showHelpScreen();
}
private function nameChosen(_arg1:Event):void{
if (fNameField.text.length > 0){
TdmScores.getScores().name = fNameField.text;
scoring();
fGame.showTitleScreen();
};
}
}
}//package com.darkmoon.enigmatica
Section 9
//TdmHandSprite (com.darkmoon.enigmatica.TdmHandSprite)
package com.darkmoon.enigmatica {
import flash.display.*;
public class TdmHandSprite extends Sprite {
private var fOpenHandImage:DisplayObject;
private var fGrabbed:Boolean;// = false
private var fClosedHandImage:DisplayObject;
public function TdmHandSprite(){
fOpenHandImage = TdmImageFactory.createHand(false);
fClosedHandImage = TdmImageFactory.createHand(true);
fGrabbed = false;
super();
mouseEnabled = false;
fOpenHandImage.x = (-(fOpenHandImage.width) / 2);
fOpenHandImage.y = (-(fOpenHandImage.height) / 2);
addChild(fOpenHandImage);
fClosedHandImage.x = (-(fClosedHandImage.width) / 2);
fClosedHandImage.y = (-(fClosedHandImage.height) / 2);
fClosedHandImage.visible = false;
addChild(fClosedHandImage);
}
public function set grabbing(_arg1:Boolean):void{
fGrabbed = _arg1;
fOpenHandImage.visible = !(_arg1);
fClosedHandImage.visible = _arg1;
}
public function get grabbing():Boolean{
return (fGrabbed);
}
}
}//package com.darkmoon.enigmatica
Section 10
//TdmHelpScreen (com.darkmoon.enigmatica.TdmHelpScreen)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.darkmoon.*;
import flash.geom.*;
import flash.utils.*;
public class TdmHelpScreen extends Sprite implements IdmLogic {
private var fCommand:int;
private var fCommands:Array;
private var fBoard:TdmBoard;
private var fEndDemoLayer:DisplayObject;
private var fHelp3:DisplayObject;
private var fHelp2:DisplayObject;
private var fHelp1:DisplayObject;
private var fGame:TdmGame;
private var fStartTime:int;// = 0
private var fHandCursor:TdmHandSprite;
private var fState:int;
private static const STATE_DEMO:int = 0;
private static const STATE_COMPLETED:int = 1;
public function TdmHelpScreen(_arg1:TdmGame){
var _local2:TextField;
var _local3:SimpleButton;
var _local4:SimpleButton;
fCommands = new Array();
fStartTime = 0;
super();
fGame = _arg1;
fBoard = new TdmBoard(4);
fBoard.demoBoard();
fBoard.x = 42;
fBoard.y = 42;
addChild(fBoard);
addChild(TdmImageFactory.createBackground(false));
_local2 = TdmTextFactory.createTextField(TdmTextFactory.DEFAULT_FONT, TdmTextFactory.SIZE_NORMAL, TdmTextFactory.COLOR_RED, false);
_local2.text = "INSTRUCTIONS";
_local2.x = ((384 - _local2.width) / 2);
_local2.y = 4;
addChild(_local2);
fHandCursor = new TdmHandSprite();
fHandCursor.x = 192;
fHandCursor.y = 192;
addChild(fHandCursor);
fHelp1 = TdmImageFactory.createHelp1();
fHelp1.x = 45;
fHelp1.y = 242;
addChild(fHelp1);
fHelp2 = TdmImageFactory.createHelp2();
fHelp2.x = 20;
fHelp2.y = 50;
fHelp2.visible = false;
addChild(fHelp2);
fHelp3 = TdmImageFactory.createHelp3();
fHelp3.x = 45;
fHelp3.y = 50;
fHelp3.visible = false;
addChild(fHelp3);
_local3 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "MENU", false);
_local3.addEventListener(MouseEvent.CLICK, showMenu);
_local3.x = (369 - _local3.width);
_local3.y = 346;
addChild(_local3);
_local4 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "SKIP", false);
_local4.addEventListener(MouseEvent.CLICK, showGame);
_local4.x = 15;
_local4.y = 346;
addChild(_local4);
fCommand = 0;
fCommands.push(new Point(305, 155));
fCommands.push(new Point(305, 80));
fCommands.push(new Point(155, 155));
fCommands.push(new Point(155, 230));
fCommands.push(new Point(80, 230));
fCommands.push(new Point(155, 230));
fCommands.push(new Point(155, 230));
fCommands.push(new Point(155, 155));
fCommands.push(new Point(305, 155));
fCommands.push(new Point(305, 305));
fCommands.push(new Point(155, 305));
fCommands.push(new Point(305, 305));
fCommands.push(new Point(305, 305));
fCommands.push(new Point(305, 155));
fCommands.push(new Point(80, 305));
fCommands.push(new Point(80, 230));
fCommands.push(new Point(155, 230));
fCommands.push(new Point(80, 230));
fCommands.push(new Point(80, 230));
fCommands.push(new Point(80, 305));
addEventListener(Event.ADDED_TO_STAGE, play);
}
private function showMenu(_arg1:Event):void{
fGame.showTitleScreen();
}
private function play(_arg1:Event):void{
fState = STATE_DEMO;
fBoard.demoBoard();
fHandCursor.visible = true;
fCommand = 0;
new TdmFadeAnimation(fHelp1, 10, TdmFadeAnimation.MODE_FADE_IN);
if (fEndDemoLayer != null){
new TdmFadeAnimation(fEndDemoLayer, 10, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
};
}
public function doLogic():void{
switch (fState){
case STATE_DEMO:
if (alpha == 1){
updateHand();
};
fBoard.mouseUpdate((fHandCursor.x - fBoard.x), (fHandCursor.y - fBoard.y), fHandCursor.grabbing);
fBoard.doLogic();
if (fBoard.isCompleted()){
fHandCursor.grabbing = false;
fBoard.mouseUpdate((fHandCursor.x - fBoard.x), (fHandCursor.y - fBoard.y), fHandCursor.grabbing);
};
break;
case STATE_COMPLETED:
fBoard.doLogic();
break;
};
}
private function showGame(_arg1:Event):void{
fGame.showGameScreen();
}
private function createEndDemoLayer():Sprite{
var _local1:Sprite;
var _local2:TdmButtonBackground;
var _local3:SimpleButton;
var _local4:SimpleButton;
_local1 = new Sprite();
_local1.x = 52;
_local1.y = 125;
_local1.alpha = 0;
_local2 = new TdmButtonBackground(280, 130);
_local1.addChild(_local2);
_local3 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "REPLAY DEMO", false);
_local3.addEventListener(MouseEvent.CLICK, play);
_local3.x = ((280 - _local3.width) / 2);
_local3.y = 25;
_local1.addChild(_local3);
_local4 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "PLAY GAME", false);
_local4.addEventListener(MouseEvent.CLICK, showGame);
_local4.x = ((280 - _local4.width) / 2);
_local4.y = 75;
_local1.addChild(_local4);
new TdmFadeAnimation(_local1, 10, TdmFadeAnimation.MODE_FADE_IN);
return (_local1);
}
private function updateHand():void{
var _local1:Point;
_local1 = fCommands[fCommand];
if ((((Math.abs((_local1.x - fHandCursor.x)) < 5)) && ((Math.abs((_local1.y - fHandCursor.y)) < 5)))){
if (fStartTime == 0){
fStartTime = getTimer();
fHandCursor.grabbing = !(fHandCursor.grabbing);
};
if ((getTimer() - fStartTime) > 400){
fCommand++;
if (fCommand == fCommands.length){
new TdmFadeAnimation(fHelp3, 10, TdmFadeAnimation.MODE_FADE_OUT);
fState = STATE_COMPLETED;
fEndDemoLayer = createEndDemoLayer();
addChild(fEndDemoLayer);
fHandCursor.visible = false;
};
if (fCommand == 9){
new TdmFadeAnimation(fHelp1, 10, TdmFadeAnimation.MODE_FADE_OUT);
new TdmFadeAnimation(fHelp2, 10, TdmFadeAnimation.MODE_FADE_IN);
};
if (fCommand == 14){
new TdmFadeAnimation(fHelp2, 10, TdmFadeAnimation.MODE_FADE_OUT);
new TdmFadeAnimation(fHelp3, 10, TdmFadeAnimation.MODE_FADE_IN);
};
fStartTime = 0;
};
} else {
if (fHandCursor.x < _local1.x){
fHandCursor.x = (fHandCursor.x + 4);
};
if (fHandCursor.x > _local1.x){
fHandCursor.x = (fHandCursor.x - 4);
};
if (fHandCursor.y < _local1.y){
fHandCursor.y = (fHandCursor.y + 4);
};
if (fHandCursor.y > _local1.y){
fHandCursor.y = (fHandCursor.y - 4);
};
};
}
}
}//package com.darkmoon.enigmatica
Section 11
//TdmImageFactory (com.darkmoon.enigmatica.TdmImageFactory)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.darkmoon.*;
public class TdmImageFactory {
private static var ClosedHandImage:Class = TdmImageFactory_ClosedHandImage;
private static var BoardCompleteImage:Class = TdmImageFactory_BoardCompleteImage;
private static var GameOverImage:Class = TdmImageFactory_GameOverImage;
private static var Help3Image:Class = TdmImageFactory_Help3Image;
private static var RelaxedModeSelImage:Class = TdmImageFactory_RelaxedModeSelImage;
private static var BGLeftBarImage:Class = TdmImageFactory_BGLeftBarImage;
private static var PlaySelImage:Class = TdmImageFactory_PlaySelImage;
private static var sTileImages:Array = new Array(Tiles4, Tiles5, Tiles6, Tiles7, Tiles8);
private static var SponsorLogoImage:Class = TdmImageFactory_SponsorLogoImage;
private static var RelaxedModeImage:Class = TdmImageFactory_RelaxedModeImage;
private static var MovesDigits:Class = TdmImageFactory_MovesDigits;
private static var TimeDigits:Class = TdmImageFactory_TimeDigits;
private static var SoundOffImage:Class = TdmImageFactory_SoundOffImage;
private static var BGRightImage:Class = TdmImageFactory_BGRightImage;
private static var ChallengeModeSelImage:Class = TdmImageFactory_ChallengeModeSelImage;
private static var SoundOnImage:Class = TdmImageFactory_SoundOnImage;
private static var BGLeftImage:Class = TdmImageFactory_BGLeftImage;
private static var Help1Image:Class = TdmImageFactory_Help1Image;
private static var TitleBGImage:Class = TdmImageFactory_TitleBGImage;
private static var PlayImage:Class = TdmImageFactory_PlayImage;
private static var OpenHandImage:Class = TdmImageFactory_OpenHandImage;
private static var BGTopImage:Class = TdmImageFactory_BGTopImage;
private static var LeftBar:Class = TdmImageFactory_LeftBar;
private static var Tiles4:Class = TdmImageFactory_Tiles4;
private static var Tiles5:Class = TdmImageFactory_Tiles5;
private static var Tiles6:Class = TdmImageFactory_Tiles6;
private static var Tiles7:Class = TdmImageFactory_Tiles7;
private static var Tiles8:Class = TdmImageFactory_Tiles8;
private static var ChallengeModeImage:Class = TdmImageFactory_ChallengeModeImage;
private static var RightBar:Class = TdmImageFactory_RightBar;
private static var Help2Image:Class = TdmImageFactory_Help2Image;
private static var BGBottomImage:Class = TdmImageFactory_BGBottomImage;
private static var sTileStrips:Array = new Array(5);
private static var BGRightBarImage:Class = TdmImageFactory_BGRightBarImage;
public static function createRedFont():TdmNumberFont{
var _local1:Bitmap;
_local1 = (new TimeDigits() as Bitmap);
return (new TdmNumberFont(_local1.bitmapData, 25));
}
public static function createTitleBackground():DisplayObject{
return (new TitleBGImage());
}
public static function createHand(_arg1:Boolean):DisplayObject{
if (_arg1){
return ((new ClosedHandImage() as DisplayObject));
};
return ((new OpenHandImage() as DisplayObject));
}
public static function createHelp2():DisplayObject{
return ((new Help2Image() as DisplayObject));
}
public static function createGreenFont():TdmNumberFont{
var _local1:Bitmap;
_local1 = (new MovesDigits() as Bitmap);
return (new TdmNumberFont(_local1.bitmapData, 25));
}
public static function createGameOver():DisplayObject{
return ((new GameOverImage() as DisplayObject));
}
public static function createRightBar():BitmapData{
var _local1:Bitmap;
_local1 = (new RightBar() as Bitmap);
return (_local1.bitmapData);
}
public static function createBoardComplete():DisplayObject{
return ((new BoardCompleteImage() as DisplayObject));
}
public static function createPlayButton():SimpleButton{
var _local1:DisplayObject;
var _local2:DisplayObject;
_local1 = (new PlayImage() as DisplayObject);
_local2 = (new PlaySelImage() as DisplayObject);
return (new SimpleButton(_local1, _local2, _local2, _local2));
}
public static function createLeftBar():BitmapData{
var _local1:Bitmap;
_local1 = (new LeftBar() as Bitmap);
return (_local1.bitmapData);
}
public static function createRelaxedModeButton():SimpleButton{
var _local1:DisplayObject;
var _local2:DisplayObject;
_local1 = (new RelaxedModeImage() as DisplayObject);
_local2 = (new RelaxedModeSelImage() as DisplayObject);
return (new SimpleButton(_local1, _local2, _local2, _local2));
}
public static function createSoundToggleButton():SimpleButton{
var soundOn:DisplayObject;
var soundOff:DisplayObject;
var button:SimpleButton;
var setButton:Function;
var toggleSound:Function;
setButton = function ():void{
if (TdmSoundManager.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 (_arg1:Event):void{
TdmSoundManager.toggleSound();
setButton();
};
soundOn = new SoundOnImage();
soundOff = new SoundOffImage();
button = new SimpleButton();
setButton();
button.addEventListener(MouseEvent.CLICK, toggleSound);
return (button);
}
public static function createCopyrightButton():SimpleButton{
var _local1:TextField;
_local1 = TdmTextFactory.createCopyrightTextField("Copyright 2007 SmileyGamer.com");
return (new SimpleButton(_local1, _local1, _local1, _local1));
}
public static function createBackground(_arg1:Boolean):Sprite{
var _local2:DisplayObject;
var _local3:DisplayObject;
var _local4:DisplayObject;
var _local5:DisplayObject;
var _local6:Sprite;
_local2 = (new BGTopImage() as DisplayObject);
if (_arg1){
_local3 = (new BGLeftBarImage() as DisplayObject);
_local4 = (new BGRightBarImage() as DisplayObject);
} else {
_local3 = (new BGLeftImage() as DisplayObject);
_local4 = (new BGRightImage() as DisplayObject);
};
_local3.y = 42;
_local4.x = 342;
_local4.y = 42;
_local5 = (new BGBottomImage() as DisplayObject);
_local5.y = 342;
_local6 = new Sprite();
_local6.addChild(_local2);
_local6.addChild(_local3);
_local6.addChild(_local4);
_local6.addChild(_local5);
return (_local6);
}
public static function createTile(_arg1:int, _arg2:int):DisplayObject{
var _local3:TdmImageStrip;
var _local4:Bitmap;
if (sTileStrips[(_arg1 - 4)] == null){
_local4 = (new (sTileImages[(_arg1 - 4)]) as Bitmap);
sTileStrips[(_arg1 - 4)] = new TdmImageStrip(_local4.bitmapData, _local4.height, _local4.height);
};
_local3 = (sTileStrips[(_arg1 - 4)] as TdmImageStrip);
return (_local3.createImage(_arg2));
}
public static function createSponsorButton():SimpleButton{
var _local1:DisplayObject;
_local1 = (new SponsorLogoImage() as DisplayObject);
return (new SimpleButton(_local1, _local1, _local1, _local1));
}
public static function createChallengeModeButton():SimpleButton{
var _local1:DisplayObject;
var _local2:DisplayObject;
_local1 = (new ChallengeModeImage() as DisplayObject);
_local2 = (new ChallengeModeSelImage() as DisplayObject);
return (new SimpleButton(_local1, _local2, _local2, _local2));
}
public static function createHelp1():DisplayObject{
return ((new Help1Image() as DisplayObject));
}
public static function createHelp3():DisplayObject{
return ((new Help3Image() as DisplayObject));
}
}
}//package com.darkmoon.enigmatica
Section 12
//TdmImageFactory_BGBottomImage (com.darkmoon.enigmatica.TdmImageFactory_BGBottomImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BGBottomImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 13
//TdmImageFactory_BGLeftBarImage (com.darkmoon.enigmatica.TdmImageFactory_BGLeftBarImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BGLeftBarImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 14
//TdmImageFactory_BGLeftImage (com.darkmoon.enigmatica.TdmImageFactory_BGLeftImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BGLeftImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 15
//TdmImageFactory_BGRightBarImage (com.darkmoon.enigmatica.TdmImageFactory_BGRightBarImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BGRightBarImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 16
//TdmImageFactory_BGRightImage (com.darkmoon.enigmatica.TdmImageFactory_BGRightImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BGRightImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 17
//TdmImageFactory_BGTopImage (com.darkmoon.enigmatica.TdmImageFactory_BGTopImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BGTopImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 18
//TdmImageFactory_BoardCompleteImage (com.darkmoon.enigmatica.TdmImageFactory_BoardCompleteImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_BoardCompleteImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 19
//TdmImageFactory_ChallengeModeImage (com.darkmoon.enigmatica.TdmImageFactory_ChallengeModeImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_ChallengeModeImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 20
//TdmImageFactory_ChallengeModeSelImage (com.darkmoon.enigmatica.TdmImageFactory_ChallengeModeSelImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_ChallengeModeSelImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 21
//TdmImageFactory_ClosedHandImage (com.darkmoon.enigmatica.TdmImageFactory_ClosedHandImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_ClosedHandImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 22
//TdmImageFactory_GameOverImage (com.darkmoon.enigmatica.TdmImageFactory_GameOverImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_GameOverImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 23
//TdmImageFactory_Help1Image (com.darkmoon.enigmatica.TdmImageFactory_Help1Image)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Help1Image extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 24
//TdmImageFactory_Help2Image (com.darkmoon.enigmatica.TdmImageFactory_Help2Image)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Help2Image extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 25
//TdmImageFactory_Help3Image (com.darkmoon.enigmatica.TdmImageFactory_Help3Image)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Help3Image extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 26
//TdmImageFactory_LeftBar (com.darkmoon.enigmatica.TdmImageFactory_LeftBar)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_LeftBar extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 27
//TdmImageFactory_MovesDigits (com.darkmoon.enigmatica.TdmImageFactory_MovesDigits)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_MovesDigits extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 28
//TdmImageFactory_OpenHandImage (com.darkmoon.enigmatica.TdmImageFactory_OpenHandImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_OpenHandImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 29
//TdmImageFactory_PlayImage (com.darkmoon.enigmatica.TdmImageFactory_PlayImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_PlayImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 30
//TdmImageFactory_PlaySelImage (com.darkmoon.enigmatica.TdmImageFactory_PlaySelImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_PlaySelImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 31
//TdmImageFactory_RelaxedModeImage (com.darkmoon.enigmatica.TdmImageFactory_RelaxedModeImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_RelaxedModeImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 32
//TdmImageFactory_RelaxedModeSelImage (com.darkmoon.enigmatica.TdmImageFactory_RelaxedModeSelImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_RelaxedModeSelImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 33
//TdmImageFactory_RightBar (com.darkmoon.enigmatica.TdmImageFactory_RightBar)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_RightBar extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 34
//TdmImageFactory_SoundOffImage (com.darkmoon.enigmatica.TdmImageFactory_SoundOffImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_SoundOffImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 35
//TdmImageFactory_SoundOnImage (com.darkmoon.enigmatica.TdmImageFactory_SoundOnImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_SoundOnImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 36
//TdmImageFactory_SponsorLogoImage (com.darkmoon.enigmatica.TdmImageFactory_SponsorLogoImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_SponsorLogoImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 37
//TdmImageFactory_Tiles4 (com.darkmoon.enigmatica.TdmImageFactory_Tiles4)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Tiles4 extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 38
//TdmImageFactory_Tiles5 (com.darkmoon.enigmatica.TdmImageFactory_Tiles5)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Tiles5 extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 39
//TdmImageFactory_Tiles6 (com.darkmoon.enigmatica.TdmImageFactory_Tiles6)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Tiles6 extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 40
//TdmImageFactory_Tiles7 (com.darkmoon.enigmatica.TdmImageFactory_Tiles7)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Tiles7 extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 41
//TdmImageFactory_Tiles8 (com.darkmoon.enigmatica.TdmImageFactory_Tiles8)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_Tiles8 extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 42
//TdmImageFactory_TimeDigits (com.darkmoon.enigmatica.TdmImageFactory_TimeDigits)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_TimeDigits extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 43
//TdmImageFactory_TitleBGImage (com.darkmoon.enigmatica.TdmImageFactory_TitleBGImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmImageFactory_TitleBGImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 44
//TdmIntroScreen (com.darkmoon.enigmatica.TdmIntroScreen)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.display.*;
import com.darkmoon.*;
import flash.utils.*;
import flash.net.*;
import com.darkmoon.util.*;
public class TdmIntroScreen extends Sprite implements IdmLogic {
private var LogoImage:Class;
private var fGame:TdmGame;
private var fIntroURL:String;
public function TdmIntroScreen(_arg1:TdmGame){
var img:DisplayObject;
var button:SimpleButton;
var timer:Timer;
var showTitle:Function;
var aGame = _arg1;
LogoImage = TdmIntroScreen_LogoImage;
super();
showTitle = function (_arg1:Event):void{
fGame.showTitleScreen();
};
fGame = aGame;
if (TdmServerUtil.introImage != null){
img = TdmServerUtil.introImage;
fIntroURL = TdmServerUtil.introURL;
} else {
img = new LogoImage();
fIntroURL = "http://www.smileygamer.com";
};
button = new SimpleButton(img, img, img, img);
button.addEventListener(MouseEvent.CLICK, showSite);
button.x = ((384 - button.width) / 2);
button.y = ((384 - button.height) / 2);
addChild(button);
timer = new Timer(3000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, showTitle);
timer.start();
}
public function doLogic():void{
}
private function showSite(_arg1:Event):void{
navigateToURL(new URLRequest(fIntroURL), "_blank");
}
}
}//package com.darkmoon.enigmatica
Section 45
//TdmIntroScreen_LogoImage (com.darkmoon.enigmatica.TdmIntroScreen_LogoImage)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmIntroScreen_LogoImage extends BitmapAsset {
}
}//package com.darkmoon.enigmatica
Section 46
//TdmProgressBar (com.darkmoon.enigmatica.TdmProgressBar)
package com.darkmoon.enigmatica {
import flash.display.*;
import flash.geom.*;
public class TdmProgressBar extends Bitmap {
private var fHeight:int;
private var fImageData:BitmapData;
private var fMaxValue:int;
public function TdmProgressBar(_arg1:BitmapData, _arg2:int, _arg3:int){
super(new BitmapData(_arg1.width, _arg1.height, true, 0));
fImageData = _arg1;
fHeight = fImageData.height;
fMaxValue = _arg2;
value = _arg3;
}
public function set maxValue(_arg1:int):void{
fMaxValue = _arg1;
}
public function set value(_arg1:int):void{
var _local2:int;
_local2 = Math.round(((fHeight * _arg1) / fMaxValue));
bitmapData.fillRect(bitmapData.rect, 0);
bitmapData.copyPixels(fImageData, fImageData.rect, new Point(0, (fHeight - _local2)));
}
}
}//package com.darkmoon.enigmatica
Section 47
//TdmRelaxedMode (com.darkmoon.enigmatica.TdmRelaxedMode)
package com.darkmoon.enigmatica {
public class TdmRelaxedMode implements IdmGameMode {
private var fPoints:int;
private var fSizeIndex:int;
private var fLevel:int;
private static const MOVES_UPPER_LIMIT:Array = new Array(50, 75, 100, 150, 200);
private static const TIME_UPPER_LIMIT:Array = new Array(90, 120, 180, 240, 300);
public function TdmRelaxedMode(_arg1:int){
fSizeIndex = (_arg1 - 4);
fLevel = 1;
}
public function get points():int{
return (fPoints);
}
public function get level():int{
return (fLevel);
}
public function get maxMoves():int{
return (-1);
}
public function boardCompleted(_arg1:int, _arg2:int):int{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
_local3 = (MOVES_UPPER_LIMIT[fSizeIndex] - _arg1);
if (_local3 < 0){
_local3 = 0;
};
_local4 = int(((_local3 * _local3) / 2));
_local5 = (TIME_UPPER_LIMIT[fSizeIndex] - _arg2);
if (_local5 < 0){
_local5 = 0;
};
_local6 = int(((_local5 * _local5) / 20));
_local7 = (_local4 + _local6);
fPoints = (fPoints + _local7);
return (_local7);
}
public function get timeLimit():int{
return (-1);
}
}
}//package com.darkmoon.enigmatica
Section 48
//TdmScoreBar (com.darkmoon.enigmatica.TdmScoreBar)
package com.darkmoon.enigmatica {
import flash.display.*;
import flash.text.*;
import com.darkmoon.*;
import flash.geom.*;
public class TdmScoreBar extends Sprite {
private var fMoves:BitmapData;
private var fTimeFont:TdmNumberFont;
private var fTime:BitmapData;
private var fMovesFont:TdmNumberFont;
public function TdmScoreBar(){
var _local1:Bitmap;
var _local2:Bitmap;
var _local3:DisplayObject;
var _local4:TextField;
super();
fMoves = new BitmapData(75, 30, true, 0);
_local1 = new Bitmap(fMoves);
_local1.x = 126;
_local1.y = 6;
addChild(_local1);
fMovesFont = TdmImageFactory.createGreenFont();
fTime = new BitmapData(100, 30, true, 0);
_local2 = new Bitmap(fTime);
_local2.x = 294;
_local2.y = 6;
addChild(_local2);
fTimeFont = TdmImageFactory.createRedFont();
_local3 = TdmTextFactory.createGameGreenText("MOVES");
_local3.x = 12;
_local3.y = 4;
addChild(_local3);
_local4 = TdmTextFactory.createTextField(TdmTextFactory.DEFAULT_FONT, TdmTextFactory.SIZE_NORMAL, TdmTextFactory.COLOR_RED, false);
_local4.text = "TIME";
_local4.x = 212;
_local4.y = 4;
addChild(_local4);
}
public function update(_arg1:int, _arg2:int):void{
fMoves.fillRect(fMoves.rect, 0);
fMovesFont.drawNumber((_arg1 % 1000), fMoves, new Point(0, 0));
fTimeFont.drawTime((_arg2 % 600), fTime, new Point(0, 0));
}
}
}//package com.darkmoon.enigmatica
Section 49
//TdmScores (com.darkmoon.enigmatica.TdmScores)
package com.darkmoon.enigmatica {
import flash.net.*;
public class TdmScores {
private var fScoresObject:SharedObject;// = null
private var fTimes:Array;
private var fName:String;// = null
private var fChallengePoints:Array;
private var fHasSavedGame:Boolean;// = false
private var fPoints:Array;
private var fSavedChallenge:Array;
private var fPlays:int;// = 0
private var fMoves:Array;
private static var sInstance:TdmScores = null;
public function TdmScores(){
fPlays = 0;
fName = null;
fMoves = [999, 999, 999, 999, 999];
fTimes = [599, 599, 599, 599, 599];
fPoints = [0, 0, 0, 0, 0];
fChallengePoints = [0, 0, 0, 0, 0];
fHasSavedGame = false;
fSavedChallenge = [4, 1, 0];
fScoresObject = null;
super();
}
public function get name():String{
return (fName);
}
private function init():void{
try {
fScoresObject = SharedObject.getLocal("enigmatica-scores", "/");
if (fScoresObject.data.plays != null){
fPlays = fScoresObject.data.plays;
fName = fScoresObject.data.name;
fMoves = fScoresObject.data.moves;
fTimes = fScoresObject.data.times;
fPoints = fScoresObject.data.points;
fChallengePoints = fScoresObject.data.challengepoints;
fHasSavedGame = fScoresObject.data.hassaved;
fSavedChallenge = fScoresObject.data.savedgame;
} else {
writeScores();
};
} catch(e:Error) {
};
}
public function updateChallengeScore(_arg1:int, _arg2:int):Boolean{
var _local3:Boolean;
fHasSavedGame = false;
_local3 = false;
if (fChallengePoints[(_arg1 - 4)] < _arg2){
fChallengePoints[(_arg1 - 4)] = _arg2;
_local3 = true;
};
writeScores();
return (_local3);
}
public function get savedPoints():int{
return (fSavedChallenge[2]);
}
public function get savedChallenge():int{
return (fSavedChallenge[1]);
}
public function set name(_arg1:String):void{
fName = _arg1;
writeScores();
}
public function get saved():Boolean{
return (fHasSavedGame);
}
public function get savedBoard():int{
return (fSavedChallenge[0]);
}
private function writeScores():void{
if (fScoresObject != null){
fScoresObject.data.plays = fPlays;
fScoresObject.data.name = fName;
fScoresObject.data.moves = fMoves;
fScoresObject.data.times = fTimes;
fScoresObject.data.points = fPoints;
fScoresObject.data.challengepoints = fChallengePoints;
fScoresObject.data.hassaved = fHasSavedGame;
fScoresObject.data.savedgame = fSavedChallenge;
fScoresObject.flush(500);
};
}
public function updateScores(_arg1:int, _arg2:int, _arg3:int, _arg4:int):Boolean{
var _local5:Boolean;
fPlays++;
_local5 = false;
if (fMoves[(_arg1 - 4)] > _arg2){
fMoves[(_arg1 - 4)] = _arg2;
};
if (fTimes[(_arg1 - 4)] > _arg3){
fTimes[(_arg1 - 4)] = _arg3;
};
if (fPoints[(_arg1 - 4)] < _arg4){
fPoints[(_arg1 - 4)] = _arg4;
_local5 = true;
};
writeScores();
return (_local5);
}
public function saveChallenge(_arg1:int, _arg2:int, _arg3:int):void{
fHasSavedGame = true;
fSavedChallenge = [_arg1, _arg2, _arg3];
writeScores();
}
public function get totalScore():int{
var _local1:int;
var _local2:int;
_local1 = 0;
_local2 = 0;
while (_local2 < fPoints.length) {
_local1 = (_local1 + fPoints[_local2]);
_local1 = (_local1 + fChallengePoints[_local2]);
_local2++;
};
return (_local1);
}
public function getBestChallengeScore(_arg1:int):int{
return (fChallengePoints[(_arg1 - 4)]);
}
public function getBestScore(_arg1:int):int{
return (fPoints[(_arg1 - 4)]);
}
public function get plays():int{
return (fPlays);
}
public static function getScores():TdmScores{
if (sInstance == null){
sInstance = new (TdmScores);
sInstance.init();
};
return (sInstance);
}
}
}//package com.darkmoon.enigmatica
Section 50
//TdmSoundManager (com.darkmoon.enigmatica.TdmSoundManager)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.media.*;
public class TdmSoundManager {
private static var Music2Sound:Class = TdmSoundManager_Music2Sound;
private static var ClickSound:Class = TdmSoundManager_ClickSound;
private static var fSound:Boolean = true;
private static var fMusic2Channel:SoundChannel;
private static var fClick:Sound = (new ClickSound() as Sound);
private static var Music1Sound:Class = TdmSoundManager_Music1Sound;
private static var fGameOver:Sound = (new GameOverSound() as Sound);
private static var GameOverSound:Class = TdmSoundManager_GameOverSound;
private static var fMusic1Channel:SoundChannel;
private static var fMusic1:Sound = (new Music1Sound() as Sound);
private static var fMusic2:Sound = (new Music2Sound() as Sound);
private static var fApplause:Sound = (new ApplauseSound() as Sound);
private static var ApplauseSound:Class = TdmSoundManager_ApplauseSound;
public static function playApplause():void{
if (fSound){
fApplause.play(0, 1, new SoundTransform(0.8));
};
}
public static function playMusic():void{
var play1:Function;
var play2:Function;
play1 = function (_arg1:Event):void{
fMusic1Channel = fMusic1.play(0, 2);
fMusic1Channel.addEventListener(Event.SOUND_COMPLETE, play2);
fMusic1Channel.soundTransform.volume = 0.8;
};
play2 = function (_arg1:Event):void{
fMusic2Channel = fMusic2.play(0, 2);
fMusic2Channel.addEventListener(Event.SOUND_COMPLETE, play1);
fMusic2Channel.soundTransform.volume = 0.8;
};
if (((fSound) && ((fMusic1Channel == null)))){
play1(null);
};
}
public static function get sound():Boolean{
return (fSound);
}
public static function toggleSound():void{
sound = !(sound);
}
public static function set sound(_arg1:Boolean):void{
fSound = _arg1;
if (!fSound){
if (fMusic1Channel != null){
fMusic1Channel.stop();
};
if (fMusic2Channel != null){
fMusic2Channel.stop();
};
} else {
if (fMusic1Channel != null){
fMusic1Channel = fMusic1.play(0, 2);
};
};
}
public static function playClick():void{
if (fSound){
fClick.play();
};
}
public static function playGameOver():void{
if (fSound){
fGameOver.play();
};
}
}
}//package com.darkmoon.enigmatica
Section 51
//TdmSoundManager_ApplauseSound (com.darkmoon.enigmatica.TdmSoundManager_ApplauseSound)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmSoundManager_ApplauseSound extends SoundAsset {
}
}//package com.darkmoon.enigmatica
Section 52
//TdmSoundManager_ClickSound (com.darkmoon.enigmatica.TdmSoundManager_ClickSound)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmSoundManager_ClickSound extends SoundAsset {
}
}//package com.darkmoon.enigmatica
Section 53
//TdmSoundManager_GameOverSound (com.darkmoon.enigmatica.TdmSoundManager_GameOverSound)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmSoundManager_GameOverSound extends SoundAsset {
}
}//package com.darkmoon.enigmatica
Section 54
//TdmSoundManager_Music1Sound (com.darkmoon.enigmatica.TdmSoundManager_Music1Sound)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmSoundManager_Music1Sound extends SoundAsset {
}
}//package com.darkmoon.enigmatica
Section 55
//TdmSoundManager_Music2Sound (com.darkmoon.enigmatica.TdmSoundManager_Music2Sound)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmSoundManager_Music2Sound extends SoundAsset {
}
}//package com.darkmoon.enigmatica
Section 56
//TdmTextFactory (com.darkmoon.enigmatica.TdmTextFactory)
package com.darkmoon.enigmatica {
import flash.display.*;
import flash.text.*;
import flash.geom.*;
import flash.filters.*;
public class TdmTextFactory {
public static const SIZE_NORMAL:int = 28;
public static const COLOR_GREEN:int = 0xCCFF00;
public static const DEFAULT_FONT:String = "xoxoxa";
public static const COLOR_RED:int = 0xFF2A00;
public static const SIZE_LARGE:int = 36;
public static const SIZE_LARGEST:int = 56;
private static var XoxoxaFont:Class = TdmTextFactory_XoxoxaFont;
public static function createCopyrightTextField(_arg1:String):TextField{
var _local2:TextField;
var _local3:TextFormat;
var _local4:GlowFilter;
var _local5:DropShadowFilter;
_local2 = new TextField();
_local3 = new TextFormat("Arial", 14, 0xFFD800);
_local3.bold = true;
_local2.autoSize = TextFieldAutoSize.LEFT;
_local2.mouseEnabled = false;
_local2.defaultTextFormat = _local3;
_local2.multiline = false;
_local4 = new GlowFilter(0, 0.5, 4, 4);
_local5 = new DropShadowFilter(2);
_local2.filters = [_local4, _local5];
_local2.text = _arg1;
return (_local2);
}
public static function createGameGreenText(_arg1:String):TextField{
var _local2:TextField;
_local2 = createTextField(DEFAULT_FONT, SIZE_NORMAL, COLOR_GREEN, false);
_local2.text = _arg1;
return (_local2);
}
public static function createDefaultGreenText(_arg1:String):TextField{
var _local2:TextField;
_local2 = createTextField(DEFAULT_FONT, SIZE_NORMAL, COLOR_GREEN, true);
_local2.text = _arg1;
return (_local2);
}
public static function createCreditsText(_arg1:String):TextField{
var _local2:TextField;
_local2 = createTextField(DEFAULT_FONT, 24, COLOR_RED, true);
_local2.text = _arg1;
return (_local2);
}
public static function createEnterNameField():TextField{
return (createEditableTextField(DEFAULT_FONT, SIZE_NORMAL, COLOR_RED));
}
public static function createEditableTextField(_arg1:String, _arg2:int, _arg3:int):TextField{
var _local4:TextField;
_local4 = createTextField(_arg1, _arg2, _arg3, true);
_local4.autoSize = TextFieldAutoSize.NONE;
_local4.defaultTextFormat.align = TextFormatAlign.CENTER;
_local4.mouseEnabled = true;
_local4.type = TextFieldType.INPUT;
_local4.border = true;
_local4.borderColor = _arg3;
return (_local4);
}
public static function createTextField(_arg1:String, _arg2:int, _arg3:int, _arg4:Boolean):TextField{
var _local5:TextField;
var _local6:TextFormat;
var _local7:BevelFilter;
var _local8:DropShadowFilter;
var _local9:DropShadowFilter;
var _local10:GlowFilter;
_local5 = new TextField();
_local6 = new TextFormat(_arg1, _arg2, _arg3);
_local6.bold = true;
_local6.letterSpacing = 1;
_local5.autoSize = TextFieldAutoSize.LEFT;
_local5.mouseEnabled = false;
_local5.embedFonts = true;
_local5.defaultTextFormat = _local6;
_local5.antiAliasType = AntiAliasType.ADVANCED;
_local5.multiline = false;
_local5.transform.matrix = new Matrix(1.25, 0, 0, 1, 0, 0);
_local7 = new BevelFilter(2, 45, 0xFFFFFF, 0.8, 0, 0.8, 1.5, 1.5, 1, 3);
_local8 = new DropShadowFilter(0, -135, 0, 0.25, 1, 1, 1, 3, true);
_local9 = new DropShadowFilter(2, 45, 0, 0.8, 2, 2, 1.3, 3);
if (_arg4){
_local10 = new GlowFilter(0xFFFFFF, 0.35, 48, 48, 6);
_local5.filters = [_local7, _local8, _local9, _local10];
} else {
_local5.filters = [_local7, _local8, _local9];
};
return (_local5);
}
public static function createNarrowGreenText(_arg1:String):TextField{
var _local2:TextField;
_local2 = createTextField(DEFAULT_FONT, SIZE_NORMAL, COLOR_GREEN, false);
_local2.text = _arg1;
_local2.transform.matrix = new Matrix(1, 0, 0, 1);
return (_local2);
}
public static function createTextButton(_arg1:int, _arg2:String, _arg3:Boolean):SimpleButton{
var _local4:TextField;
var _local5:TextField;
var _local6:SimpleButton;
_local4 = createTextField(DEFAULT_FONT, _arg1, COLOR_GREEN, _arg3);
_local4.text = _arg2;
_local5 = createTextField(DEFAULT_FONT, _arg1, COLOR_RED, _arg3);
_local5.text = _arg2;
_local6 = new SimpleButton(_local4, _local5, _local5, _local5);
return (_local6);
}
}
}//package com.darkmoon.enigmatica
Section 57
//TdmTextFactory_XoxoxaFont (com.darkmoon.enigmatica.TdmTextFactory_XoxoxaFont)
package com.darkmoon.enigmatica {
import mx.core.*;
public class TdmTextFactory_XoxoxaFont extends FontAsset {
}
}//package com.darkmoon.enigmatica
Section 58
//TdmTile (com.darkmoon.enigmatica.TdmTile)
package com.darkmoon.enigmatica {
import flash.display.*;
import com.darkmoon.*;
import flash.filters.*;
public class TdmTile extends Sprite implements IdmLogic {
private var fSlideXTo:int;// = -1
private var fBoardSize:int;
private var fSelected:Boolean;
private var fTileSize:int;
private var fClone:DisplayObject;
private var fType:int;
private var fSlideYTo:int;// = -1
private static var sFilter:GlowFilter = new GlowFilter(16777176, 0.2, 64, 64, 2, 1, true);
public function TdmTile(_arg1:int, _arg2:int){
fSlideXTo = -1;
fSlideYTo = -1;
super();
fType = _arg2;
fBoardSize = _arg1;
addChild(TdmImageFactory.createTile(_arg1, fType));
fTileSize = width;
fClone = TdmImageFactory.createTile(_arg1, fType);
addChild(fClone);
fSelected = false;
}
public function set selected(_arg1:Boolean):void{
fSelected = _arg1;
if (fSelected){
filters = [sFilter];
} else {
filters = [];
};
}
public function isXLocked():Boolean{
var _local1:int;
_local1 = ((column * fTileSize) + (fTileSize / 2));
return ((Math.abs((_local1 - centerX)) < 10));
}
public function get type():int{
return (fType);
}
public function get column():int{
return ((Math.floor(((centerX / fTileSize) + TdmBoard.SIZE)) % TdmBoard.SIZE));
}
public function isYLocked():Boolean{
var _local1:int;
_local1 = ((row * fTileSize) + (fTileSize / 2));
return ((Math.abs((_local1 - centerY)) < 10));
}
public function doLogic():void{
if (fSlideXTo > -1){
if (Math.abs((fSlideXTo - x)) < 10){
super.x = fSlideXTo;
fSlideXTo = -1;
} else {
if (fSlideXTo > x){
super.x = (super.x + 10);
} else {
super.x = (super.x - 10);
};
};
};
if (fSlideYTo > -1){
if (Math.abs((fSlideYTo - y)) < 10){
super.y = fSlideYTo;
fSlideYTo = -1;
} else {
if (fSlideYTo > y){
super.y = (super.y + 10);
} else {
super.y = (super.y - 10);
};
};
};
if (x < 0){
fClone.x = TdmBoard.SIZE;
fClone.y = 0;
};
if (x > ((fBoardSize - 1) * fTileSize)){
fClone.x = -(TdmBoard.SIZE);
fClone.y = 0;
};
if (y < 0){
fClone.x = 0;
fClone.y = TdmBoard.SIZE;
};
if (y > ((fBoardSize - 1) * fTileSize)){
fClone.x = 0;
fClone.y = -(TdmBoard.SIZE);
};
}
public function get centerY():int{
return (int((y + Math.floor((fTileSize / 2)))));
}
public function get selected():Boolean{
return (fSelected);
}
public function get centerX():int{
return (int((x + Math.floor((fTileSize / 2)))));
}
public function containsPoint(_arg1:int, _arg2:int):Boolean{
return ((((((((_arg1 >= x)) && ((_arg1 < (x + fTileSize))))) && ((_arg2 >= y)))) && ((_arg2 < (y + fTileSize)))));
}
public function get row():int{
return ((Math.floor(((centerY / fTileSize) + TdmBoard.SIZE)) % TdmBoard.SIZE));
}
override public function set x(_arg1:Number):void{
super.x = _arg1;
if (centerX >= TdmBoard.SIZE){
super.x = (super.x - TdmBoard.SIZE);
};
if (centerX < 0){
super.x = (super.x + TdmBoard.SIZE);
};
}
override public function set y(_arg1:Number):void{
super.y = _arg1;
if (centerY >= TdmBoard.SIZE){
super.y = (super.y - TdmBoard.SIZE);
};
if (centerY < 0){
super.y = (super.y + TdmBoard.SIZE);
};
}
public function slideInPosition():void{
if (centerX >= TdmBoard.SIZE){
super.x = (super.x - TdmBoard.SIZE);
};
if (centerX < 0){
super.x = (super.x + TdmBoard.SIZE);
};
if (centerY >= TdmBoard.SIZE){
super.y = (super.y - TdmBoard.SIZE);
};
if (centerY < 0){
super.y = (super.y + TdmBoard.SIZE);
};
fSlideXTo = (column * fTileSize);
fSlideYTo = (row * fTileSize);
if (fSlideXTo == x){
fSlideXTo = -1;
};
if (fSlideYTo == y){
fSlideYTo = -1;
};
}
}
}//package com.darkmoon.enigmatica
Section 59
//TdmTitleScreen (com.darkmoon.enigmatica.TdmTitleScreen)
package com.darkmoon.enigmatica {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.darkmoon.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import com.darkmoon.util.*;
import flash.filters.*;
public class TdmTitleScreen extends Sprite implements IdmLogic {
private var fSizeLayer:Sprite;
private var fGreenFont:TdmNumberFont;
private var fBoardSize:int;
private var fRedFont:TdmNumberFont;
private var fCreditsLayer:Sprite;
private var fNameField:TextField;
private var fGame:TdmGame;
private var fTimer:Timer;
private var fChallenge:Boolean;
private var fModeLayer:Sprite;
private var fEnterNameLayer:Sprite;
private var fPlayLayer:Sprite;
public function TdmTitleScreen(_arg1:TdmGame){
var _local2:SimpleButton;
var _local3:SimpleButton;
var _local4:SimpleButton;
fTimer = new Timer(15000);
super();
fGame = _arg1;
addChild(TdmImageFactory.createTitleBackground());
_local2 = TdmImageFactory.createCopyrightButton();
_local2.addEventListener(MouseEvent.CLICK, showSite);
_local2.x = 2;
_local2.y = ((384 - _local2.height) - 2);
addChild(_local2);
_local3 = TdmImageFactory.createSoundToggleButton();
_local3.x = 8;
_local3.y = 8;
addChild(_local3);
_local4 = TdmImageFactory.createSponsorButton();
_local4.addEventListener(MouseEvent.CLICK, showSite);
_local4.x = 319;
_local4.y = 334;
addChild(_local4);
fPlayLayer = createButtonLayer();
addChild(fPlayLayer);
new TdmFadeAnimation(fPlayLayer, 10, TdmFadeAnimation.MODE_FADE_IN);
fGreenFont = TdmImageFactory.createGreenFont();
fRedFont = TdmImageFactory.createRedFont();
}
private function showNameLayer():void{
new TdmFadeAnimation(fPlayLayer, 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
fEnterNameLayer = createEnterNameLayer();
addChild(fEnterNameLayer);
stage.focus = fNameField;
new TdmFadeAnimation(fEnterNameLayer, 15, TdmFadeAnimation.MODE_FADE_IN);
}
private function chooseChallenge(_arg1:Event):void{
fChallenge = true;
showBoardSize();
}
private function createBoardButton(_arg1:int):SimpleButton{
var board:TdmBoard;
var m:Matrix;
var upImage:BitmapData;
var glowFilter:GlowFilter;
var normal:Sprite;
var number:Bitmap;
var overImage:BitmapData;
var selected:Sprite;
var selnumber:Bitmap;
var button:SimpleButton;
var chooseMode:Function;
var shadowFilter:DropShadowFilter;
var highShadowFilter:DropShadowFilter;
var aSize = _arg1;
chooseMode = function (_arg1:Event):void{
fBoardSize = aSize;
startGame();
};
board = new TdmBoard(aSize);
m = new Matrix(0.25, 0, 0, 0.25);
upImage = new BitmapData(75, 75);
upImage.draw(board, m);
glowFilter = new GlowFilter(0xFFFFFF, 0.35, 40, 40, 4);
normal = new Sprite();
normal.addChild(new Bitmap(upImage));
number = fGreenFont.createNumber(aSize);
number.x = 25;
number.y = 25;
number.filters = [glowFilter];
normal.addChild(number);
overImage = new BitmapData(75, 75);
overImage.draw(board, m);
selected = new Sprite();
selected.addChild(new Bitmap(overImage));
selnumber = fRedFont.createNumber(aSize);
selnumber.x = 25;
selnumber.y = 25;
selnumber.filters = [glowFilter];
selected.addChild(selnumber);
selected.x = -2;
selected.y = -2;
button = new SimpleButton(normal, selected, selected, selected);
button.addEventListener(MouseEvent.CLICK, chooseMode);
shadowFilter = new DropShadowFilter();
highShadowFilter = new DropShadowFilter(8);
button.upState.filters = [shadowFilter, glowFilter];
button.downState.filters = [highShadowFilter, glowFilter];
button.overState.filters = [highShadowFilter, glowFilter];
return (button);
}
private function showHighscores(_arg1:Event):void{
navigateToURL(new URLRequest("http://www.smileygamer.com/highscores/enigmatica.html"), "_blank");
}
private function createChooseGameModeLayer():Sprite{
var _local1:Sprite;
var _local2:GlowFilter;
var _local3:DisplayObject;
var _local4:SimpleButton;
var _local5:SimpleButton;
_local1 = new Sprite();
_local1.y = 120;
_local2 = new GlowFilter(0xFFFFFF, 0.35, 48, 48, 6);
_local3 = TdmTextFactory.createDefaultGreenText("CHOOSE GAME MODE");
_local3.x = ((width - _local3.width) / 2);
_local3.y = 20;
_local1.addChild(_local3);
_local4 = TdmImageFactory.createRelaxedModeButton();
_local4.addEventListener(MouseEvent.CLICK, chooseRelaxed);
_local4.x = ((width - _local4.width) / 2);
_local4.y = 80;
applyGlowFilter(_local4);
_local1.addChild(_local4);
_local5 = TdmImageFactory.createChallengeModeButton();
_local5.addEventListener(MouseEvent.CLICK, chooseChallenge);
_local5.x = ((width - _local5.width) / 2);
_local5.y = 140;
applyGlowFilter(_local5);
_local1.addChild(_local5);
return (_local1);
}
private function resume(_arg1:Event):void{
fGame.resumeGame();
}
private function play(_arg1:Event):void{
showModeLayer();
}
private function showSponsorSite(_arg1:Event):void{
navigateToURL(new URLRequest(fGame.sponsorURL), "_blank");
}
private function chooseRelaxed(_arg1:Event):void{
fChallenge = false;
showBoardSize();
}
private function linkURL(_arg1:Event):void{
if (TdmServerUtil.linkURL != null){
navigateToURL(new URLRequest(TdmServerUtil.linkURL), "_blank");
};
}
private function startGame():void{
fGame.startGame(fBoardSize, fChallenge);
}
private function moreGames(_arg1:Event):void{
var _local2:String;
if (fGame.sponsorURL != null){
_local2 = fGame.sponsorURL;
} else {
_local2 = TdmServerUtil.moreGamesURL;
if (_local2 == null){
_local2 = "http://www.smileygamer.com";
};
};
navigateToURL(new URLRequest(_local2), "_blank");
}
private function showBoardSize():void{
new TdmFadeAnimation(fModeLayer, 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
fSizeLayer = createChooseBoardSizeLayer();
addChild(fSizeLayer);
new TdmFadeAnimation(fSizeLayer, 15, TdmFadeAnimation.MODE_FADE_IN);
}
private function applyGlowFilter(_arg1:SimpleButton):void{
var _local2:GlowFilter;
_local2 = new GlowFilter(0xFFFFFF, 0.35, 48, 48, 6);
_arg1.upState.filters = [_local2];
_arg1.downState.filters = [_local2];
_arg1.overState.filters = [_local2];
}
public function doLogic():void{
}
private function credits(_arg1:Event):void{
new TdmFadeAnimation(fPlayLayer, 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
fCreditsLayer = createCreditsLayer();
addChild(fCreditsLayer);
new TdmFadeAnimation(fCreditsLayer, 15, TdmFadeAnimation.MODE_FADE_IN);
fTimer.addEventListener(TimerEvent.TIMER, exitCredits);
fTimer.start();
}
private function createChooseBoardSizeLayer():Sprite{
var _local1:Sprite;
var _local2:GlowFilter;
var _local3:DisplayObject;
var _local4:SimpleButton;
var _local5:SimpleButton;
var _local6:SimpleButton;
var _local7:SimpleButton;
var _local8:SimpleButton;
_local1 = new Sprite();
_local1.y = 90;
_local2 = new GlowFilter(0xFFFFFF, 0.35, 48, 48, 6);
_local3 = TdmTextFactory.createDefaultGreenText("CHOOSE BOARD SIZE");
_local3.x = ((width - _local3.width) / 2);
_local3.y = 25;
_local1.addChild(_local3);
_local4 = createBoardButton(4);
_local4.x = 40;
_local4.y = 75;
_local1.addChild(_local4);
_local5 = createBoardButton(5);
_local5.x = 155;
_local5.y = 75;
_local1.addChild(_local5);
_local6 = createBoardButton(6);
_local6.x = 270;
_local6.y = 75;
_local1.addChild(_local6);
_local7 = createBoardButton(7);
_local7.x = 100;
_local7.y = 170;
_local1.addChild(_local7);
_local8 = createBoardButton(8);
_local8.x = 215;
_local8.y = 170;
_local1.addChild(_local8);
return (_local1);
}
private function createEnterNameLayer():Sprite{
var _local1:Sprite;
var _local2:DisplayObject;
var _local3:SimpleButton;
_local1 = new Sprite();
_local1.y = 120;
_local2 = TdmTextFactory.createDefaultGreenText("ENTER YOUR NAME");
_local2.x = ((width - _local2.width) / 2);
_local2.y = 20;
_local1.addChild(_local2);
fNameField = TdmTextFactory.createEnterNameField();
fNameField.x = 42;
fNameField.y = 70;
fNameField.width = 240;
fNameField.height = 36;
fNameField.maxChars = 16;
_local1.addChild(fNameField);
_local3 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "OK", true);
_local3.addEventListener(MouseEvent.CLICK, nameChosen);
_local3.x = ((width - _local3.width) / 2);
_local3.y = 120;
_local1.addChild(_local3);
return (_local1);
}
private function createButtonLayer():Sprite{
var _local1:Sprite;
var _local2:SimpleButton;
var _local3:int;
var _local4:SimpleButton;
var _local5:SimpleButton;
var _local6:SimpleButton;
var _local7:SimpleButton;
var _local8:int;
var _local9:SimpleButton;
_local1 = new Sprite();
_local1.y = 130;
_local2 = TdmImageFactory.createPlayButton();
_local1.addChild(_local2);
_local2.addEventListener(MouseEvent.CLICK, play);
_local2.x = ((width - _local2.width) / 2);
_local2.y = 20;
applyGlowFilter(_local2);
_local3 = 0;
if (TdmScores.getScores().saved){
_local7 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "RESUME CHALLENGE", true);
_local1.addChild(_local7);
_local7.addEventListener(MouseEvent.CLICK, resume);
_local7.x = ((width - _local7.width) / 2);
_local7.y = 100;
_local1.y = 90;
_local3 = 50;
};
_local4 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "HIGHSCORES", true);
_local1.addChild(_local4);
_local4.addEventListener(MouseEvent.CLICK, showHighscores);
_local4.y = (100 + _local3);
_local5 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "CREDITS", true);
_local1.addChild(_local5);
_local5.addEventListener(MouseEvent.CLICK, credits);
_local5.y = (100 + _local3);
_local4.x = ((width - ((_local4.width + _local5.width) + 25)) / 2);
_local5.x = ((((width - ((_local4.width + _local5.width) + 25)) / 2) + _local4.width) + 25);
_local6 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "PLAY MORE GAMES", true);
_local1.addChild(_local6);
_local6.addEventListener(MouseEvent.CLICK, moreGames);
_local6.x = ((width - _local6.width) / 2);
_local6.y = (150 + _local3);
if (((!((TdmServerUtil.linkText == null))) && (!(TdmScores.getScores().saved)))){
_local8 = TdmTextFactory.SIZE_NORMAL;
if (TdmServerUtil.linkText.length > 16){
_local8 = 24;
};
_local9 = TdmTextFactory.createTextButton(_local8, TdmServerUtil.linkText, true);
_local1.addChild(_local9);
_local9.addEventListener(MouseEvent.CLICK, linkURL);
_local9.x = ((width - _local9.width) / 2);
_local9.y = (210 + _local3);
_local1.y = 100;
};
return (_local1);
}
private function exitCredits(_arg1:Event):void{
fTimer.stop();
fTimer.removeEventListener(TimerEvent.TIMER, exitCredits);
new TdmFadeAnimation(fCreditsLayer, 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
addChild(fPlayLayer);
new TdmFadeAnimation(fPlayLayer, 15, TdmFadeAnimation.MODE_FADE_IN);
}
private function nameChosen(_arg1:Event):void{
if (fNameField.text.length > 0){
TdmScores.getScores().name = fNameField.text;
};
showModeLayer();
}
private function showSite(_arg1:Event):void{
navigateToURL(new URLRequest("http://www.smileygamer.com"), "_blank");
}
private function showModeLayer():void{
new TdmFadeAnimation(getChildAt((numChildren - 1)), 15, TdmFadeAnimation.MODE_FADE_OUT_REMOVE);
fModeLayer = createChooseGameModeLayer();
addChild(fModeLayer);
new TdmFadeAnimation(fModeLayer, 15, TdmFadeAnimation.MODE_FADE_IN);
}
private function createCreditsLayer():Sprite{
var _local1:Sprite;
var _local2:DisplayObject;
var _local3:DisplayObject;
var _local4:DisplayObject;
var _local5:DisplayObject;
var _local6:SimpleButton;
_local1 = new Sprite();
_local1.y = 120;
_local2 = TdmTextFactory.createCreditsText("ENIGMATICA V1.1");
_local2.x = ((width - _local2.width) / 2);
_local2.y = 20;
_local1.addChild(_local2);
_local3 = TdmTextFactory.createCreditsText("Programming, artwork");
_local3.x = ((width - _local3.width) / 2);
_local3.y = 60;
_local1.addChild(_local3);
_local4 = TdmTextFactory.createCreditsText("and music by");
_local4.x = ((width - _local4.width) / 2);
_local4.y = 100;
_local1.addChild(_local4);
_local5 = TdmTextFactory.createCreditsText("Jochen De Schepper");
_local5.x = ((width - _local5.width) / 2);
_local5.y = 140;
_local1.addChild(_local5);
_local6 = TdmTextFactory.createTextButton(TdmTextFactory.SIZE_NORMAL, "www.smileygamer.com", true);
_local1.addChild(_local6);
_local6.x = ((width - _local6.width) / 2);
_local6.y = 180;
_local1.addEventListener(MouseEvent.CLICK, exitCredits);
return (_local1);
}
}
}//package com.darkmoon.enigmatica
Section 60
//TdmInterpolationUtil (com.darkmoon.util.TdmInterpolationUtil)
package com.darkmoon.util {
public class TdmInterpolationUtil {
public static const TYPE_LINEAR:int = 0;
public static const TYPE_ACOS:int = 2;
public static const TYPE_COSINE:int = 1;
public static function createValues(_arg1:int, _arg2:Number, _arg3:Number, _arg4:int):Array{
var _local5:Array;
var _local6:int;
var _local7:int;
_local5 = new Array(_arg4);
_local6 = (_arg4 - 1);
_local7 = 0;
while (_local7 < _arg4) {
if (_arg1 == TYPE_COSINE){
_local5[_local7] = (_arg2 + (((_arg3 - _arg2) * Number((1 - Math.cos(((_local7 * Math.PI) / _local6))))) / 2));
} else {
if (_arg1 == TYPE_ACOS){
_local5[_local7] = (_arg2 + ((_arg3 - _arg2) * Number((Math.acos((1 - ((2 * Number(_local7)) / _local6))) / Math.PI))));
} else {
_local5[_local7] = (_arg2 + (((_arg3 - _arg2) * Number(_local7)) / _local6));
};
};
_local7++;
};
return (_local5);
}
}
}//package com.darkmoon.util
Section 61
//TdmRandomUtil (com.darkmoon.util.TdmRandomUtil)
package com.darkmoon.util {
public class TdmRandomUtil {
public static function generateRandom(_arg1:int, _arg2:int):int{
return (((randomInt() % (_arg2 - _arg1)) + _arg1));
}
public static function generateRandomArray(_arg1:int):Array{
var _local2:Array;
var _local3:int;
var _local4:int;
var _local5:int;
_local2 = new Array(_arg1);
_local3 = 0;
while (_local3 < _arg1) {
_local2[_local3] = _local3;
_local3++;
};
_local3 = 0;
while (_local3 < _arg1) {
_local4 = (randomInt() % _arg1);
_local5 = _local2[_local3];
_local2[_local3] = _local2[_local4];
_local2[_local4] = _local5;
_local3++;
};
return (_local2);
}
public static function randomInt():int{
return (Math.round((Math.random() * int.MAX_VALUE)));
}
public static function chance(_arg1:int):Boolean{
var _local2:int;
if (_arg1 < 1){
return (false);
};
_local2 = (randomInt() % _arg1);
return ((_local2 == 0));
}
public static function randomBoolean():Boolean{
return (((randomInt() % 2) == 0));
}
}
}//package com.darkmoon.util
Section 62
//TdmServerUtil (com.darkmoon.util.TdmServerUtil)
package com.darkmoon.util {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class TdmServerUtil {
private static var fLinkImage:DisplayObject;
private static var fImageLoader:Loader = new Loader();
private static var fLinkText:String;
private static var fLinkURL:String;
private static var fIntroImage:DisplayObject;
private static var fLoader:URLLoader;
private static var fIntroImageURL:String;
private static var fMoreGamesURL:String;
private static var fIntroURL:String;
private static var fLinkImageURL:String;
public static function get linkImage():DisplayObject{
return (fLinkImage);
}
public static function contactServer(_arg1:String):void{
var error:Function;
var infoReceived:Function;
var linkImageReceived:Function;
var introImageReceived:Function;
var aURL = _arg1;
error = function (_arg1:Event):void{
};
infoReceived = function (_arg1:Event):void{
var _local2:String;
var _local3:Array;
trace("Server info received:");
fLoader.removeEventListener(Event.COMPLETE, infoReceived);
_local2 = (fLoader.data as String);
_local3 = _local2.split("+");
fMoreGamesURL = _local3[0];
if (fMoreGamesURL.length == 0){
fMoreGamesURL = null;
};
fLinkText = _local3[1];
if (fLinkText.length == 0){
fLinkText = null;
};
fLinkImageURL = _local3[2];
fLinkURL = _local3[3];
if (fLinkURL.length == 0){
fLinkURL = null;
};
fIntroImageURL = _local3[4];
fIntroURL = _local3[5];
if (fIntroURL.length == 0){
fIntroURL = null;
};
trace(fMoreGamesURL);
trace(fLinkText);
trace(fLinkImageURL);
trace(fLinkURL);
trace(fIntroImageURL);
trace(fIntroURL);
if (fIntroImageURL.length > 0){
fImageLoader.load(new URLRequest(fIntroImageURL));
fImageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error);
fImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, introImageReceived);
} else {
if (fLinkImageURL.length > 0){
fImageLoader.load(new URLRequest(fLinkImageURL));
fImageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error);
fImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, linkImageReceived);
};
};
};
linkImageReceived = function (_arg1:Event):void{
fImageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, linkImageReceived);
fLinkImage = fImageLoader.content;
};
introImageReceived = function (_arg1:Event):void{
fImageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, introImageReceived);
fIntroImage = fImageLoader.content;
if (fLinkImageURL.length > 0){
fImageLoader.load(new URLRequest(fLinkImageURL));
fImageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error);
fImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, linkImageReceived);
};
};
fLoader = new URLLoader(new URLRequest(aURL));
fLoader.addEventListener(IOErrorEvent.IO_ERROR, error);
fLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
fLoader.addEventListener(Event.COMPLETE, infoReceived);
}
public static function get introURL():String{
return (fIntroURL);
}
public static function get linkText():String{
return (fLinkText);
}
public static function get introImage():DisplayObject{
return (fIntroImage);
}
public static function get linkURL():String{
return (fLinkURL);
}
public static function get moreGamesURL():String{
return (fMoreGamesURL);
}
}
}//package com.darkmoon.util
Section 63
//AdmAnimation (com.darkmoon.AdmAnimation)
package com.darkmoon {
import flash.events.*;
import flash.display.*;
public class AdmAnimation implements IdmAnimation {
private var fFrame:int;// = 0
private var fLooping:Boolean;
private var fDisplayObject:DisplayObject;
public function AdmAnimation(_arg1:DisplayObject){
fFrame = 0;
super();
fDisplayObject = _arg1;
fFrame = 0;
looping = true;
if (displayObject.stage != null){
displayObject.addEventListener(Event.REMOVED_FROM_STAGE, stop);
displayObject.addEventListener(Event.ENTER_FRAME, next);
} else {
displayObject.addEventListener(Event.ADDED_TO_STAGE, start);
};
}
private function start(_arg1:Event):void{
displayObject.addEventListener(Event.REMOVED_FROM_STAGE, stop);
displayObject.addEventListener(Event.ENTER_FRAME, next);
fFrame = 0;
}
protected function get displayObject():DisplayObject{
return (fDisplayObject);
}
private function stop(_arg1:Event):void{
displayObject.removeEventListener(Event.ADDED_TO_STAGE, start);
displayObject.removeEventListener(Event.ENTER_FRAME, next);
displayObject.removeEventListener(Event.REMOVED_FROM_STAGE, stop);
}
public function update():void{
}
protected function get frame():int{
return (fFrame);
}
protected function get frameCount():int{
return (1);
}
public function get finished():Boolean{
return ((fFrame == frameCount));
}
private function next(_arg1:Event):void{
update();
fFrame++;
if (fLooping){
fFrame = (fFrame % frameCount);
};
if (finished){
displayObject.removeEventListener(Event.ENTER_FRAME, next);
};
}
public function set looping(_arg1:Boolean):void{
fLooping = _arg1;
}
public function get looping():Boolean{
return (fLooping);
}
}
}//package com.darkmoon
Section 64
//AdmGame (com.darkmoon.AdmGame)
package com.darkmoon {
import flash.events.*;
import flash.display.*;
public class AdmGame extends Sprite {
public function AdmGame(){
addEventListener(Event.ENTER_FRAME, mainLoop);
}
public function mainLoop(_arg1:Event):void{
var _local2:int;
var _local3:IdmLogic;
_local2 = 0;
while (_local2 < numChildren) {
if ((getChildAt(_local2) is IdmLogic)){
_local3 = (getChildAt(_local2) as IdmLogic);
_local3.doLogic();
};
_local2++;
};
}
}
}//package com.darkmoon
Section 65
//IdmAnimation (com.darkmoon.IdmAnimation)
package com.darkmoon {
public interface IdmAnimation {
function get finished():Boolean;
function update():void;
function get looping():Boolean;
}
}//package com.darkmoon
Section 66
//IdmLogic (com.darkmoon.IdmLogic)
package com.darkmoon {
public interface IdmLogic {
function doLogic():void;
}
}//package com.darkmoon
Section 67
//TdmFadeAnimation (com.darkmoon.TdmFadeAnimation)
package com.darkmoon {
import flash.display.*;
import com.darkmoon.util.*;
public class TdmFadeAnimation extends AdmAnimation {
private var fSteps:int;
private var fValues:Array;
private var fMode:int;
public static const MODE_FADE_IN:int = 0;
public static const MODE_FADE_OUT:int = 1;
public static const MODE_FADE_OUT_REMOVE:int = 2;
public function TdmFadeAnimation(_arg1:DisplayObject, _arg2:int, _arg3:int){
super(_arg1);
looping = false;
fSteps = _arg2;
fMode = _arg3;
if (fMode == MODE_FADE_IN){
fValues = TdmInterpolationUtil.createValues(TdmInterpolationUtil.TYPE_COSINE, 0, 1, fSteps);
} else {
fValues = TdmInterpolationUtil.createValues(TdmInterpolationUtil.TYPE_COSINE, 1, 0, fSteps);
};
}
override protected function get frameCount():int{
return (fSteps);
}
override public function update():void{
displayObject.alpha = fValues[frame];
if (fValues[frame] > 0){
displayObject.visible = true;
} else {
displayObject.visible = false;
};
}
override public function get finished():Boolean{
var _local1:Boolean;
_local1 = super.finished;
if (((_local1) && ((fMode == MODE_FADE_OUT_REMOVE)))){
displayObject.parent.removeChild(displayObject);
};
return (_local1);
}
}
}//package com.darkmoon
Section 68
//TdmImageStrip (com.darkmoon.TdmImageStrip)
package com.darkmoon {
import flash.display.*;
import flash.geom.*;
public class TdmImageStrip {
private var fWidth:int;
private var fHeight:int;
private var fImageData:BitmapData;
public function TdmImageStrip(_arg1:BitmapData, _arg2:int, _arg3:int){
fImageData = _arg1;
fWidth = _arg2;
fHeight = _arg3;
}
public function createImage(_arg1:int):Bitmap{
var _local2:BitmapData;
var _local3:Rectangle;
_local2 = new BitmapData(fWidth, fHeight, true, 0);
_local3 = new Rectangle((_arg1 * fWidth), 0, fWidth, fHeight);
_local2.copyPixels(fImageData, _local3, new Point(0, 0));
return (new Bitmap(_local2));
}
}
}//package com.darkmoon
Section 69
//TdmNumberFont (com.darkmoon.TdmNumberFont)
package com.darkmoon {
import flash.display.*;
import flash.geom.*;
public class TdmNumberFont {
private var fWidth:int;
private var fFont:BitmapData;
public function TdmNumberFont(_arg1:BitmapData, _arg2:int){
fFont = _arg1;
fWidth = _arg2;
}
public function createNumber(_arg1:int):Bitmap{
var _local2:BitmapData;
_local2 = new BitmapData(getWidth(_arg1), fFont.height, true, 0);
drawNumber(_arg1, _local2, new Point(0, 0));
return (new Bitmap(_local2));
}
public function createTime(_arg1:int):Bitmap{
var _local2:int;
var _local3:BitmapData;
_local2 = int((((fWidth - 2) * 10) / 3));
if (_arg1 >= 600){
_local2 = (_local2 + (fWidth - 2));
};
_local3 = new BitmapData(_local2, fFont.height, true, 0);
drawTime(_arg1, _local3, new Point(0, 0));
return (new Bitmap(_local3));
}
public function drawNumber(_arg1:int, _arg2:BitmapData, _arg3:Point):void{
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Rectangle;
_local4 = (int((Math.log(_arg1) * Math.LOG10E)) + 1);
_local5 = (_local4 - 1);
while (_local5 >= 0) {
_local6 = (int((_arg1 / Math.pow(10, _local5))) % 10);
_local7 = new Rectangle(((_local6 * fWidth) + 1), 0, (fWidth - 2), fFont.height);
_arg2.copyPixels(fFont, _local7, _arg3);
_arg3.x = (_arg3.x + (fWidth - 2));
_local5--;
};
}
public function getWidth(_arg1:int):int{
var _local2:int;
_local2 = (int((Math.log(_arg1) * Math.LOG10E)) + 1);
return (((fWidth - 2) * _local2));
}
public function drawTime(_arg1:int, _arg2:BitmapData, _arg3:Point):void{
var _local4:int;
var _local5:int;
var _local6:Rectangle;
_local4 = int((_arg1 / 60));
_local5 = (_arg1 % 60);
_local6 = new Rectangle(0, 0, (fWidth - 2), fFont.height);
if (_local4 > 9){
_local6.x = ((int((_local4 / 10)) * fWidth) + 1);
_arg2.copyPixels(fFont, _local6, _arg3);
_arg3.x = (_arg3.x + (fWidth - 2));
};
_local6.x = (((_local4 % 10) * fWidth) + 1);
_arg2.copyPixels(fFont, _local6, _arg3);
_arg3.x = (_arg3.x + (fWidth - 2));
_local6.x = ((10 * fWidth) + 1);
_local6.width = int(((fWidth - 2) / 3));
_arg2.copyPixels(fFont, _local6, _arg3);
_arg3.x = (_arg3.x + int(((fWidth - 2) / 3)));
_local6.width = (fWidth - 2);
_local6.x = ((int((_local5 / 10)) * fWidth) + 1);
_arg2.copyPixels(fFont, _local6, _arg3);
_arg3.x = (_arg3.x + (fWidth - 2));
_local6.x = (((_local5 % 10) * fWidth) + 1);
_arg2.copyPixels(fFont, _local6, _arg3);
}
}
}//package com.darkmoon
Section 70
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "2.0.1.0";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
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(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 71
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "2.0.1.0";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
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 = "2.0.1.0";
}
}//package mx.core
Section 73
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 74
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function set height(_arg1:Number):void;
function get scaleY():Number;
function move(_arg1:Number, _arg2:Number):void;
function get scaleX():Number;
function set mask(_arg1:DisplayObject):void;
function set scaleX(_arg1:Number):void;
function set name(_arg1:String):void;
function set scaleY(_arg1:Number):void;
function get visible():Boolean;
function get measuredWidth():Number;
function set visible(_arg1:Boolean):void;
function get alpha():Number;
function get height():Number;
function get width():Number;
function get parent():DisplayObjectContainer;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set y(_arg1:Number):void;
function get x():Number;
function get y():Number;
function set alpha(_arg1:Number):void;
}
}//package mx.core
Section 75
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function get repeaters():Array;
function get instanceIndices():Array;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 76
//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 77
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "2.0.1.0";
}
}//package mx.core
Section 78
//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 = "2.0.1.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local3:DisplayObject;
var _local4:String;
var _local5:Array;
_local3 = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
var _local2:String;
var _local3:int;
var _local4:int;
if (!_arg1){
return (null);
};
_local2 = getQualifiedClassName(_arg1);
_local3 = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
_local4 = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 79
//MochiAd (MochiAd)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function _isNetworkAvailable(){
return (!((Security.sandboxType == "localWithFile")));
}
static function _allowDomains(_arg1){
var _local2:*;
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1){
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
_arg1.removeChild(_arg1._mochiad);
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function sendHighScore(_arg1, _arg2, _arg3=null){
var _local4:*;
var _local5:*;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local5 = ["sendHighScore", _arg1];
_local4.doSend(["sendHighScore", _arg1], _arg2, _arg3);
return (true);
}
public static function _getRes(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function _parseOptions(_arg1, _arg2){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_local3 = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
return (_local3);
}
public static function showTimedAd(_arg1){
var DEFAULTS:*;
var clip:*;
var ad_msec:*;
var ad_timeout:*;
var fadeout_time:*;
var mc:*;
var wh:*;
var w:*;
var h:*;
var chk:*;
var options = _arg1;
DEFAULTS = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd"};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
return (null);
};
clip.stop();
mc = clip._mochiad;
mc.onUnload = function (){
clip.play();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = 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 (){
var _local1:*;
var _local2:*;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
_local2 = this.parent.parent;
MochiAd.unload(_local2);
delete this.onEnterFrame;
};
};
mc.unloadAd = function (){
MochiAd.unload(clip);
};
mc.adjustProgress = function (_arg1){
var _local2:*;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
chk.onEnterFrame = function (){
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
if (!chk.showing){
_local4 = _local1.loaderInfo.bytesTotal;
if ((((_local4 > 0)) || ((typeof(_local4) == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
_local3 = true;
};
};
};
if ((((_local2 > chk.ad_msec)) || (this.parent._mochiad_ctr_failed))){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function load(_arg1){
var DEFAULTS:*;
var clip:*;
var depth:*;
var mc:*;
var wh:*;
var lv:*;
var k:*;
var server:*;
var hostname:*;
var lc:*;
var name:*;
var loader:*;
var f:*;
var req:*;
var options = _arg1;
DEFAULTS = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = "1.4";
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (false);
};
if (clip._mochiad_loaded){
return (false);
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
lv = new URLVariables();
for (k in options) {
lv[k] = options[k];
};
if (clip.loaderInfo.loaderURL.indexOf("http") != 0){
options.no_page = true;
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
mc.onEnterFrame = function (){
if (!this._mochiad_ctr){
delete this.onEnterFrame;
MochiAd.unload(this.parent);
};
};
doOnEnterFrame(mc);
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;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
f = function (_arg1){
mc._mochiad_ctr_failed = true;
};
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
static function createEmptyMovieClip(_arg1, _arg2, _arg3){
var _local4:*;
_local4 = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4._name = _arg2;
return (_local4);
}
static function _loadCommunicator(_arg1){
var DEFAULTS:*;
var clip:*;
var clipname:*;
var server:*;
var depth:*;
var mc:*;
var lv:*;
var k:*;
var lc:*;
var name:*;
var req:*;
var loader:*;
var options = _arg1;
DEFAULTS = {com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = "1.4";
clip = options.clip;
clipname = ("_mochiad_com_" + options.id);
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip[clipname]){
return (clip[clipname]);
};
server = (options.com_server + options.id);
MochiAd._allowDomains(server);
delete options.id;
delete options.com_server;
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, clipname, depth);
lv = new URLVariables();
for (k in options) {
lv[k] = options[k];
};
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.name = name;
mc.lc = lc;
lv.lc = name;
mc._id = 0;
mc._queue = [];
mc.rpcResult = function (_arg1){
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_arg1 = parseInt(_arg1);
_local3 = mc._callbacks[_arg1];
if (!_local3){
return;
};
delete mc._callbacks[_arg1];
_local4 = [];
_local5 = 2;
while (_local5 < _local3.length) {
_local4.push(_local3[_local5]);
_local5++;
};
_local5 = 1;
while (_local5 < arguments.length) {
_local4.push(arguments[_local5]);
_local5++;
};
_local6 = _local3[1];
_local7 = _local3[0];
if (((_local7) && ((typeof(_local6) == "string")))){
_local6 = _local7[_local6];
};
if (_local6){
_local6.apply(_local7, _local4);
};
};
mc._didConnect = function (_arg1){
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
mc._endpoint = _arg1;
_local2 = mc._queue;
delete mc._queue;
_local3 = mc.doSend;
_local4 = 0;
while (_local4 < _local2.length) {
_local5 = _local2[_local4];
_local3.apply(this, _local5);
_local4++;
};
};
mc.doSend = function (_arg1, _arg2, _arg3){
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
if (mc._endpoint == null){
_local8 = [];
_local9 = 0;
while (_local9 < arguments.length) {
_local8.push(arguments[_local9]);
_local9++;
};
mc._queue.push(_local8);
return;
};
mc._id = (mc._id + 1);
_local5 = mc._id;
mc._callbacks[_local5] = [_arg2, ((_arg3) || (_arg2))];
_local6 = new LocalConnection();
_local7 = _local6.send(mc._endpoint, "rpc", _local5, _arg1);
};
mc._callbacks = {};
mc._callbacks[0] = [mc, "_didConnect"];
lv.st = getTimer();
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader = new Loader();
loader.load(req);
mc.addChild(loader);
mc._mochiad_com = loader;
return (mc);
}
public static function showPreloaderAd(_arg1){
var DEFAULTS:*;
var clip:*;
var ad_msec:*;
var ad_timeout:*;
var fadeout_time:*;
var mc:*;
var wh:*;
var w:*;
var h:*;
var chk:*;
var bar:*;
var bar_color:*;
var bar_background:*;
var bar_outline:*;
var backing_mc:*;
var backing:*;
var inside_mc:*;
var inside:*;
var outline_mc:*;
var outline:*;
var options = _arg1;
DEFAULTS = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
clip.play();
return (null);
};
clip.stop();
mc = clip._mochiad;
mc.onUnload = function (){
clip.play();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = 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);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
bar.x = 10;
bar.y = (h - 20);
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 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 (){
var _local1:*;
var _local2:*;
_local1 = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
_local2 = this.parent.parent;
MochiAd.unload(_local2);
delete this.onEnterFrame;
};
};
mc.unloadAd = function (){
MochiAd.unload(clip);
};
mc.adjustProgress = function (_arg1){
var _local2:*;
_local2 = mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
chk.onEnterFrame = function (){
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
_local1 = this.parent.parent;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
if (!chk.showing){
_local11 = _local2.loaderInfo.bytesTotal;
if ((((_local11 > 0)) || ((typeof(_local11) == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local3 > chk.ad_timeout){
_local4 = true;
};
};
};
if ((((_local3 > chk.ad_msec)) || (this.parent._mochiad_ctr_failed))){
_local4 = true;
};
if ((((((_local5 > 0)) && ((_local6 >= _local5)))) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function fetchHighScores(_arg1, _arg2, _arg3=null){
var _local4:*;
var _local5:*;
_local4 = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local5 = ["fetchHighScores", _arg1];
_local4.doSend(["fetchHighScores", _arg1], _arg2, _arg3);
return (true);
}
static function doOnEnterFrame(_arg1){
var f:*;
var mc = _arg1;
f = function (_arg1){
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
mc.removeEventListener(Event.ENTER_FRAME, f);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package