Section 1
//HGAErrors (com.hubworld.game.api.HGAErrors)
package com.hubworld.game.api {
public class HGAErrors {
public static const HGA_ERROR_TYPE_2_VERSION_ERROR:String = "VersionError";
public static const HGA_ERROR_301_DETAIL:String = "The Hub Game Shell is experiencing a service-communication error.";
public static const HGA_ERROR_TYPE_3_IO_ERROR:String = "IOError";
public static const HGA_ERROR_104_DETAIL:String = "Flex-based game SWF could not establish API communication with the game shell.";
public static const HGA_ERROR_102_DETAIL:String = "Initialization in progress. Do no call startApi() twice.";
public static const HGA_ERROR_201_DETAIL:String = "Your game uses a version of HubGameApi that is not supported by the Hub Game Shell";
public static const HGA_ERROR_101_SUBTYPE:String = "null_root";
public static const HGA_ERROR_201_SUBTYPE:String = "api_version_mismatch";
public static const HGA_ERROR_103_SUBTYPE:String = "initialized_once";
public static const HGA_ERROR_104_SUBTYPE:String = "flex_communication";
public static const HGA_ERROR_102_SUBTYPE:String = "initializing_now";
public static const HGA_ERROR_301_SUBTYPE:String = "shell_communication";
public static const HGA_ERROR_103_DETAIL:String = "Initialization previously completed. Do no call startApi() twice.";
public static const HGA_ERROR_TYPE_1_INIT_ERROR:String = "InitError";
public static const HGA_ERROR_101_DETAIL:String = "Contstructor arg 'rootRef' is null. It must be a display object that is currently on the display list.";
public function HGAErrors(){
super();
}
public static function create(errorNum:uint):Object{
var errorNumString:String;
var typeNumString:String;
var error:Object;
errorNumString = String(errorNum);
typeNumString = errorNumString.substr(0, (errorNumString.length - 2));
error = new Object();
error.type = HGAErrors[("HGA_ERROR_TYPE_" + typeNumString)];
error.subtype = HGAErrors[(("HGA_ERROR_" + errorNum) + "_SUBTYPE")];
error.detail = HGAErrors[(("HGA_ERROR_" + errorNum) + "_DETAIL")];
return (error);
}
}
}//package com.hubworld.game.api
Section 2
//HGAEvent (com.hubworld.game.api.HGAEvent)
package com.hubworld.game.api {
import flash.events.*;
public class HGAEvent extends Event {
public var result:Object;
public static const HGA_RESPONSE_GET_START_OK:String = "hgaResponseGetStartOk";
public static const HGA_RESPONSE_REPORT_SCORE:String = "hgaResponseReportScore";
public static const HGA_RESPONSE_REPORT_TRACKING_POINT:String = "hgaResponseReportTrackingPoint";
public static const HGA_RESPONSE_REPORT_RESUME:String = "hgaResponseReportResume";
public static const HGA_RESPONSE_CHECK_FOR_PROFANITY:String = "hgaResponseCheckForProfanity";
public static const HGA_RESPONSE_START_API_COMPLETE:String = "hgaResponseStartApiComplete";
public static const HGA_RESPONSE_REPORT_ACHIEVEMENT:String = "hgaResponseReportAchievement";
public static const HGA_RESPONSE_ERROR:String = "hgaResponseInitError";
public static const HGA_RESPONSE_REPORT_PAUSE:String = "hgaResponseReportPause";
public static const HGA_RESPONSE_GET_GAME_STATE:String = "hgaResponseGetGameState";
public static const HGA_RESPONSE_REPORT_PREEMPTION_POINT:String = "hgaResponseReportPreemptionPoint";
public static const HGA_RESPONSE_REPORT_QUIT:String = "hgaResponseReportQuit";
public static const HGA_RESPONSE_REPORT_FINISH:String = "hgaResponseReportFinish";
public static const HGA_RESPONSE_DECRYPT_VALUE:String = "hgaResponseDecryptValue";
public function HGAEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false){
super(type, bubbles, cancelable);
result = new Object();
}
override public function clone():Event{
return (new HGAEvent(this.type, this.bubbles, this.cancelable));
}
}
}//package com.hubworld.game.api
Section 3
//HGAPrivateEvent (com.hubworld.game.api.HGAPrivateEvent)
package com.hubworld.game.api {
import flash.events.*;
public class HGAPrivateEvent extends Event {
public var gameVersion:String;
public var gameApiFrontRef:HubGameApi;
public var gameApiVersionFront:String;
public var handshakeCallback:Function;
public var runmode:String;
public static const FRONT_API_INITIATES_HANDSHAKE:String = "frontApiInitiatesHandshake";
public function HGAPrivateEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new HGAPrivateEvent(this.type, this.bubbles, this.cancelable));
}
}
}//package com.hubworld.game.api
Section 4
//HGAStatus (com.hubworld.game.api.HGAStatus)
package com.hubworld.game.api {
public class HGAStatus {
public static const HGA_STATUS_READY:String = "hgaStatusReady";
public function HGAStatus(){
super();
}
}
}//package com.hubworld.game.api
Section 5
//HubGameApi (com.hubworld.game.api.HubGameApi)
package com.hubworld.game.api {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.system.*;
public class HubGameApi extends EventDispatcher {
private var _rootRef:DisplayObject;
private var _constructorCallback:Function;
private var _constructorCallId:uint;
public var testVar:String;// = "I am HubGameApi.testVar"
private var _detectFlexSwfReadyTries:int;
private var _apiInitializing:Boolean;
private var _gameVersion:String;
private var _runmode:String;
private var _apiInitialized:Boolean;
private var _backApiRef:Object;
public static const PREEMPT_MEDIUM:uint = 2;
private static const DETECT_FLEX_READY_RETRY_DELAY_MILLISECONDS:int = 100;
public static const PREEMPT_SHORT:uint = 1;
private static const HUB_GAME_API_VERSION:String = "FrontApi v2.5";
public static const DELAY_MILLISECONDS_BEFORE_ASSUMING_GAME_SWF_IS_FLEX_BUILT:Number = 1;
public static const PREEMPT_LONG:uint = 3;
public static const RUNMODE_LOCAL:String = "runmodeLocal";
public static const RUNMODE_NETWORKED:String = "runmodeNetworked";
private static const DETECT_FLEX_READY_MAX_TRIES:int = 100;
private static var _instance:HubGameApi;
public function HubGameApi(){
testVar = "I am HubGameApi.testVar";
super();
trace("HubGameApi CONSTRUCTOR");
if (HubGameApi._instance == null){
_instance = this;
} else {
trace("Error: A singleton instance of HubGameApi already Exists. You may access it via its variable, or via HubGameApi.instance");
};
}
public function reportPreemptionPoint_result(result:Object):void{
var outEvent:HGAEvent;
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_REPORT_PREEMPTION_POINT);
outEvent.result = result;
dispatchEvent(outEvent);
}
public function reportResume():void{
if (_backApiRef){
_backApiRef.reportResume();
};
}
public function getGameState():void{
if (_backApiRef){
_backApiRef.getGameState();
};
}
public function encryptValue(valueName:String, value):void{
if (_backApiRef){
_backApiRef.encryptValue(valueName, value);
};
}
public function getGameState_result(result:Object):void{
var outEvent:HGAEvent;
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_GET_GAME_STATE);
outEvent.result = result;
dispatchEvent(outEvent);
}
public function getStartOk_result(result:Object):void{
var outEvent:HGAEvent;
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_GET_START_OK);
outEvent.result = result;
dispatchEvent(outEvent);
}
public function get instance():HubGameApi{
if (_instance == null){
trace("Error: The HubGameApi singleton has not yet been instantiated via the new operator.");
return (null);
};
return (_instance);
}
public function checkForProfanity(value:String, asyncToken:String):void{
if (_backApiRef){
_backApiRef.checkForProfanity(value, asyncToken);
};
}
private function dbug(msg:String):void{
var output:String;
output = ("HubGameApi:: " + msg);
trace(output);
}
public function reportAchievement_result(result:Object):void{
}
public function reportResume_result(result:Object):void{
var outEvent:HGAEvent;
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_REPORT_RESUME);
outEvent.result = result;
dispatchEvent(outEvent);
}
public function reportStart():void{
if (_backApiRef){
_backApiRef.reportStart();
};
}
public function reportPause():void{
if (_backApiRef){
_backApiRef.reportPause();
};
}
public function reportQuit():void{
if (_backApiRef){
_backApiRef.reportQuit();
};
}
private function _startApi_detectFlexSwfReady():void{
var outEvent:HGAEvent;
dbug("Flex-based game SWF attempting to establish API communication...");
if (_rootRef.loaderInfo.loader == null){
_detectFlexSwfReadyTries++;
if (_detectFlexSwfReadyTries < DETECT_FLEX_READY_MAX_TRIES){
setTimeout(_startApi_detectFlexSwfReady, DETECT_FLEX_READY_RETRY_DELAY_MILLISECONDS);
} else {
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_ERROR);
outEvent.result.error = HGAErrors.create(104);
dispatchEvent(outEvent);
trace(outEvent.result.error.detail);
};
} else {
_startApi_initiateHandshakeWithBackApi();
};
}
public function getStartOk():void{
if (_backApiRef){
_backApiRef.getStartOk();
};
}
public function encryptValue_result(result:Object):void{
dbug("encryptValue_result: ");
}
public function reportQuit_result(result:Object):void{
}
public function saveGameState_result(result:Object):void{
}
public function reportScore(scoreObject:Object):void{
if (_backApiRef){
_backApiRef.reportScore(scoreObject);
};
}
public function saveGameState(gameStateBA:ByteArray):void{
if (_backApiRef){
_backApiRef.saveGameState(gameStateBA);
};
}
public function reportTrackingPoint(trackString:String):void{
if (_backApiRef){
_backApiRef.reportTrackingPoint(trackString);
};
}
public function checkForProfanity_result(approved:String, asyncToken:String):void{
var outEvent:HGAEvent;
dbug(((("checkForProfanity_result: approved = " + approved) + " / asyncToken = ") + asyncToken));
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_CHECK_FOR_PROFANITY);
outEvent.result = new Object();
outEvent.result.approved = approved;
outEvent.result.asyncToken = asyncToken;
dispatchEvent(outEvent);
}
public function reportScore_result(result:Object):void{
}
private function _startApi_initiateHandshakeWithBackApi():void{
var functionOwner:HubGameApi;
var handshakeCallback:Function;
var sharedEventsDispatcher:IEventDispatcher;
var outEvent:HGAPrivateEvent;
dbug("__initiateHandshakeWithBackApi");
if (_rootRef.loaderInfo.loader != null){
dbug(". GAME HAS BEEN LOADED INSIDE THE SHELL ENVIRONMENT!!");
functionOwner = this;
handshakeCallback = function (backApiRef:Object, status:String, gameConfig:Object, gameAssetPath:String):void{
var outEvent:HGAEvent;
dbug("handshakeCallback");
_backApiRef = backApiRef;
dbug((". _rootRef.loaderInfo.loaderURL = " + _rootRef.loaderInfo.loaderURL));
dbug((". backApiRef = " + backApiRef));
dbug((". status = " + status));
dbug((". gameAssetPath = " + gameAssetPath));
dbug((". gameConfig.userHandle = " + gameConfig.userHandle));
dbug((". gameConfig.gameAssetPath = " + gameConfig.gameAssetPath));
dbug((". gameConfig.sponsorAssetPath = " + gameConfig.sponsorAssetPath));
dbug((". gameAssetPath = " + gameAssetPath));
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_START_API_COMPLETE);
outEvent.result = new Object();
outEvent.result.status = status;
outEvent.result.gameSwfPath = gameAssetPath;
outEvent.result.gameConfig = gameConfig;
dispatchEvent(outEvent);
};
Security.allowDomain(_rootRef.loaderInfo.loaderURL);
sharedEventsDispatcher = (_rootRef.loaderInfo.sharedEvents as IEventDispatcher);
outEvent = new HGAPrivateEvent(HGAPrivateEvent.FRONT_API_INITIATES_HANDSHAKE);
outEvent.gameApiFrontRef = this;
outEvent.runmode = _runmode;
outEvent.gameVersion = _gameVersion;
outEvent.gameApiVersionFront = HUB_GAME_API_VERSION;
outEvent.handshakeCallback = handshakeCallback;
sharedEventsDispatcher.dispatchEvent(outEvent);
_apiInitialized = true;
} else {
dbug(". GAME HAS BEEN LOADED OUTSIDE THE SHELL ENVIRONMENT!!");
};
_apiInitializing = false;
}
public function startApi(gameVersion:String, rootRef:DisplayObject, runmode:String):void{
var outEvent:HGAEvent;
var isFlexSwf:Boolean;
dbug("startApi");
if (_apiInitializing){
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_ERROR);
outEvent.result.error = HGAErrors.create(102);
dispatchEvent(outEvent);
trace(outEvent.result.error.detail);
};
if (_apiInitialized){
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_ERROR);
outEvent.result.error = HGAErrors.create(103);
dispatchEvent(outEvent);
trace(outEvent.result.error.detail);
};
if (((!(_apiInitializing)) && (!(_apiInitialized)))){
if ((((rootRef == null)) || ((rootRef.loaderInfo == null)))){
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_ERROR);
outEvent.result.error = HGAErrors.create(101);
dispatchEvent(outEvent);
trace(outEvent.result.error.detail);
} else {
_apiInitializing = true;
_gameVersion = gameVersion;
_rootRef = rootRef;
_runmode = runmode;
isFlexSwf = __isFlexSwf(rootRef);
dbug((". isFlexSwf > " + isFlexSwf));
if (isFlexSwf){
_detectFlexSwfReadyTries = 0;
_startApi_detectFlexSwfReady();
} else {
_startApi_initiateHandshakeWithBackApi();
};
};
};
}
public function reportPause_result(result:Object):void{
var outEvent:HGAEvent;
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_REPORT_PAUSE);
outEvent.result = null;
dispatchEvent(outEvent);
}
public function reportAchievement(achievementObject:Object):void{
if (_backApiRef){
_backApiRef.reportAchievement(achievementObject);
};
}
public function decryptValue_result(value):void{
var outEvent:HGAEvent;
dbug("decryptValue_result: ");
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_DECRYPT_VALUE);
outEvent.result = new Object();
outEvent.result.value = value;
dispatchEvent(outEvent);
}
public function reportPreemptionPoint(preemptionIdNum:uint, preemptionPointType:uint):void{
if (_backApiRef){
_backApiRef.reportPreemptionPoint(preemptionIdNum, preemptionPointType);
};
}
public function decryptValue(valueName:String):void{
if (_backApiRef){
_backApiRef.decryptValue(valueName);
};
}
public function reportTrackingPoint_result(result:Object):void{
}
public function reportFinish(finishObject:Object, scoreObject:Object):void{
if (_backApiRef){
_backApiRef.reportFinish(finishObject, scoreObject);
};
}
public function reportStart_result(result:Object):void{
}
public function reportFinish_result(result:Object):void{
var outEvent:HGAEvent;
outEvent = new HGAEvent(HGAEvent.HGA_RESPONSE_REPORT_FINISH);
outEvent.result = result;
dispatchEvent(outEvent);
}
private function __isFlexSwf(rootRef:Object):Boolean{
var description:XML;
var rootClassType:String;
var tempList:Array;
var lastItem:String;
description = describeType(rootRef);
rootClassType = description.@name;
tempList = rootClassType.split("_");
lastItem = tempList[(tempList.length - 1)];
if (lastItem == "SystemManager"){
return (true);
};
return (false);
}
}
}//package com.hubworld.game.api
Section 6
//UsefulEvent (com.kid360.events.UsefulEvent)
package com.kid360.events {
import flash.events.*;
public class UsefulEvent extends Event {
public var data:Object;
public static const USEFUL_EVENT:String = "usefulEvent";
public function UsefulEvent(eventData:Object, type:String="usefulEvent", bubbles:Boolean=true, cancelable:Boolean=true){
super(type, bubbles, cancelable);
data = eventData;
}
override public function toString():String{
return (formatToString("UsefulEvent", "type", "bubbles", "cancelable", "eventPhase", "data"));
}
override public function clone():Event{
return (new UsefulEvent(data, type, bubbles, cancelable));
}
}
}//package com.kid360.events
Section 7
//PonyModel (com.kid360.mlp.ponycreator.PonyModel)
package com.kid360.mlp.ponycreator {
import com.kid360.mlp.*;
import flash.geom.*;
import flash.display.*;
import flash.events.*;
import fl.motion.*;
public class PonyModel extends MovieClip {
private var settings:Object;
public var ponySkirt:MovieClip;
public var ponyHat:MovieClip;
public var ponyMane:MovieClip;
public var ponyTail:MovieClip;
public var ponyNecklace:MovieClip;
public var ponyBody:MovieClip;
public var ponyEye:MovieClip;
public function PonyModel(){
super();
settings = (MLPConstants.defaultAvatar() as Object);
stop();
ponyBody.stop();
ponyEye.stop();
ponyMane.horn.visible = (ponyMane.patch.visible = (settings.body.variant > 0));
ponyMane.stop();
ponyMane.patch.stop();
ponyTail.stop();
ponyHat.stop();
ponyNecklace.stop();
ponySkirt.stop();
}
public function showParts(flag:Boolean):void{
ponyEye.visible = (ponyMane.visible = (ponyTail.visible = (ponyHat.visible = (ponyNecklace.visible = (ponySkirt.visible = flag)))));
}
public function get specs():Object{
return (settings);
}
public function set body(partSpec:Object):void{
settings.body = partSpec;
previewBody(partSpec);
}
private function tintBody(shade:uint, alpha:Number):void{
var tint:Color;
tint = new Color();
tint.setTint(shade, alpha);
ponyBody.transform.colorTransform = tint;
ponyMane.ear.transform.colorTransform = tint;
ponyMane.horn.transform.colorTransform = tint;
}
public function set bottoms(partSpec:Object):void{
settings.bottoms = partSpec;
ponySkirt.gotoAndStop((ponySkirt.currentLabels[partSpec.variant].frame + partSpec.color));
}
public function set ponyName(newName:String):void{
settings.name = newName;
}
public function set tops(partSpec:Object):void{
settings.tops = partSpec;
ponyNecklace.gotoAndStop((ponyNecklace.currentLabels[partSpec.variant].frame + partSpec.color));
}
public function set eye(partSpec:Object):void{
settings.eye = partSpec;
ponyEye.gotoAndStop((ponyEye.currentLabels[partSpec.variant].frame + partSpec.color));
}
public function previewBody(partSpec:Object, isLocked:Boolean=false):void{
trace("model set body var", partSpec.variant, "color", partSpec.color);
if (isLocked){
trace("is locked");
showParts(false);
gotoAndStop((partSpec.variant + 1));
} else {
ponyBody.gotoAndStop(ponyBody.currentLabels[partSpec.variant].frame);
ponyMane.horn.visible = (ponyMane.patch.visible = (partSpec.variant == 2));
if (partSpec.color > 0){
tintBody(MLPConstants.BODY_COLORS[partSpec.color], 0.5);
} else {
ponyBody.transform.colorTransform = new ColorTransform();
ponyMane.ear.transform.colorTransform = new ColorTransform();
ponyMane.horn.transform.colorTransform = new ColorTransform();
};
};
}
public function set tail(partSpec:Object):void{
settings.tail = partSpec;
ponyTail.gotoAndStop((ponyTail.currentLabels[partSpec.variant].frame + partSpec.color));
}
public function set head(partSpec:Object):void{
settings.head = partSpec;
ponyHat.gotoAndStop((ponyHat.currentLabels[partSpec.variant].frame + partSpec.color));
}
public function set hair(partSpec:Object):void{
settings.hair = partSpec;
ponyMane.gotoAndStop((ponyMane.currentLabels[partSpec.variant].frame + partSpec.color));
ponyMane.patch.gotoAndStop((ponyMane.currentLabels[partSpec.variant].frame + partSpec.color));
}
}
}//package com.kid360.mlp.ponycreator
Section 8
//ChanceEncounter (com.kid360.mlp.ponyville.ChanceEncounter)
package com.kid360.mlp.ponyville {
import com.kid360.mlp.*;
import flash.display.*;
import flash.events.*;
import com.kid360.events.*;
import flash.text.*;
public class ChanceEncounter extends MovieClip {
private const NUM_REWARDS:uint = 1;
private const NUM_DIALOGS:uint = 8;
private const NUM_DILEMMAS:uint = 11;
private const NUM_ANIMS:uint = 4;
private const NUM_COMMENTS:uint = 3;
public var userChoice:uint;
public var theEncounter:int;
public var outcomePanel:MovieClip;
public var choices:MovieClip;
public var readout:TextField;
public static const DOWNTOWN_DIALOGS:Array = [CUPCAKE_DIALOG, DINNER_DIALOG, SHOPPE_DIALOG];
public static const JUMP_ANIM:uint = 3;
public static const FARM_DIALOGS:Array = [HARVEST_DIALOG, APPLE_PIE_DIALOG, HARD_WORKER_DIALOG];
public static const LOYALTY_DILEMMA:uint = 13;
public static const HARVEST_DIALOG:uint = 24;
public static const FLYING_DIALOG:uint = 33;
public static const SUBURBS_DIALOGS:Array = [MANE_DIALOG, COAT_DIALOG, FERNANDO_DIALOG];
public static const SHOPPE_DIALOG:uint = 29;
public static const APPLE_DILEMMA:uint = 5;
public static const SPARKLE_REWARD:uint = 4;
public static const APPLE_PIE_DIALOG:uint = 25;
public static const HI_THERE_DIALOG:uint = 20;
public static const FLIP_ANIM:uint = 1;
public static const SADDLE_DILEMMA:uint = 7;
public static const WAY_TO_GO_DIALOG:uint = 22;
public static const DINNER_DIALOG:uint = 28;
public static const PARK_DIALOGS:Array = [FLYING_DIALOG, MUSIC_DIALOG, CLOUDS_DIALOG];
public static const NEST_DILEMMA:uint = 8;
public static const FRIENDSHIP_DILEMMA:uint = 9;
public static const FLOWER_DILEMMA:uint = 15;
public static const ILLNESS_DILEMMA:uint = 12;
public static const MUSIC_DIALOG:uint = 34;
public static const THEFT_DILEMMA:uint = 14;
public static const MANE_DIALOG:uint = 30;
public static const REAR_ANIM:uint = 2;
public static const HI_DIALOG:uint = 21;
public static const CUPCAKE_DIALOG:uint = 27;
public static const FERNANDO_DIALOG:uint = 32;
public static const BUCK_ANIM:uint = 0;
public static const CLOUDS_DIALOG:uint = 35;
public static const HARD_WORKER_DIALOG:uint = 26;
public static const STUDYING_DILEMMA:uint = 10;
public static const HAT_DILEMMA:uint = 6;
public static const OFF_TO_PLAY_DIALOG:uint = 18;
public static const CLEANUP_DILEMMA:uint = 11;
public static const COAT_DIALOG:uint = 31;
public static const SPARKS_DIALOG:uint = 23;
public static const PONY_UP_DIALOG:uint = 19;
public static const GREAT_DAY_DIALOG:uint = 17;
public static const PONYVILLE_DIALOG:uint = 16;
public function ChanceEncounter(encounterIndex:int){
super();
theEncounter = encounterIndex;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onDilemmaMessage(e:UsefulEvent):void{
var eventName:String;
var payload:Object;
eventName = e.data.name;
payload = e.data.payload;
switch (eventName){
case "dilemmaChoice":
userChoice = payload.choice;
break;
case "dilemmaChoiceDone":
gotoAndStop("resolution");
break;
case "resolutionDone":
encounterDone();
break;
};
}
private function dilemmaReward():Array{
var vals:Array;
var dilemmaNum:uint;
vals = [[[0, 0, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]], [[1, 0, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 0, 0]], [[0, 1, 0, 1, 0], [1, 0, 1, 0, 0], [1, 0, 0, 0, 0]], [[0, 0, 0, 0, 1], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0]], [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]], [[0, 0, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 0]], [[0, 0, 1, 0, 1], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]], [[1, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]], [[0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 0]], [[0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0]], [[0, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]];
dilemmaNum = (theEncounter - APPLE_DILEMMA);
return (vals[dilemmaNum][userChoice]);
}
public function encounterDone():void{
var encounterPayload:Object;
var encounterSparks:Array;
var i:int;
removeEventListener(UsefulEvent.USEFUL_EVENT, onDilemmaMessage);
gotoAndStop("home");
encounterPayload = {index:theEncounter, points:0, sparks:[0, 0, 0, 0, 0]};
if (isDilemma(theEncounter)){
encounterSparks = dilemmaReward();
i = 0;
while (i < encounterSparks.length) {
encounterPayload.sparks[i] = (encounterPayload.sparks[i] + (encounterSparks[i] * 2));
i++;
};
} else {
if (theEncounter == SPARKLE_REWARD){
encounterPayload.sparks = [1, 1, 1, 1, 1];
};
};
dispatchEvent(new UsefulEvent({name:MLPConstants.ENCOUNTER_DONE, payload:encounterPayload}));
}
private function onAddedToStage(e:Event):void{
var dilemmaNum:uint;
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
if ((((theEncounter == SPARKLE_REWARD)) || ((theEncounter > FLOWER_DILEMMA)))){
gotoAndStop("sparkle");
} else {
dilemmaNum = (theEncounter - SPARKLE_REWARD);
gotoAndStop(("dilemma" + dilemmaNum));
addEventListener(UsefulEvent.USEFUL_EVENT, onDilemmaMessage);
};
}
public static function isDilemma(encounterNum:uint):Boolean{
return ((((encounterNum >= APPLE_DILEMMA)) && ((encounterNum <= FLOWER_DILEMMA))));
}
public static function localDialogs(panoNum:uint):Array{
return ([FARM_DIALOGS, DOWNTOWN_DIALOGS, SUBURBS_DIALOGS, PARK_DIALOGS][panoNum]);
}
public static function animName(encounterNum:uint):String{
return (["buck", "flip", "rear", "jump"][encounterNum]);
}
}
}//package com.kid360.mlp.ponyville
Section 9
//NavButton (com.kid360.mlp.ui.NavButton)
package com.kid360.mlp.ui {
import flash.display.*;
import flash.events.*;
public class NavButton extends MovieClip {
public var indicating:Boolean;// = false
public var faces:MovieClip;
public function NavButton(){
indicating = false;
super();
mouseChildren = false;
buttonMode = true;
addEventListener(MouseEvent.MOUSE_OVER, onRolledOver);
addEventListener(MouseEvent.MOUSE_OUT, onRolledOut);
addEventListener(MouseEvent.MOUSE_DOWN, onPressed);
faces.stop();
}
private function onRolledOver(e:MouseEvent):void{
buttonMode = (parent as MovieClip).canTeleport;
if ((parent as MovieClip).canTeleport){
glowing = true;
};
}
private function onPressed(e:MouseEvent):void{
if (!(parent as MovieClip).canTeleport){
return;
};
if (!indicating){
faces.gotoAndStop("down");
};
}
public function set glowing(flag:Boolean):void{
faces.gotoAndStop((flag) ? "over" : "up");
}
private function onRolledOut(e:MouseEvent):void{
if (!(parent as MovieClip).canTeleport){
return;
};
if (!indicating){
faces.gotoAndStop("up");
};
}
}
}//package com.kid360.mlp.ui
Section 10
//AvatarSpec (com.kid360.mlp.AvatarSpec)
package com.kid360.mlp {
import com.kid360.*;
public class AvatarSpec {
public var creationTime:Number;// = 0
public var mark:uint;// = 0
public var tail:Object;
public var name:String;// = ""
public var markingTime:Number;// = 0
public var body:Object;
public var head:Object;
public var bottoms:Object;
public var eye:Object;
public var hair:Object;
public var tops:Object;
public function AvatarSpec(){
name = "";
creationTime = 0;
body = {variant:0, color:0};
eye = {variant:0, color:0};
hair = {variant:0, color:0};
tail = {variant:0, color:0};
head = {variant:1, color:0};
tops = {variant:1, color:0};
bottoms = {variant:1, color:0};
mark = 0;
markingTime = 0;
super();
}
public function clone():AvatarSpec{
return (({name:name, creationTime:creationTime, body:{variant:body.variant, color:body.color}, eye:{variant:eye.variant, color:eye.color}, hair:{variant:hair.variant, color:hair.color}, tail:{variant:tail.variant, color:tail.color}, head:{variant:head.variant, color:head.color}, tops:{variant:tops.variant, color:tops.color}, bottoms:{variant:bottoms.variant, color:bottoms.color}, mark:mark, markingTime:markingTime} as AvatarSpec));
}
public function toString():String{
var s:String;
s = (("[" + name) + "\n");
s = (s + (("\tBorn:\t" + new Date(creationTime).toString()) + "\n"));
s = (s + ((("\tBody:\t" + body.variant) + MLPConstants.COLOR_NAMES[body.color]) + "\n"));
s = (s + ((("\tEyes:\t" + eye.variant) + MLPConstants.COLOR_NAMES[eye.color]) + "\n"));
s = (s + ((("\tHair:\t" + hair.variant) + MLPConstants.COLOR_NAMES[hair.color]) + "\n"));
s = (s + ((("\tTail:\t" + tail.variant) + MLPConstants.COLOR_NAMES[tail.color]) + "\n"));
s = (s + ((("\tHead:\t" + head.variant) + MLPConstants.COLOR_NAMES[head.color]) + "\n"));
s = (s + ((("\tNeck:\t" + tops.variant) + MLPConstants.COLOR_NAMES[tops.color]) + "\n"));
s = (s + ((("\tBack:\t" + bottoms.variant) + MLPConstants.COLOR_NAMES[bottoms.color]) + "\n"));
s = (s + (((("\tMark:\t" + ((mark == 0)) ? "none" : String(mark)) + " on ") + new Date(markingTime).toString()) + "]"));
return (s);
}
public function get isMarked():Boolean{
return ((markingTime > 0));
}
public static function anySpec():Object{
var anyName:Function;
var ponySpec:Object;
anyName = function ():String{
return (("Pony" + Utils.randInRange(1000, 9999)));
};
ponySpec = new (AvatarSpec);
ponySpec.name = anyName();
ponySpec.body = {variant:Utils.randInRange(0, (MLPConstants.NUM_BODY_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.eye = {variant:Utils.randInRange(0, (MLPConstants.NUM_EYE_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.hair = {variant:Utils.randInRange(0, (MLPConstants.NUM_MANE_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.tail = {variant:Utils.randInRange(0, (MLPConstants.NUM_TAIL_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.head = {variant:Utils.randInRange(0, (MLPConstants.NUM_HAT_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.tops = {variant:Utils.randInRange(0, (MLPConstants.NUM_NECK_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.bottoms = {variant:Utils.randInRange(0, (MLPConstants.NUM_BACK_CHOICES - 1)), color:Utils.randInRange(0, (MLPConstants.NUM_COLOR_CHOICES - 1))};
ponySpec.mark = Utils.randInRange(1, 20);
return (ponySpec);
}
}
}//package com.kid360.mlp
Section 11
//FriendshipThermometer (com.kid360.mlp.FriendshipThermometer)
package com.kid360.mlp {
import flash.display.*;
public class FriendshipThermometer extends Thermometer {
private const HONESTY_COLOR:uint = 52045;
private const LAUGHTER_COLOR:uint = 16733219;
private const FLUID_COLORS:Array;
private const KINDNESS_COLOR:uint = 9117849;
private const GENEROSITY_COLOR:uint = 11949041;
private const LOYALTY_COLOR:uint = 0xDC0067;
private var thermometerType:uint;
public var labels:MovieClip;
public static const LOYALTY_METER:uint = 4;
public static const LAUGHTER_METER:uint = 3;
public static const HONESTY_METER:uint = 2;
public static const KINDNESS_METER:uint = 0;
public static const GENEROSITY_METER:uint = 1;
public function FriendshipThermometer(){
FLUID_COLORS = [KINDNESS_COLOR, GENEROSITY_COLOR, HONESTY_COLOR, LAUGHTER_COLOR, LOYALTY_COLOR];
super();
}
public function set flavor(newFlavor:uint):void{
thermometerType = newFlavor;
labels.gotoAndStop((thermometerType + 1));
fluid.gotoAndStop((thermometerType + 1));
}
}
}//package com.kid360.mlp
Section 12
//InfoArea (com.kid360.mlp.InfoArea)
package com.kid360.mlp {
import flash.display.*;
import flash.events.*;
import com.kid360.events.*;
import flash.text.*;
import com.kid360.mlp.ui.*;
public class InfoArea extends MovieClip {
public var parkBtn:MovieClip;
public var sparkles:MovieClip;
public var burbsBtn:MovieClip;
public var environmentIndicator:MovieClip;
public var acresBtn:MovieClip;
public var generosityThermo:FriendshipThermometer;
public var helpBtn:MovieClip;
public var kindnessThermo:FriendshipThermometer;
public var loyaltyThermo:FriendshipThermometer;
public var townBtn:MovieClip;
public var cutiemarkCheatBtn:MovieClip;
public var avatarName:TextField;
public var cheatBtn:MovieClip;
public var sparkCheatBtn:MovieClip;
public var honestyThermo:FriendshipThermometer;
public var audioBtn:MovieClip;
public var totalScore:TextField;
public var cameo:MovieClip;
public var laughterThermo:FriendshipThermometer;
public var editBtn:MovieClip;
public static const TOGGLE_AUDIO:String = "toggleAudio";
public static const TOGGLE_HELP:String = "toggleHelp";
public function InfoArea(){
super();
addFrameScript(0, frame1);
cheatBtn.visible = (cheatBtn.mouseEnabled = (sparkCheatBtn.visible = (sparkCheatBtn.mouseEnabled = (cutiemarkCheatBtn.visible = (cutiemarkCheatBtn.mouseEnabled = (MLPConstants.CHEAT_ACTIVE == 1))))));
parkBtn.visible = false;
editBtn.buttonMode = (helpBtn.buttonMode = (audioBtn.buttonMode = true));
audioBtn.mouseChildren = false;
kindnessThermo.flavor = FriendshipThermometer.KINDNESS_METER;
generosityThermo.flavor = FriendshipThermometer.GENEROSITY_METER;
honestyThermo.flavor = FriendshipThermometer.HONESTY_METER;
laughterThermo.flavor = FriendshipThermometer.LAUGHTER_METER;
loyaltyThermo.flavor = FriendshipThermometer.LOYALTY_METER;
kindnessThermo.value = (generosityThermo.value = (honestyThermo.value = (laughterThermo.value = (loyaltyThermo.value = 0))));
addEventListener(MouseEvent.CLICK, onClick);
}
public function get canTeleport():Boolean{
if (MLPPlayer.instance.ponyLoc == MLPConstants.INVALID_LOC){
return (false);
};
if ((parent as MLPGame).curModule == "ponycreator.swf"){
return (false);
};
if ((parent as MLPGame).curModule == "MetaOutro.swf"){
return (false);
};
if ((parent as MLPGame).confirming){
return (false);
};
return (true);
}
public function get laughterPercent():uint{
return (laughterThermo.value);
}
public function set environment(newBG:int):void{
var btns:Array;
var locs:Array;
var i:int;
btns = [acresBtn, townBtn, burbsBtn, parkBtn];
locs = [509.5, 565, 620];
if (newBG > (locs.length - 1)){
return;
};
trace("putting the lilheart to", locs[newBG], "for bg", newBG);
environmentIndicator.x = locs[newBG];
i = 0;
while (i < locs.length) {
btns[i].glowing = (btns[i].indicating = (i == newBG));
i++;
};
}
public function get loyaltyPercent():uint{
return (loyaltyThermo.value);
}
public function get generosityPercent():uint{
return (generosityThermo.value);
}
public function set loyaltyPercent(newPercent:uint):void{
if (loyaltyThermo.value != newPercent){
sparkles.play();
};
loyaltyThermo.value = newPercent;
}
public function set generosityPercent(newPercent:uint):void{
if (generosityThermo.value != newPercent){
sparkles.play();
};
generosityThermo.value = newPercent;
}
public function setScore(playerStats:Object):void{
score = playerStats.totalScore;
kindnessPercent = playerStats.sparks[MLPConstants.KINDNESS_SPARKS];
generosityPercent = playerStats.sparks[MLPConstants.GENEROSITY_SPARKS];
honestyPercent = playerStats.sparks[MLPConstants.HONESTY_SPARKS];
laughterPercent = playerStats.sparks[MLPConstants.LAUGHTER_SPARKS];
loyaltyPercent = playerStats.sparks[MLPConstants.LOYALTY_SPARKS];
}
public function get honestyPercent():uint{
return (honestyThermo.value);
}
public function set ponyName(newName:String):void{
avatarName.text = newName.toLowerCase();
}
public function set laughterPercent(newPercent:uint):void{
if (laughterThermo.value != newPercent){
sparkles.play();
};
laughterThermo.value = newPercent;
}
function frame1(){
acresBtn.gotoAndStop(1);
townBtn.gotoAndStop(2);
burbsBtn.gotoAndStop(3);
parkBtn.gotoAndStop(4);
}
public function set score(newScore:uint):void{
totalScore.text = String(Math.max(0, newScore));
}
public function get score():uint{
return ((totalScore.text as uint));
}
public function showSparkles():void{
if (sparkles.currentFrame == 1){
sparkles.play();
};
}
public function updateHead(category:int, variant:int, flavor:int):void{
switch (category){
case MLPConstants.EYE_CATEGORY:
cameo.model.eye = {variant:variant, color:flavor};
break;
case MLPConstants.HAIR_CATEGORY:
cameo.model.hair = {variant:variant, color:flavor};
break;
case MLPConstants.HEAD_CATEGORY:
cameo.model.head = {variant:variant, color:flavor};
break;
case MLPConstants.TOPS_CATEGORY:
cameo.model.tops = {variant:variant, color:flavor};
break;
case MLPConstants.BODY_CATEGORY:
cameo.model.body = {variant:variant, color:flavor};
break;
};
}
public function enableNavButtons(flag:Boolean):void{
acresBtn.buttonMode = (townBtn.buttonMode = (burbsBtn.buttonMode = (parkBtn.buttonMode = (editBtn.buttonMode = flag))));
}
public function set kindnessPercent(newPercent:uint):void{
if (kindnessThermo.value != newPercent){
sparkles.play();
};
kindnessThermo.value = newPercent;
}
public function updateScore(playerStats:Object):void{
score = (score + playerStats.totalScore);
kindnessPercent = (kindnessPercent + playerStats.sparks[MLPConstants.KINDNESS_SPARKS]);
generosityPercent = (generosityPercent + playerStats.sparks[MLPConstants.GENEROSITY_SPARKS]);
honestyPercent = (honestyPercent + playerStats.sparks[MLPConstants.HONESTY_SPARKS]);
laughterPercent = (laughterPercent + playerStats.sparks[MLPConstants.LAUGHTER_SPARKS]);
loyaltyPercent = (loyaltyPercent + playerStats.sparks[MLPConstants.LOYALTY_SPARKS]);
}
public function set head(ponySpec:Object):void{
cameo.model.eye = ponySpec.eye;
cameo.model.hair = ponySpec.hair;
cameo.model.head = ponySpec.head;
cameo.model.tops = ponySpec.tops;
cameo.model.body = ponySpec.body;
}
public function set honestyPercent(newPercent:uint):void{
if (honestyThermo.value != newPercent){
sparkles.play();
};
honestyThermo.value = newPercent;
}
public function get kindnessPercent():uint{
return (kindnessThermo.value);
}
private function requestTeleport(panoramaNum:uint):void{
if (!canTeleport){
return;
};
dispatchEvent(new UsefulEvent({name:MLPConstants.TELEPORT_PONY, payload:{loc:panoramaNum}}));
}
private function onClick(e:MouseEvent):void{
trace("infoarea gets click from", e.target);
switch (e.target){
case acresBtn:
case townBtn:
case burbsBtn:
case parkBtn:
requestTeleport([acresBtn, townBtn, burbsBtn, parkBtn].indexOf(e.target));
break;
case helpBtn:
dispatchEvent(new UsefulEvent({name:TOGGLE_HELP, payload:null}));
break;
case editBtn:
requestTeleport(MLPConstants.AVATAR_EDITOR);
break;
case audioBtn:
trace("someone hit the speaker");
dispatchEvent(new UsefulEvent({name:TOGGLE_AUDIO, payload:null}));
break;
case cheatBtn:
if (MLPConstants.CHEAT_ACTIVE == 1){
dispatchEvent(new UsefulEvent({name:MLPConstants.UPDATE_SCORE, payload:{points:299, sparks:[0, 0, 0, 0, 0]}}));
} else {
trace("won't dispatch from cheatbtn");
};
break;
case sparkCheatBtn:
if (MLPConstants.CHEAT_ACTIVE == 1){
dispatchEvent(new UsefulEvent({name:MLPConstants.UPDATE_SCORE, payload:{points:0, sparks:[99, 99, 99, 99, 99]}}));
} else {
trace("won't dispatch from spcheatbtn");
};
break;
};
}
}
}//package com.kid360.mlp
Section 13
//MLPConstants (com.kid360.mlp.MLPConstants)
package com.kid360.mlp {
public class MLPConstants {
public static const BODY_CATEGORY:int = 6;
public static const STAGE_WIDTH:Number = 750;
public static const APPLE_INTRO:int = 1;
public static const TAIL_CATEGORY:int = 2;
public static const PANO_MAX_X:int = 0;
public static const KINDNESS_SPARKS:uint = 0;
public static const CHEAT_ACTIVE:int = 0;
public static const AVATAR_EDITOR:uint = 8;
public static const PARK_PANO_WIDTH:uint = 1709;
public static const NUM_MANE_CHOICES:uint = 9;
public static const YELLOW_BODY_COLOR:uint = 16777062;
public static const RED_CHIP_COLOR:uint = 16737945;
public static const NUM_TAIL_CHOICES:uint = 9;
public static const BODY_THRESHOLDS:Array = [0, 1, 2];
public static const HARVEST_LOC:int = 0;
public static const COLOR_NAMES:Array = ["white", "red", "yellow", "green", "blue", "purple"];
public static const CLOUD_BUMP:uint = 6;
public static const NUM_NECK_CHOICES:uint = 10;
public static const DOWNTOWN:uint = 1;
public static const SCROLL_SPEED:int = 6;
public static const FARM:uint = 0;
public static const LAUGH_PACK:uint = 5;
public static const MINIGAME_ABORTED:String = "minigameAborted";
public static const YELLOW_CHIP_COLOR:uint = 16777062;
public static const ENCOUNTER_DONE:String = "encounterDone";
public static const MINIGAME_DONE:String = "minigameDone";
public static const GREEN_BODY_COLOR:uint = 0x66FF00;
public static const STRINGS_FILENAME:String = "strings.xml";
public static const GENEROSITY_SPARKS:uint = 1;
public static const FARM_PANO_WIDTH:uint = 1165;
public static const PART_THRESHOLDS:Array = [EYE_THRESHOLDS, MANE_THRESHOLDS, TAIL_THRESHOLDS, HAT_THRESHOLDS, NECK_THRESHOLDS, BACK_THRESHOLDS, BODY_THRESHOLDS];
public static const BURBS_PANO_WIDTH:uint = 1475;
public static const NUM_EYE_CHOICES:uint = 9;
public static const APPLE_HARVEST:uint = 4;
public static const LAUGHTER_SPARKS:uint = 3;
public static const NECK_THRESHOLDS:Array = [0, 0, 0, 0, 1500, 3300, 5100, 6900, 8700, 10500];
public static const RARITY_MOB:uint = 5;
public static const AVATAR_CHANGE:String = "avatarChange";
public static const TOPS_CATEGORY:int = 4;
public static const PINKIE_PIE_MOB:uint = 3;
public static const FLUTTERSHY_MOB:uint = 2;
public static const SWEETS_LOC:int = 1;
public static const TOWN_PANO_WIDTH:uint = 1332;
public static const RAINBOW_DASH_MOB:uint = 4;
public static const BLUE_BODY_COLOR:uint = 10944509;
public static const EYE_CATEGORY:int = 0;
public static const CREATOR_LOC:int = 2;
public static const LOYALTY_SPARKS:uint = 4;
public static const NUM_BODY_CHOICES:uint = 3;
public static const MISH_MASH:uint = 7;
public static const EYE_THRESHOLDS:Array = [0, 0, 0, 300, 2100, 3900, 5700, 7500, 9300];
public static const LOCATION_CHANGE:String = "locationChange";
public static const GREEN_CHIP_COLOR:uint = 10017853;
public static const MINIGAME_SCORE:String = "minigameScore";
public static const PANO_MIN_X:int = -4931;
public static const UPDATE_SCORE:String = "updateScore";
public static const PONY_CHANGE:String = "ponyChange";
public static const WHITE_CHIP_COLOR:uint = 0xFFFFFF;
public static const MELODY_DONE:String = "melodyDone";
public static const HEAD_CATEGORY:int = 3;
public static const GENERIC_MOB:uint = 0;
public static const META_INTRO:int = 0;
public static const BLUE_CHIP_COLOR:uint = 5354482;
public static const SWEETS_INTRO:int = 2;
public static const MUSIC_INTRO:int = 4;
public static const TELEPORT_PONY:String = "teleportPony";
public static const CLOUD_INTRO:int = 3;
public static const STAGE_HEIGHT:Number = 500;
public static const WESTWARD:int = -1;
public static const BODY_COLORS:Array = [0, RED_BODY_COLOR, YELLOW_BODY_COLOR, GREEN_BODY_COLOR, BLUE_BODY_COLOR, PURPLE_BODY_COLOR];
public static const NUM_BACK_CHOICES:uint = 10;
public static const NUM_HAT_CHOICES:uint = 10;
public static const TAIL_THRESHOLDS:Array = [0, 0, 0, 900, 2700, 4500, 6300, 8100, 9900];
public static const INVALID_LOC:int = -1;
public static const APPLEJACK_MOB:uint = 1;
public static const HAIR_CATEGORY:int = 1;
public static const NUM_COLOR_CHOICES:uint = 6;
public static const HONESTY_SPARKS:uint = 2;
public static const BACK_THRESHOLDS:Array = [0, 0, 0, 0, 1800, 3600, 5400, 7200, 9000, 10800];
public static const PURPLE_BODY_COLOR:uint = 0xFF00FF;
public static const MISHMASH_LOC:int = 4;
public static const SUBURBS:uint = 2;
public static const BOTTOMS_CATEGORY:int = 5;
public static const HAT_THRESHOLDS:Array = [0, 0, 0, 0, 1200, 3000, 4800, 6600, 8400, 10200];
public static const PANO_LOCS:Array = [-240, -1690, -2770, -4080, -4860];
public static const MANE_THRESHOLDS:Array = [0, 0, 0, 600, 2400, 4200, 6000, 7800, 9600];
public static const PARK:uint = 3;
public static const TWILIGHT_SPARKLE_MOB:uint = 6;
public static const PURPLE_CHIP_COLOR:uint = 6961263;
public static const CLOUD_LOC:int = 3;
public static const EASTWARD:int = 1;
public static const RED_BODY_COLOR:uint = 16737945;
public function MLPConstants(){
super();
}
public static function defaultAvatar():Object{
return (new AvatarSpec());
}
public static function partCategoryName(categoryIndex:uint):String{
var names:Array;
names = ["eyes", "mane", "tails", "headwear", "neckwear", "saddles"];
return (names[categoryIndex]);
}
public static function partsAvailable(oldPoints:uint, newPoints:uint):Array{
var maxValidIndex:Function;
var newParts:Array;
var i:int;
var vals:Array;
var lastUnlocked:uint;
var nowUnlocked:uint;
var numUnlocked:int;
var newOnes:Array;
var j:int;
var oldPoints = oldPoints;
var newPoints = newPoints;
maxValidIndex = function (a:Array, score:uint):uint{
var lastIndex:int;
var i:int;
lastIndex = (a.length - 1);
if (score >= a[lastIndex]){
return (lastIndex);
};
i = 0;
while (i < a.length) {
if (a[i] > score){
return ((i - 1));
};
i++;
};
return (0);
};
newParts = [];
i = 0;
while (i < (PART_THRESHOLDS.length - 1)) {
vals = PART_THRESHOLDS[i];
lastUnlocked = maxValidIndex(vals, oldPoints);
nowUnlocked = maxValidIndex(vals, newPoints);
if (nowUnlocked > lastUnlocked){
numUnlocked = (nowUnlocked - lastUnlocked);
newOnes = [];
j = 0;
while (j < numUnlocked) {
newOnes.push(((lastUnlocked + j) + 1));
j = (j + 1);
};
newParts.push({category:i, items:newOnes});
};
i = (i + 1);
};
return (newParts);
}
}
}//package com.kid360.mlp
Section 14
//MLPGame (com.kid360.mlp.MLPGame)
package com.kid360.mlp {
import flash.display.*;
import flash.events.*;
import com.hubworld.game.api.*;
import flash.utils.*;
import com.kid360.events.*;
import flash.text.*;
import com.kid360.mlp.ponyville.*;
import flash.net.*;
import flash.media.*;
public class MLPGame extends MovieClip {
private const ACHIEVE_UNLOCK_ACTION:String = "GAME_A_MLPHUB_PONYASSET";
private const ACHIEVE_LAUGHPACK_ACTION:String = "GAME_A_MLPHUB_PINKIECOMPLETE";
private const ACHIEVE_CLOUDBUMP_ACTION:String = "GAME_A_MLPHUB_DASHCOMPLETE";
private const ACHIEVE_LAUGHPACK_SCORE_ACTION:String = "GAME_A_MLPHUB_PINKIECORE";
private const ACHIEVE_APPLEHARVEST_ACTION:String = "GAME_A_MLPHUB_APPLEJACKCOMPLETE";
private const ACHIEVE_PEGASUS_ACTION:String = "GAME_A_MLPHUB_PEGASUS";
private const ACHIEVE_DILEMMA_ACTION:String = "GAME_A_MLPHUB_DILEMMACOMPLETE";
private const ACHIEVE_MISHMASH_ACTION:String = "GAME_A_MLPHUB_FLUTTERSHYCOMPLETE";
private const ACHIEVE_CUTIEMARK_ACTION:String = "GAME_A_MLPHUB_CUTIEMARK";
private const ACHIEVE_CLOUDBUMP_SCORE_ACTION:String = "GAME_A_MLPHUB_DASHSCORE";
private const ACHIEVE_APPLEHARVEST_SCORE_ACTION:String = "GAME_A_MLPHUB_APPLEJACKSCORE";
private const ACHIEVE_UNICORN_ACTION:String = "GAME_A_MLPHUB_UNICORN";
private const REPORT_SCORE_ACTION:String = "GAME_A_MLPHUB_GAMESCORE";
private const ACHIEVE_MISHMASH_SCORE_ACTION:String = "GAME_A_MLPHUB_FLUTTERSHYSCORE";
public var infoArea:InfoArea;
public var intro:MovieClip;
private var theScore:uint;// = 0
private var hgapi:HubGameApi;
public var player:MLPPlayer;
public var assetsURL:String;
public var languageTag:String;// = "en_US"
private var skinDataURL:String;
public var canUnlock:uint;// = 0
private var requestedDest:int;// = -1
public var preemptionAllowed:Boolean;// = false
private var moduleLoader:Loader;
public var hofBackdrop:MovieClip;
public var inHubWorld:Boolean;// = false
private var myPath:String;// = ""
private static const GAME_VERSION:String = "0.5";
public function MLPGame(){
inHubWorld = false;
canUnlock = 0;
languageTag = "en_US";
preemptionAllowed = false;
myPath = "";
theScore = 0;
requestedDest = -1;
super();
addFrameScript(1, frame2, 2, frame3, 3, frame4);
stop();
player = MLPPlayer.instance;
player.game = this;
moduleLoader = new Loader();
addChildAt(moduleLoader, 0);
moduleLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadingError, false, 0, true);
addEventListener(Event.ADDED_TO_STAGE, onAddedtoStage);
}
public function checkForProfanity(s:String):void{
if (inHubWorld){
hgapi.checkForProfanity(s, "PonyName");
} else {
textIsAcceptible(true);
};
}
private function editAvatar():void{
abortModuleMusic();
gotoAndStop("creator");
moduleLoader.load(new URLRequest((assetsURL + "ponycreator.swf")));
moduleLoader.contentLoaderInfo.addEventListener(Event.INIT, onEditorReady, false, 0, true);
}
private function preemptBegin(id:uint):void{
trace("preempt begin, maybe show an ad");
(moduleLoader.content as MovieClip).halt();
if (inHubWorld){
hgapi.reportPreemptionPoint(id, HubGameApi.PREEMPT_SHORT);
} else {
preemptEnd(id);
};
}
public function get gaming():Boolean{
switch (curModule){
case "AppleHarvest.swf":
case "LaughPack.swf":
case "CloudBump.swf":
case "MishMash.swf":
return (true);
};
return (false);
}
function frame2(){
stop();
}
public function updateInfoArea(stateObj:Object=null):void{
var stateObj = stateObj;
if (stateObj == null){
stateObj = player.stats;
};
var _local3 = infoArea;
with (_local3) {
head = player.stats.avatar;
ponyName = stateObj.avatar.name;
kindnessPercent = stateObj.sparks[0];
generosityPercent = stateObj.sparks[1];
honestyPercent = stateObj.sparks[2];
laughterPercent = stateObj.sparks[3];
loyaltyPercent = stateObj.sparks[4];
score = stateObj.totalScore;
visible = true;
};
}
function frame4(){
updateInfoArea(player.stats);
}
function frame3(){
}
private function showHallOfFame():void{
gotoAndStop("creator");
moduleLoader.load(new URLRequest((assetsURL + "ponycreator.swf")));
}
private function preemptEnd(id:uint):void{
trace("preempt end");
preemptionAllowed = false;
displayAchievements();
}
private function onPanoramaReady(e:Event):void{
var firstEntry:Boolean;
firstEntry = (player.ponyLoc == MLPConstants.INVALID_LOC);
e.target.removeEventListener(Event.INIT, onPanoramaReady);
if (firstEntry){
player.ponyLoc = MLPConstants.CREATOR_LOC;
saveGameState();
};
(e.target.loader.content as MovieClip).panoramaLoc = MLPConstants.PANO_LOCS[player.ponyLoc];
infoArea.enableNavButtons(true);
infoArea.environment = player.ponyLoc;
if (preemptionAllowed){
preemptBegin(0);
} else {
displayAchievements(firstEntry);
};
}
private function gameDone():void{
saveGameState();
}
public function get score():uint{
var result:uint;
result = 0;
if (((inHubWorld) && (false))){
result = (hgapi.decryptValue("totalScore") as uint);
} else {
result = theScore;
};
return (result);
}
public function saveGameState():void{
var ba:ByteArray;
if (!inHubWorld){
return;
};
ba = new ByteArray();
ba.writeObject(player.stats);
hgapi.saveGameState(ba);
}
public function get curModule():String{
var modulePath:String;
modulePath = moduleLoader.contentLoaderInfo.url;
if (modulePath == null){
return ("mlp.swf");
};
return (modulePath.substring((modulePath.lastIndexOf("/") + 1)));
}
private function restoreGameState(ba:ByteArray):void{
var stateAtLaunch:Object;
if (ba.length){
ba.position = 0;
stateAtLaunch = ba.readObject();
player.stats = stateAtLaunch;
};
}
private function onEditorReady(e:Event):void{
e.target.removeEventListener(Event.INIT, onEditorReady);
e.target.loader.content.editor.specs = player.avatar;
e.target.loader.content.editor.languageTag = languageTag;
infoArea.setScore({totalScore:player.stats.totalScore, sparks:player.stats.sparks});
}
private function toggleAudio():void{
SoundMixer.soundTransform = new SoundTransform((SoundMixer.soundTransform.volume) ? 0 : 1);
}
private function initAPI():void{
hgapi = new HubGameApi();
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_START_API_COMPLETE, onAPIInit);
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_ERROR, onAPIInit);
hgapi.startApi(GAME_VERSION, this.root, HubGameApi.RUNMODE_LOCAL);
}
public function awardCutieMark():void{
abortModuleMusic();
infoArea.enableNavButtons(false);
gotoAndStop("cutiemark");
moduleLoader.load(new URLRequest((assetsURL + "MetaOutro.swf")));
}
private function displayAchievements(isFirstEntry:Boolean=false):void{
if (isFirstEntry){
showHelp(true, {type:"notice", context:"ponyville", status:{}});
} else {
if (player.hasWon){
trace("you have won your cutiemark");
awardCutieMark();
} else {
if (canUnlock){
showHelp(true, {type:"notice", context:"unlock", status:{}, points:canUnlock});
canUnlock = 0;
} else {
(moduleLoader.content as MovieClip).resume();
};
};
};
}
public function stringsDidLoad():void{
gotoAndStop("intro");
moduleLoader.load(new URLRequest((assetsURL + "MetaIntro.swf")));
}
public function get confirming():Boolean{
if (gaming){
return ((moduleLoader.content as MovieClip).confirming);
};
return (false);
}
public function set score(newScore:uint):void{
if (((inHubWorld) && (false))){
hgapi.encryptValue("totalScore", newScore);
} else {
theScore = newScore;
};
}
private function onCastmemberMessage(e:UsefulEvent):void{
var eventName:String;
var payload:Object;
var achievementObj:Object;
var nextLoc:int;
var e = e;
eventName = e.data.name;
payload = e.data.payload;
switch (eventName){
case "gameStart":
if (inHubWorld){
hgapi.reportStart();
};
break;
case "introDone":
if (player.ponyLoc == MLPConstants.INVALID_LOC){
trace("letscreate");
editAvatar();
} else {
enterPonyville(player.ponyLoc);
};
break;
case "cutieMarkAwarded":
trace("now you have your mark", payload.chosenMark, "put you in hall o' fame");
var _local3 = player;
with (_local3) {
avatar.mark = payload.chosenMark;
avatar.markingTime = new Date().getTime();
appendMarkedPony(avatar);
};
if (inHubWorld){
achievementObj = {actionName:ACHIEVE_CUTIEMARK_ACTION, value:true};
hgapi.reportAchievement(achievementObj);
};
showHallOfFame();
break;
case MLPConstants.LOCATION_CHANGE:
trace("moving player to", panoName(payload.loc));
player.ponyLoc = payload.loc;
infoArea.environment = payload.loc;
break;
case MLPConstants.PONY_CHANGE:
infoArea.updateHead(payload.category, payload.variant, payload.color);
break;
case MLPConstants.AVATAR_CHANGE:
player.avatar = payload;
moduleLoader.unload();
if (player.ponyLoc == MLPConstants.INVALID_LOC){
player.avatar.creationTime = new Date().getTime();
};
saveGameState();
enterPonyville(player.ponyLoc);
break;
case MLPConstants.TELEPORT_PONY:
showHelp(false);
switch (curModule){
case "AppleHarvest.swf":
case "LaughPack.swf":
case "CloudBump.swf":
case "MishMash.swf":
requestedDest = payload.loc;
(moduleLoader.content as MovieClip).confirmExit();
return;
};
switch (payload.loc){
case MLPConstants.FARM:
case MLPConstants.DOWNTOWN:
case MLPConstants.SUBURBS:
case MLPConstants.PARK:
trace("must teleport to", payload.loc);
enterPanorama(payload.loc);
break;
case MLPConstants.AVATAR_EDITOR:
trace("teleporting to editor from", curModule);
editAvatar();
break;
case MLPConstants.APPLE_HARVEST:
case MLPConstants.LAUGH_PACK:
case MLPConstants.CLOUD_BUMP:
case MLPConstants.MISH_MASH:
trace("must load game", payload.loc);
loadMiniGame(payload.loc);
break;
default:
trace("you can't get there from here");
break;
};
break;
case InfoArea.TOGGLE_HELP:
showHelp(!(helpShowing));
break;
case InfoArea.TOGGLE_AUDIO:
toggleAudio();
break;
case MLPConstants.ENCOUNTER_DONE:
if (ChanceEncounter.isDilemma(payload.index)){
if (inHubWorld){
achievementObj = {actionName:ACHIEVE_DILEMMA_ACTION, value:true};
hgapi.reportAchievement(achievementObj);
};
};
updateScore(payload);
if (player.hasWon){
trace("thou winnest! let's get your cutie mark and put you in the HoF");
awardCutieMark();
} else {
if (canUnlock){
trace("unlocker points", (player.stats.totalScore - 1));
showHelp(true, {type:"notice", context:"unlock", status:{}, points:canUnlock});
canUnlock = 0;
};
};
break;
case MLPConstants.UPDATE_SCORE:
updateScore(payload);
break;
case MLPConstants.MINIGAME_SCORE:
reportMinigameRound(payload.points);
break;
case MLPConstants.MINIGAME_DONE:
preemptionAllowed = true;
enterPonyville(player.ponyLoc);
break;
case MLPConstants.MINIGAME_ABORTED:
nextLoc = ((requestedDest == MLPConstants.INVALID_LOC)) ? player.ponyLoc : requestedDest;
enterPanorama(nextLoc);
break;
default:
break;
};
}
private function panoName(panoramaIndex:uint):String{
return (["Acres", "Town", "Burbs", "Park"][panoramaIndex]);
}
private function initGame():void{
skinDataURL = "";
StringsManager.loadText((assetsURL + MLPConstants.STRINGS_FILENAME), this, stringsDidLoad);
}
public function get helpShowing():Boolean{
return ((getChildAt((numChildren - 1)) is Popup));
}
private function updateScore(scoreInfo:Object):void{
var collapseCategories:Function;
var mergeArrays:Function;
var curStats:Object;
var priorPoints:uint;
var newParts:Array;
var scoreObj:Object;
var scoreInfo = scoreInfo;
collapseCategories = function (a:Array):void{
var i:int;
var category:int;
var j:int;
var k:int;
i = 0;
while (i < a.length) {
category = a[i].category;
j = (i + 1);
while (j < a.length) {
if (a[j].category == category){
k = 0;
while (k < a[j].items.length) {
a[i].items.push(a[j].items[k]);
k++;
};
a.splice(j, 1);
};
j++;
};
i++;
};
};
mergeArrays = function (a1:Array, a2:Array):Array{
var merged:Array;
var i:int;
merged = a1.concat();
i = 0;
while (i < a2.length) {
if (merged.indexOf(a2[i]) == -1){
merged.push(a2[i]);
};
i++;
};
collapseCategories(merged);
return (merged);
};
curStats = player.stats;
priorPoints = curStats.totalScore;
if (((inHubWorld) && ((scoreInfo.points > 0)))){
scoreObj = {actionName:REPORT_SCORE_ACTION, value:(priorPoints + scoreInfo.points)};
hgapi.reportScore(scoreObj);
};
trace("player had", priorPoints, "points");
curStats.totalScore = (curStats.totalScore + scoreInfo.points);
newParts = MLPConstants.partsAvailable(priorPoints, curStats.totalScore);
if (newParts.length > 0){
canUnlock = (canUnlock + newParts.length);
curStats.unpreviewed = mergeArrays(curStats.unpreviewed, newParts);
};
trace("player has", curStats.totalScore, "points after adding", scoreInfo.points, "sparks", scoreInfo.sparks);
curStats.sparks[MLPConstants.KINDNESS_SPARKS] = (curStats.sparks[MLPConstants.KINDNESS_SPARKS] + scoreInfo.sparks[MLPConstants.KINDNESS_SPARKS]);
curStats.sparks[MLPConstants.GENEROSITY_SPARKS] = (curStats.sparks[MLPConstants.GENEROSITY_SPARKS] + scoreInfo.sparks[MLPConstants.GENEROSITY_SPARKS]);
curStats.sparks[MLPConstants.HONESTY_SPARKS] = (curStats.sparks[MLPConstants.HONESTY_SPARKS] + scoreInfo.sparks[MLPConstants.HONESTY_SPARKS]);
curStats.sparks[MLPConstants.LAUGHTER_SPARKS] = (curStats.sparks[MLPConstants.LAUGHTER_SPARKS] + scoreInfo.sparks[MLPConstants.LAUGHTER_SPARKS]);
curStats.sparks[MLPConstants.LOYALTY_SPARKS] = (curStats.sparks[MLPConstants.LOYALTY_SPARKS] + scoreInfo.sparks[MLPConstants.LOYALTY_SPARKS]);
player.stats = curStats;
saveGameState();
infoArea.setScore(curStats);
}
private function diddleHOFBG():void{
setChildIndex(hofBackdrop, 0);
if (!player.avatar.isMarked){
hofBackdrop.visible = false;
};
}
private function onAPIInit(e:HGAEvent):void{
hgapi.removeEventListener(HGAEvent.HGA_RESPONSE_START_API_COMPLETE, onAPIInit);
hgapi.removeEventListener(HGAEvent.HGA_RESPONSE_ERROR, onAPIInit);
if (e.result.status == HGAStatus.HGA_STATUS_READY){
player.playerName = e.result.userHandle;
assetsURL = e.result.gameConfig.gameAssetPath;
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_GET_GAME_STATE, onHGAEvent);
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_GET_START_OK, onHGAEvent);
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_REPORT_PREEMPTION_POINT, onHGAEvent);
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_REPORT_FINISH, onHGAEvent);
hgapi.addEventListener(HGAEvent.HGA_RESPONSE_CHECK_FOR_PROFANITY, onHGAEvent);
inHubWorld = true;
StringsManager.loadText((assetsURL + MLPConstants.STRINGS_FILENAME), this, loadGameState);
} else {
showHelp(true, {type:"error", context:"apiStartError", status:{}});
dbug("HubWorld Game API Version Error");
};
}
private function enterPanorama(panoramaIndex:uint):void{
if (curModule == "ponyville.swf"){
if (panoramaIndex != player.ponyLoc){
trace("gotta move the bg to", panoName(panoramaIndex));
player.ponyLoc = panoramaIndex;
infoArea.environment = panoramaIndex;
(moduleLoader.content as MovieClip).panoramaLoc = MLPConstants.PANO_LOCS[panoramaIndex];
} else {
trace("nothing to do, nowhere to go");
};
} else {
player.ponyLoc = panoramaIndex;
abortModuleMusic();
enterPonyville(player.ponyLoc);
};
}
private function reportMinigameRound(gameScore:int):void{
var codes:Object;
var i:int;
var achievementObj:Object;
codes = {AppleHarvest.swf:[ACHIEVE_APPLEHARVEST_ACTION, ACHIEVE_APPLEHARVEST_SCORE_ACTION], LaughPack.swf:[ACHIEVE_LAUGHPACK_ACTION, ACHIEVE_LAUGHPACK_SCORE_ACTION], CloudBump.swf:[ACHIEVE_CLOUDBUMP_ACTION, ACHIEVE_CLOUDBUMP_SCORE_ACTION], MishMash.swf:[ACHIEVE_MISHMASH_ACTION, ACHIEVE_MISHMASH_SCORE_ACTION]};
achievementObj = {actionName:"", value:true};
if (inHubWorld){
i = 0;
while (i < 2) {
achievementObj.actionName = codes[curModule][i];
if (i == 1){
achievementObj.value = gameScore;
};
hgapi.reportAchievement(achievementObj);
i++;
};
};
}
private function onHGAEvent(e:HGAEvent):void{
switch (e.type){
case HGAEvent.HGA_RESPONSE_GET_GAME_STATE:
restoreGameState(e.result.gameStateBA);
hgapi.getStartOk();
break;
case HGAEvent.HGA_RESPONSE_GET_START_OK:
if (e.result.startOk){
initGame();
} else {
showHelp(true, {type:"error", context:"startOKError", status:{}});
};
break;
case HGAEvent.HGA_RESPONSE_REPORT_PREEMPTION_POINT:
preemptEnd(e.result.preemptionIdNum);
break;
case HGAEvent.HGA_RESPONSE_CHECK_FOR_PROFANITY:
textIsAcceptible(e.result.approved);
break;
default:
dbug("rcvd HGAEvt", e.type);
break;
};
}
private function loadGameState():void{
hgapi.getGameState();
}
public function dbug(... _args):void{
var s:String;
s = _args.join(" ");
if (hasOwnProperty("readout")){
TextField(this["readout"]).appendText((s + " \n"));
};
trace(s);
}
private function enterPonyville(panoramaNum:int):void{
trace("entering ponyville at", panoramaNum, "curmodule", moduleLoader.content);
requestedDest = -1;
gotoAndStop("ponyville");
moduleLoader.load(new URLRequest((assetsURL + "ponyville.swf")));
moduleLoader.contentLoaderInfo.addEventListener(Event.INIT, onPanoramaReady, false, 0, true);
}
private function onLoadingError(e:IOErrorEvent):void{
throw (new Error(e.text));
}
private function abortModuleMusic():void{
if (moduleLoader.content.hasOwnProperty("stopMusic")){
(moduleLoader.content as MovieClip).stopMusic();
};
}
private function onAddedtoStage(e:Event):void{
var theStats:Object;
removeEventListener(Event.ADDED_TO_STAGE, onAddedtoStage);
if (parent == stage){
myPath = "./";
assetsURL = (myPath + "assets/");
theStats = player.stats;
theStats.intros = [true, true, true, true, true];
player.stats = theStats;
initGame();
} else {
initAPI();
};
stage.stageFocusRect = false;
addEventListener(UsefulEvent.USEFUL_EVENT, onCastmemberMessage);
}
private function showHelp(flag:Boolean, config:Object=null):void{
var popupConfig:Object;
var currentModule:MovieClip;
var _local7:DisplayObject;
var win:DisplayObject;
var achievementObj:Object;
trace("showHelp, curmod", curModule.slice(0, -4));
popupConfig = (config) ? config : {type:"help", context:curModule.slice(0, -4), status:{}};
popupConfig.language = languageTag;
currentModule = (moduleLoader.content as MovieClip);
if (((flag) && (!(helpShowing)))){
switch (curModule){
case "mlp.swf":
if (popupConfig.type == "error"){
switch (popupConfig.context){
case "apiStartError":
case "startOKError":
_local7 = addChild(new Popup(popupConfig));
_local7.x = 150;
_local7.y = 125;
break;
};
};
break;
case "ponycreator.swf":
break;
case "ponyville.swf":
currentModule.halt();
break;
case "LaughPack.swf":
case "CloudBump.swf":
case "MishMash.swf":
case "AppleHarvest.swf":
trace("telling gamecontainer to halt");
currentModule.halt();
break;
default:
trace("not ready yet");
break;
};
if (Popup.helpMessages.hasOwnProperty(popupConfig.context)){
win = addChild(new Popup(popupConfig));
win.x = 150;
win.y = 125;
} else {
trace("no help available for", popupConfig.context);
};
if (popupConfig.context == "unlock"){
if (inHubWorld){
achievementObj = {actionName:ACHIEVE_UNLOCK_ACTION, value:popupConfig.points};
hgapi.reportAchievement(achievementObj);
};
};
} else {
if (helpShowing){
removeChild(getChildAt((numChildren - 1)));
switch (curModule){
case "ponycreator.swf":
break;
case "ponyville.swf":
case "LaughPack.swf":
case "CloudBump.swf":
case "MishMash.swf":
case "AppleHarvest.swf":
currentModule.resume();
break;
default:
trace("not ready yet");
break;
};
};
};
}
public function get appPath():String{
return (myPath);
}
private function loadMiniGame(gameNum:uint):void{
var gameSWFs:Array;
(moduleLoader.content as MovieClip).stopMusic();
gameSWFs = ["AppleHarvest.swf", "LaughPack.swf", "CloudBump.swf", "MishMash.swf"];
moduleLoader.load(new URLRequest((assetsURL + gameSWFs[(gameNum - MLPConstants.APPLE_HARVEST)])));
}
private function textIsAcceptible(isClean:Boolean):void{
var currentModule:MovieClip;
currentModule = (moduleLoader.content as MovieClip);
currentModule.editor.stringIsClean(isClean);
}
}
}//package com.kid360.mlp
Section 15
//MLPPlayer (com.kid360.mlp.MLPPlayer)
package com.kid360.mlp {
import flash.display.*;
import flash.events.*;
public class MLPPlayer extends EventDispatcher {
public var playerName:String;// = "Guest"
private var dilemmas:Array;
private var unpreviewedParts:Array;
private var playerPoints:uint;// = 0
private var friendshipSparks:Array;
private var owner:MovieClip;
private var avatarSpec:Object;
private var curPanorama:int;// = -1
private var introViews:Array;
private var markedPonies:Array;
public static const instance:MLPPlayer = new MLPPlayer(SingletonLock);
;
public function MLPPlayer(lock:Class){
playerName = "Guest";
introViews = [true, true, true, true, true];
unpreviewedParts = [];
markedPonies = [];
dilemmas = [false, false, false, false, false, false, false, false, false, false, false];
curPanorama = -1;
friendshipSparks = [0, 0, 0, 0, 0];
playerPoints = 0;
super();
if (lock != SingletonLock){
throw (new Error("Invalid access. Use MLPPlayer.instance."));
};
avatarSpec = new AvatarSpec();
}
public function appendMarkedPony(ponySpec:Object):void{
markedPonies.push(ponySpec);
}
public function get hasWon():Boolean{
var percent:Number;
for each (percent in friendshipSparks) {
if (percent < 100){
return (false);
};
};
return (true);
}
public function get stats():Object{
var statsObj:Object;
statsObj = {ponyLoc:curPanorama, sparks:friendshipSparks, totalScore:(game) ? game.score : playerPoints, avatar:avatarSpec, dilemmas:dilemmas, markedPonies:markedPonies, unpreviewed:unpreviewedParts, intros:introViews};
return (statsObj);
}
public function set ponyLoc(newLoc:int):void{
curPanorama = newLoc;
}
public function set avatar(newAvatar:Object):void{
avatarSpec = newAvatar;
}
public function hasSeenIntro(introNum:int):void{
introViews[introNum] = true;
}
public function set stats(newStats:Object):void{
curPanorama = newStats.ponyLoc;
friendshipSparks = newStats.sparks;
if (game){
game.score = newStats.totalScore;
} else {
playerPoints = newStats.totalScore;
};
avatarSpec = newStats.avatar;
dilemmas = newStats.dilemmas;
markedPonies = newStats.markedPonies;
unpreviewedParts = newStats.unpreviewed;
introViews = newStats.intros;
}
public function dilemmaAvailable(dilemmaIndex:uint):Boolean{
return ((dilemmas[dilemmaIndex] == false));
}
public function reset():void{
curPanorama = MLPConstants.INVALID_LOC;
friendshipSparks = [0, 0, 0, 0, 0];
dilemmas = [false, false, false, false, false, false, false, false, false, false, false];
unpreviewedParts = [];
avatarSpec = new AvatarSpec();
game.infoArea.ponyName = avatarSpec.name;
game.infoArea.head = avatarSpec;
game.infoArea.setScore({totalScore:(game) ? game.score : playerPoints, sparks:[0, 0, 0, 0, 0]});
game.saveGameState();
}
public function get ponyLoc():int{
return (curPanorama);
}
public function maySkipIntro(introNum:int):Boolean{
return (introViews[introNum]);
}
public function get avatar():Object{
return (avatarSpec);
}
public function set unpreviewed(newItems:Array):void{
unpreviewedParts = newItems;
}
public function set game(newOwner:MovieClip):void{
owner = newOwner;
}
public function get unpreviewed():Array{
return (unpreviewedParts);
}
public function get game():MovieClip{
return (owner);
}
public function rememberDilemma(dilemmaIndex:uint):void{
dilemmas[dilemmaIndex] = true;
}
}
}//package com.kid360.mlp
class SingletonLock {
private function SingletonLock(){
super();
}
}
Section 16
//Popup (com.kid360.mlp.Popup)
package com.kid360.mlp {
import flash.display.*;
import flash.events.*;
import com.kid360.events.*;
import flash.text.*;
public class Popup extends MovieClip {
public var helpFaces:MovieClip;
public var helpBkgdFaces:MovieClip;
public var backdrop:MovieClip;
public var controlPanel:MovieClip;
public var body:TextField;
public var header:TextField;
public var cameo:MovieClip;
public var editorBtn:MovieClip;
public static const helpMessages:Object = {spawn:"", ponyville:"", ponycreator:"", AppleHarvest:"", LaughPack:"", CloudBump:"", MishMash:"", unlock:"", apiStartError:"", startOKError:"", newbody:"You’ve earned _nummarks_ Cutie Marks, and have unlocked the _bodytype_ body! Visit the Pony Creator to try it out!"};
public function Popup(popupConfig:Object){
super();
addFrameScript(0, frame1);
backdrop.gotoAndStop(((popupConfig.type == "error")) ? 2 : 1);
cameo.visible = (editorBtn.visible = (popupConfig.context == "unlock"));
updateHead(MLPPlayer.instance.stats.avatar);
header.text = ((popupConfig.type == "help")) ? "" : "";
if (popupConfig.type == "error"){
controlPanel.visible = false;
helpFaces.stop();
helpBkgdFaces.stop();
if (popupConfig.context == "apiStartError"){
header.text = "Oops!";
body.text = "Can’t load game";
} else {
header.text = StringsManager.getString(popupConfig.context, "header", popupConfig.language);
body.text = StringsManager.getString(popupConfig.context, "body", popupConfig.language);
};
} else {
if (helpMessages.hasOwnProperty(popupConfig.context)){
switch (popupConfig.context){
case "ponycreator":
helpFaces.gotoAndStop(2);
helpBkgdFaces.gotoAndStop(2);
break;
case "ponyville":
helpFaces.gotoAndStop(3);
helpBkgdFaces.gotoAndStop(3);
break;
case "AppleHarvest":
helpFaces.gotoAndStop(4);
helpBkgdFaces.gotoAndStop(4);
break;
case "LaughPack":
helpFaces.gotoAndStop(5);
helpBkgdFaces.gotoAndStop(5);
break;
case "CloudBump":
helpFaces.gotoAndStop(6);
helpBkgdFaces.gotoAndStop(6);
break;
case "MishMash":
helpFaces.gotoAndStop(7);
helpBkgdFaces.gotoAndStop(7);
break;
case "unlock":
header.text = StringsManager.getString("unlock", "header", popupConfig.language);
if (popupConfig.points > 1){
body.text = StringsManager.getString("unlock", "multiple", popupConfig.language);
} else {
body.text = StringsManager.getString("unlock", "single", popupConfig.language);
};
body.text = body.text.replace(/-numitems-/, String(popupConfig.points));
helpFaces.gotoAndStop(8);
helpBkgdFaces.gotoAndStop(8);
break;
default:
body.text = StringsManager.getString(popupConfig.context, "body", popupConfig.language);
break;
};
} else {
trace("no help available for", popupConfig.context);
};
};
addEventListener(MouseEvent.CLICK, onClick);
}
private function updateHead(ponySpec:Object):void{
cameo.model.eye = ponySpec.eye;
cameo.model.hair = ponySpec.hair;
cameo.model.head = ponySpec.head;
cameo.model.tops = ponySpec.tops;
cameo.model.body = ponySpec.body;
}
function frame1(){
body.wordWrap = true;
body.autoSize = "left";
stop();
}
function onClick(e:MouseEvent):void{
if (e.target == editorBtn){
dispatchEvent(new UsefulEvent({name:MLPConstants.TELEPORT_PONY, payload:{loc:MLPConstants.AVATAR_EDITOR}}));
};
}
}
}//package com.kid360.mlp
Section 17
//Thermometer (com.kid360.mlp.Thermometer)
package com.kid360.mlp {
import flash.display.*;
public class Thermometer extends MovieClip {
public var fluid:MovieClip;
public function Thermometer(){
super();
}
public function get value():uint{
return ((fluid.scaleX * 100));
}
public function set value(newValue:uint):void{
fluid.scaleX = (Math.max(0, Math.min(100, Math.round(newValue))) / 100);
}
}
}//package com.kid360.mlp
Section 18
//Utils (com.kid360.Utils)
package com.kid360 {
import flash.geom.*;
import flash.display.*;
public class Utils {
public function Utils(){
super();
}
public static function shuffleArray(anArray:Array):Array{
return (randomSubset(anArray.concat(), anArray.length));
}
public static function traceObject(obj:Object, depth:int=0, numTabs:int=0, asElement:Boolean=false){
var whiteSpace:String;
var i:int;
var m:String;
if (asElement){
trace("<traceObject>");
};
whiteSpace = "";
i = 0;
while (i < numTabs) {
whiteSpace = (whiteSpace + "\t");
i++;
};
trace((whiteSpace + obj));
for (m in obj) {
trace((((((whiteSpace + m) + ":") + obj[m]) + ":") + typeof(obj[m])));
if ((((depth > 0)) && ((((typeof(obj[m]) == "movieclip")) || ((typeof(obj[m]) == "object")))))){
traceObject(obj[m], (depth - 1), (numTabs + 1), true);
};
};
if (asElement){
trace("</traceObject>");
};
}
public static function randomSubset(anArray:Array, howMany:int):Array{
var results:Array;
var i:int;
var anIndex:Number;
results = [];
i = 0;
while (i < howMany) {
anIndex = randInRange(0, (anArray.length - 1));
results.push(anArray.splice(anIndex, 1)[0]);
i++;
};
return (results);
}
public static function anyIndex(anArray:Array):int{
return (randInRange(0, (anArray.length - 1)));
}
public static function float2decimal(n:Number, numPlaces:uint):Number{
var magicFactor:Number;
var result:Number;
magicFactor = Math.pow(10, Math.abs(numPlaces));
result = (Math.round((n * magicFactor)) / magicFactor);
return (result);
}
public static function arrayPopulation(a:Array):uint{
var i:uint;
var num:uint;
num = 0;
i = 0;
while (i < a.length) {
if (a[i]){
num++;
};
i++;
};
return (num);
}
public static function nearestMultiple(curVal:Number, unitSize:uint):int{
var numUnits:Number;
numUnits = Math.round((curVal / unitSize));
return ((numUnits * unitSize));
}
public static function nearestPoint(curPoint:Point, unitSize:uint):Point{
var nearest:Point;
nearest = new Point();
nearest.x = nearestMultiple(curPoint.x, unitSize);
nearest.y = nearestMultiple(curPoint.y, unitSize);
return (nearest);
}
public static function randInRange(minVal:Number, maxVal:Number):Number{
return ((minVal + Math.floor((Math.random() * ((maxVal + 1) - minVal)))));
}
public static function nearestLegalPoint(actual:Point, bounds:Rectangle):Point{
var nearest:Point;
var center:Point;
var slope:Number;
var nearEdge:String;
if (bounds.containsPoint(actual)){
return (actual);
};
nearest = new Point();
center = new Point((bounds.x + (bounds.width / 2)), (bounds.y + (bounds.height / 2)));
slope = (-((actual.y - center.y)) / (actual.x - center.x));
if (slope == Number.POSITIVE_INFINITY){
nearest.x = center.x;
nearest.y = bounds.top;
} else {
if (slope == Number.NEGATIVE_INFINITY){
nearest.x = center.x;
nearest.y = bounds.bottom;
} else {
nearEdge = Utils.nearestEdge(actual, bounds);
switch (nearEdge){
case "topRight":
nearest.x = bounds.right;
nearest.y = bounds.top;
case "right":
nearest.x = bounds.right;
nearest.y = (center.y + ((bounds.width / 2) * -(slope)));
break;
case "bottomRight":
nearest.x = bounds.right;
nearest.y = bounds.bottom;
case "bottom":
nearest.x = (center.x + (((bounds.height / 2) * -1) / slope));
nearest.y = bounds.bottom;
break;
case "bottomLeft":
nearest.x = bounds.left;
nearest.y = bounds.bottom;
case "left":
nearest.x = bounds.left;
nearest.y = (center.y + ((bounds.width / 2) * slope));
break;
case "topLeft":
nearest.x = bounds.left;
nearest.y = bounds.top;
case "top":
nearest.x = (center.x + (((bounds.height / 2) * 1) / slope));
nearest.y = bounds.top;
break;
};
};
};
return (nearest);
}
public static function randPtInRect(r:Rectangle):Point{
return (new Point(randInRange(r.left, r.right), randInRange(r.top, r.bottom)));
}
public static function tintObject(o:DisplayObject, rgbColor:uint):void{
var ct:ColorTransform;
ct = new ColorTransform();
ct.color = rgbColor;
o.transform.colorTransform = ct;
}
public static function nearestEdge(pt:Point, r:Rectangle):String{
var ctr:Point;
var slope:Number;
var aspect:Number;
var nearEdge:String;
ctr = new Point((r.x + (r.width / 2)), (r.y + (r.height / 2)));
slope = (-((pt.y - ctr.y)) / (pt.x - ctr.x));
aspect = (r.height / r.width);
nearEdge = "";
if (pt.x > ctr.x){
nearEdge = "right";
if (pt.y < ctr.y){
if (slope == aspect){
nearEdge = "topRight";
} else {
if (slope > aspect){
nearEdge = "top";
} else {
nearEdge = "right";
};
};
} else {
if (pt.y > ctr.y){
if (slope == -(aspect)){
nearEdge = "bottomRight";
} else {
if (slope < -(aspect)){
nearEdge = "bottom";
} else {
nearEdge = "right";
};
};
};
};
} else {
if (pt.x < ctr.x){
nearEdge = "left";
if (pt.y < ctr.y){
if (slope == -(aspect)){
nearEdge = "topLeft";
} else {
if (slope < -(aspect)){
nearEdge = "top";
} else {
nearEdge = "left";
};
};
} else {
if (pt.y > ctr.y){
if (slope == aspect){
nearEdge = "bottomLeft";
} else {
if (slope > aspect){
nearEdge = "bottom";
} else {
nearEdge = "left";
};
};
};
};
};
};
return (nearEdge);
}
public static function firstEmptyIndex(a:Array):int{
var i:int;
i = 0;
while (i < a.length) {
if (!a[i]){
return (i);
};
i++;
};
return (-1);
}
}
}//package com.kid360
Section 19
//Color (fl.motion.Color)
package fl.motion {
import flash.geom.*;
import flash.display.*;
public class Color extends ColorTransform {
private var _tintMultiplier:Number;// = 0
private var _tintColor:Number;// = 0
public function Color(redMultiplier:Number=1, greenMultiplier:Number=1, blueMultiplier:Number=1, alphaMultiplier:Number=1, redOffset:Number=0, greenOffset:Number=0, blueOffset:Number=0, alphaOffset:Number=0){
_tintColor = 0;
_tintMultiplier = 0;
super(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset);
}
public function setTint(tintColor:uint, tintMultiplier:Number):void{
var r:uint;
var g:uint;
var b:uint;
this._tintColor = tintColor;
this._tintMultiplier = tintMultiplier;
this.redMultiplier = (this.greenMultiplier = (this.blueMultiplier = (1 - tintMultiplier)));
r = ((tintColor >> 16) & 0xFF);
g = ((tintColor >> 8) & 0xFF);
b = (tintColor & 0xFF);
this.redOffset = Math.round((r * tintMultiplier));
this.greenOffset = Math.round((g * tintMultiplier));
this.blueOffset = Math.round((b * tintMultiplier));
}
public function set tintColor(value:uint):void{
this.setTint(value, this.tintMultiplier);
}
public function get brightness():Number{
return ((this.redOffset) ? (1 - this.redMultiplier) : (this.redMultiplier - 1));
}
private function deriveTintColor():uint{
var ratio:Number;
var r:uint;
var g:uint;
var b:uint;
var colorNum:uint;
ratio = (1 / this.tintMultiplier);
r = Math.round((this.redOffset * ratio));
g = Math.round((this.greenOffset * ratio));
b = Math.round((this.blueOffset * ratio));
colorNum = (((r << 16) | (g << 8)) | b);
return (colorNum);
}
public function get tintMultiplier():Number{
return (this._tintMultiplier);
}
public function get tintColor():uint{
return (this._tintColor);
}
public function set brightness(value:Number):void{
var percent:Number;
var offset:Number;
if (value > 1){
value = 1;
} else {
if (value < -1){
value = -1;
};
};
percent = (1 - Math.abs(value));
offset = 0;
if (value > 0){
offset = (value * 0xFF);
};
this.redMultiplier = (this.greenMultiplier = (this.blueMultiplier = percent));
this.redOffset = (this.greenOffset = (this.blueOffset = offset));
}
public function set tintMultiplier(value:Number):void{
this.setTint(this.tintColor, value);
}
private function parseXML(xml:XML=null):Color{
var firstChild:XML;
var att:XML;
var name:String;
var tintColorNumber:uint;
if (!xml){
return (this);
};
firstChild = xml.elements()[0];
if (!firstChild){
return (this);
};
for each (att in firstChild.attributes()) {
name = att.localName();
if (name == "tintColor"){
tintColorNumber = (Number(att.toString()) as uint);
this.tintColor = tintColorNumber;
} else {
this[name] = Number(att.toString());
};
};
return (this);
}
public static function interpolateColor(fromColor:uint, toColor:uint, progress:Number):uint{
var q:Number;
var fromA:uint;
var fromR:uint;
var fromG:uint;
var fromB:uint;
var toA:uint;
var toR:uint;
var toG:uint;
var toB:uint;
var resultA:uint;
var resultR:uint;
var resultG:uint;
var resultB:uint;
var resultColor:uint;
q = (1 - progress);
fromA = ((fromColor >> 24) & 0xFF);
fromR = ((fromColor >> 16) & 0xFF);
fromG = ((fromColor >> 8) & 0xFF);
fromB = (fromColor & 0xFF);
toA = ((toColor >> 24) & 0xFF);
toR = ((toColor >> 16) & 0xFF);
toG = ((toColor >> 8) & 0xFF);
toB = (toColor & 0xFF);
resultA = ((fromA * q) + (toA * progress));
resultR = ((fromR * q) + (toR * progress));
resultG = ((fromG * q) + (toG * progress));
resultB = ((fromB * q) + (toB * progress));
resultColor = ((((resultA << 24) | (resultR << 16)) | (resultG << 8)) | resultB);
return (resultColor);
}
public static function interpolateTransform(fromColor:ColorTransform, toColor:ColorTransform, progress:Number):ColorTransform{
var q:Number;
var resultColor:ColorTransform;
q = (1 - progress);
resultColor = new ColorTransform(((fromColor.redMultiplier * q) + (toColor.redMultiplier * progress)), ((fromColor.greenMultiplier * q) + (toColor.greenMultiplier * progress)), ((fromColor.blueMultiplier * q) + (toColor.blueMultiplier * progress)), ((fromColor.alphaMultiplier * q) + (toColor.alphaMultiplier * progress)), ((fromColor.redOffset * q) + (toColor.redOffset * progress)), ((fromColor.greenOffset * q) + (toColor.greenOffset * progress)), ((fromColor.blueOffset * q) + (toColor.blueOffset * progress)), ((fromColor.alphaOffset * q) + (toColor.alphaOffset * progress)));
return (resultColor);
}
public static function fromXML(xml:XML):Color{
return (Color(new (Color).parseXML(xml)));
}
}
}//package fl.motion
Section 20
//audioBtn_21 (mlp_fla.audioBtn_21)
package mlp_fla {
import flash.display.*;
import flash.events.*;
public dynamic class audioBtn_21 extends MovieClip {
public var isOn:Boolean;
public var faces:MovieClip;
public function audioBtn_21(){
super();
addFrameScript(0, frame1);
}
public function onRolledOver(e:MouseEvent):void{
faces.gotoAndStop((isOn) ? "overOn" : "overOff");
}
public function onReleased(e:MouseEvent):void{
if (isOn){
isOn = false;
faces.gotoAndStop("upOff");
} else {
isOn = true;
faces.gotoAndStop("upOn");
};
}
public function onPressed(e:MouseEvent):void{
faces.gotoAndStop((isOn) ? "downOn" : "downOff");
}
function frame1(){
isOn = true;
faces.gotoAndStop("upOn");
addEventListener(MouseEvent.MOUSE_OVER, onRolledOver);
addEventListener(MouseEvent.MOUSE_OUT, onRolledOut);
addEventListener(MouseEvent.MOUSE_DOWN, onPressed);
addEventListener(MouseEvent.MOUSE_UP, onReleased);
}
public function onRolledOut(e:MouseEvent):void{
faces.gotoAndStop((isOn) ? "upOn" : "upOff");
}
}
}//package mlp_fla
Section 21
//cameo_30 (mlp_fla.cameo_30)
package mlp_fla {
import flash.display.*;
import com.kid360.mlp.ponycreator.*;
public dynamic class cameo_30 extends MovieClip {
public var model:PonyModel;
public function cameo_30(){
super();
}
}
}//package mlp_fla
Section 22
//CutieMark_37 (mlp_fla.CutieMark_37)
package mlp_fla {
import flash.display.*;
public dynamic class CutieMark_37 extends MovieClip {
public function CutieMark_37(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mlp_fla
Section 23
//cutiemarkCheatBtn_53 (mlp_fla.cutiemarkCheatBtn_53)
package mlp_fla {
import com.kid360.mlp.*;
import flash.geom.*;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.media.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class cutiemarkCheatBtn_53 extends MovieClip {
public function cutiemarkCheatBtn_53(){
super();
addFrameScript(0, frame1);
}
function frame1(){
addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(e:MouseEvent):void{
if (MLPConstants.CHEAT_ACTIVE == 1){
(parent.parent as MovieClip).awardCutieMark();
};
}
}
}//package mlp_fla
Section 24
//doneBtn_80 (mlp_fla.doneBtn_80)
package mlp_fla {
import flash.display.*;
public dynamic class doneBtn_80 extends MovieClip {
public function doneBtn_80(){
super();
addFrameScript(0, frame1);
}
function frame1(){
mouseChildren = false;
buttonMode = true;
}
}
}//package mlp_fla
Section 25
//editorBtn_54 (mlp_fla.editorBtn_54)
package mlp_fla {
import flash.display.*;
import flash.events.*;
public dynamic class editorBtn_54 extends MovieClip {
public var faces:MovieClip;
public function editorBtn_54(){
super();
addFrameScript(0, frame1);
}
public function onReleased(e:MouseEvent):void{
faces.gotoAndStop("up");
}
public function onPressed(e:MouseEvent):void{
faces.gotoAndStop("down");
}
function frame1(){
mouseChildren = false;
buttonMode = true;
faces.stop();
addEventListener(MouseEvent.MOUSE_OVER, onRolled);
addEventListener(MouseEvent.MOUSE_OUT, onRolledOut);
addEventListener(MouseEvent.MOUSE_DOWN, onPressed);
addEventListener(MouseEvent.MOUSE_UP, onReleased);
}
public function onRolled(e:MouseEvent):void{
faces.gotoAndStop("over");
}
public function onRolledOut(e:MouseEvent):void{
faces.gotoAndStop("up");
}
}
}//package mlp_fla
Section 26
//helpBkgdFaces_59 (mlp_fla.helpBkgdFaces_59)
package mlp_fla {
import flash.display.*;
public dynamic class helpBkgdFaces_59 extends MovieClip {
public function helpBkgdFaces_59(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package mlp_fla
Section 27
//helpBtn_5 (mlp_fla.helpBtn_5)
package mlp_fla {
import flash.display.*;
import flash.events.*;
public dynamic class helpBtn_5 extends MovieClip {
public var faces:MovieClip;
public function helpBtn_5(){
super();
addFrameScript(0, frame1);
}
public function onReleased(e:MouseEvent):void{
faces.gotoAndStop("up");
}
public function onPressed(e:MouseEvent):void{
faces.gotoAndStop("down");
}
function frame1(){
mouseChildren = false;
buttonMode = true;
faces.stop();
addEventListener(MouseEvent.MOUSE_OVER, onRolled);
addEventListener(MouseEvent.MOUSE_OUT, onRolledOut);
addEventListener(MouseEvent.MOUSE_DOWN, onPressed);
addEventListener(MouseEvent.MOUSE_UP, onReleased);
}
public function onRolled(e:MouseEvent):void{
faces.gotoAndStop("over");
}
public function onRolledOut(e:MouseEvent):void{
faces.gotoAndStop("up");
}
}
}//package mlp_fla
Section 28
//helpFaces_63 (mlp_fla.helpFaces_63)
package mlp_fla {
import flash.geom.*;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.media.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class helpFaces_63 extends MovieClip {
public var moment:TextField;
public var header:TextField;
public var subheader:TextField;
public var step1:TextField;
public var step2:TextField;
public var step4:TextField;
public var step3:TextField;
public function helpFaces_63(){
super();
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8);
}
public function updateStrings1():void{
header.text = StringsManager.getString("ponycreatorHelp", "header", (parent.parent as MovieClip).languageTag);
subheader.text = StringsManager.getString("ponycreatorHelp", "subheader", (parent.parent as MovieClip).languageTag);
step1.text = StringsManager.getString("ponycreatorHelp", "step1", (parent.parent as MovieClip).languageTag);
step2.text = StringsManager.getString("ponycreatorHelp", "step2", (parent.parent as MovieClip).languageTag);
step3.text = StringsManager.getString("ponycreatorHelp", "step3", (parent.parent as MovieClip).languageTag);
}
public function updateStrings5():void{
header.text = StringsManager.getString("CloudBumpHelp", "header", (parent.parent as MovieClip).languageTag);
subheader.text = StringsManager.getString("CloudBumpHelp", "subheader", (parent.parent as MovieClip).languageTag);
step1.text = StringsManager.getString("CloudBumpHelp", "step1", (parent.parent as MovieClip).languageTag);
step2.text = StringsManager.getString("CloudBumpHelp", "step2", (parent.parent as MovieClip).languageTag);
step3.text = StringsManager.getString("CloudBumpHelp", "step3", (parent.parent as MovieClip).languageTag);
moment.text = StringsManager.getString("CloudBumpHelp", "moment", (parent.parent as MovieClip).languageTag);
}
function frame3(){
step3.wordWrap = true;
step3.autoSize = "left";
StringsManager.loadText("strings.xml", this, stringsDidLoad2);
}
function frame6(){
moment.wordWrap = true;
moment.autoSize = "left";
StringsManager.loadText("strings.xml", this, stringsDidLoad5);
}
function frame7(){
step3.wordWrap = true;
step3.autoSize = "left";
StringsManager.loadText("strings.xml", this, stringsDidLoad6);
}
function frame1(){
stop();
}
public function stringsDidLoad3():void{
updateStrings3();
}
public function stringsDidLoad4():void{
updateStrings4();
}
public function stringsDidLoad1():void{
updateStrings1();
}
public function stringsDidLoad2():void{
updateStrings2();
}
function frame5(){
StringsManager.loadText("strings.xml", this, stringsDidLoad4);
}
function frame4(){
StringsManager.loadText("strings.xml", this, stringsDidLoad3);
}
function frame8(){
}
function frame2(){
StringsManager.loadText("strings.xml", this, stringsDidLoad1);
}
public function stringsDidLoad5():void{
updateStrings5();
}
public function stringsDidLoad6():void{
updateStrings6();
}
public function updateStrings2():void{
header.text = StringsManager.getString("ponyvilleHelp", "header", (parent.parent as MovieClip).languageTag);
subheader.text = StringsManager.getString("ponyvilleHelp", "subheader", (parent.parent as MovieClip).languageTag);
step1.text = StringsManager.getString("ponyvilleHelp", "step1", (parent.parent as MovieClip).languageTag);
step2.text = StringsManager.getString("ponyvilleHelp", "step2", (parent.parent as MovieClip).languageTag);
step3.text = StringsManager.getString("ponyvilleHelp", "step3", (parent.parent as MovieClip).languageTag);
moment.text = StringsManager.getString("ponyvilleHelp", "moment", (parent.parent as MovieClip).languageTag);
}
public function updateStrings3():void{
header.text = StringsManager.getString("AppleHarvestHelp", "header", (parent.parent as MovieClip).languageTag);
subheader.text = StringsManager.getString("AppleHarvestHelp", "subheader", (parent.parent as MovieClip).languageTag);
step1.text = StringsManager.getString("AppleHarvestHelp", "step1", (parent.parent as MovieClip).languageTag);
step2.text = StringsManager.getString("AppleHarvestHelp", "step2", (parent.parent as MovieClip).languageTag);
step3.text = StringsManager.getString("AppleHarvestHelp", "step3", (parent.parent as MovieClip).languageTag);
step4.text = StringsManager.getString("AppleHarvestHelp", "step4", (parent.parent as MovieClip).languageTag);
moment.text = StringsManager.getString("AppleHarvestHelp", "moment", (parent.parent as MovieClip).languageTag);
}
public function updateStrings4():void{
header.text = StringsManager.getString("LaughPackHelp", "header", (parent.parent as MovieClip).languageTag);
subheader.text = StringsManager.getString("LaughPackHelp", "subheader", (parent.parent as MovieClip).languageTag);
step1.text = StringsManager.getString("LaughPackHelp", "step1", (parent.parent as MovieClip).languageTag);
step2.text = StringsManager.getString("LaughPackHelp", "step2", (parent.parent as MovieClip).languageTag);
step3.text = StringsManager.getString("LaughPackHelp", "step3", (parent.parent as MovieClip).languageTag);
step4.text = StringsManager.getString("LaughPackHelp", "step4", (parent.parent as MovieClip).languageTag);
moment.text = StringsManager.getString("LaughPackHelp", "moment", (parent.parent as MovieClip).languageTag);
}
public function updateStrings6():void{
header.text = StringsManager.getString("MishMashHelp", "header", (parent.parent as MovieClip).languageTag);
subheader.text = StringsManager.getString("MishMashHelp", "subheader", (parent.parent as MovieClip).languageTag);
step1.text = StringsManager.getString("MishMashHelp", "step1", (parent.parent as MovieClip).languageTag);
step2.text = StringsManager.getString("MishMashHelp", "step2", (parent.parent as MovieClip).languageTag);
step3.text = StringsManager.getString("MishMashHelp", "step3", (parent.parent as MovieClip).languageTag);
step4.text = StringsManager.getString("MishMashHelp", "step4", (parent.parent as MovieClip).languageTag);
moment.text = StringsManager.getString("MishMashHelp", "moment", (parent.parent as MovieClip).languageTag);
}
}
}//package mlp_fla
Section 29
//Manes_41 (mlp_fla.Manes_41)
package mlp_fla {
import flash.display.*;
public dynamic class Manes_41 extends MovieClip {
public var patch:MovieClip;
public var ear:MovieClip;
public var horn:MovieClip;
public function Manes_41(){
super();
}
}
}//package mlp_fla
Section 30
//Mouth_36 (mlp_fla.Mouth_36)
package mlp_fla {
import flash.display.*;
public dynamic class Mouth_36 extends MovieClip {
public function Mouth_36(){
super();
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package mlp_fla
Section 31
//popupControlPanel_79 (mlp_fla.popupControlPanel_79)
package mlp_fla {
import com.kid360.mlp.*;
import flash.display.*;
import flash.events.*;
import com.kid360.events.*;
public dynamic class popupControlPanel_79 extends MovieClip {
public var doneBtn:MovieClip;
public function popupControlPanel_79(){
super();
addFrameScript(0, frame1);
}
function frame1(){
addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(e:MouseEvent):void{
switch (e.target){
case doneBtn:
dispatchEvent(new UsefulEvent({name:InfoArea.TOGGLE_HELP, payload:null}));
break;
};
}
}
}//package mlp_fla
Section 32
//sparkles_11 (mlp_fla.sparkles_11)
package mlp_fla {
import flash.display.*;
public dynamic class sparkles_11 extends MovieClip {
public function sparkles_11(){
super();
addFrameScript(0, frame1, 48, frame49);
}
function frame1(){
stop();
}
function frame49(){
gotoAndStop(1);
}
}
}//package mlp_fla
Section 33
//Area1Btn (Area1Btn)
package {
import com.kid360.mlp.ui.*;
public dynamic class Area1Btn extends NavButton {
public function Area1Btn(){
super();
}
}
}//package
Section 34
//Area2Btn (Area2Btn)
package {
import com.kid360.mlp.ui.*;
public dynamic class Area2Btn extends NavButton {
public function Area2Btn(){
super();
}
}
}//package
Section 35
//Area3Btn (Area3Btn)
package {
import com.kid360.mlp.ui.*;
public dynamic class Area3Btn extends NavButton {
public function Area3Btn(){
super();
}
}
}//package
Section 36
//Area4Btn (Area4Btn)
package {
import com.kid360.mlp.ui.*;
public dynamic class Area4Btn extends NavButton {
public function Area4Btn(){
super();
}
}
}//package
Section 37
//StringsManager (StringsManager)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class StringsManager extends EventDispatcher {
public static const CANONICAL_SUBTAG_SEPARATOR:String = "_";
public static const DEFAULT_LANGUAGE_TAG:String = ((DEFAULT_LANGUAGE + CANONICAL_SUBTAG_SEPARATOR) + DEFAULT_REGION);
public static const DEFAULT_REGION:String = "US";
public static const DEFAULT_LANGUAGE:String = "en";
private static var textloader:URLLoader;
private static var callback:Function;
private static var owner:DisplayObject;
public static var i18n:XML;
public function StringsManager(){
super();
}
public static function getString(screenID:String, blockID:String, languageTag:String=""):String{
if (languageTag == ""){
languageTag = StringsManager.DEFAULT_LANGUAGE_TAG;
};
return (StringsManager.findBestString(screenID, blockID, StringsManager.canonicalize(languageTag)));
}
private static function canonicalize(s:String):String{
return (s.replace(/_/g, CANONICAL_SUBTAG_SEPARATOR));
}
private static function doCallback():void{
if (((!((StringsManager.owner == null))) && (!((StringsManager.callback == null))))){
var _local2 = StringsManager.owner;
with (_local2) {
StringsManager.callback();
};
};
}
private static function findBestString(screenID:String, blockID:String, languageTag:String):String{
var translations:XMLList;
var s:String;
var separatorPos:int;
var regionTag:String;
var t:XML;
var screenID = screenID;
var blockID = blockID;
var languageTag = languageTag;
translations = i18n.screen.(@id == screenID).block.(@id == blockID).text;
s = translations.(@lang == languageTag);
if (s == ""){
separatorPos = languageTag.indexOf(CANONICAL_SUBTAG_SEPARATOR);
if (separatorPos > 1){
regionTag = languageTag.substr(-((separatorPos + 1)));
languageTag = languageTag.substring(0, separatorPos);
s = translations.(@lang == languageTag);
if (s == ""){
for each (t in translations) {
if (t.@lang.indexOf(languageTag) == 0){
s = t;
};
};
};
};
};
if (s == ""){
languageTag = DEFAULT_LANGUAGE_TAG;
s = translations.(@lang == languageTag);
};
if (s == ""){
languageTag = "en";
s = translations.(@lang == languageTag);
};
if (s == ""){
s = "???";
};
return (s);
}
private static function onTextLoaded(e:Event):void{
StringsManager.i18n = new XML(StringsManager.canonicalize(e.target.data));
doCallback();
}
public static function loadText(itsFile:String, owner:DisplayObject=null, callback:Function=null):void{
StringsManager.owner = owner;
StringsManager.callback = callback;
if (StringsManager.i18n){
doCallback();
} else {
StringsManager.textloader = new URLLoader(new URLRequest(itsFile));
StringsManager.textloader.addEventListener(Event.COMPLETE, StringsManager.onTextLoaded, false, 0, true);
};
}
}
}//package