Section 1
//KongregateEvent (com.kongregate.as3.client.events.KongregateEvent)
package com.kongregate.as3.client.events {
import flash.events.*;
public class KongregateEvent extends Event {
public static const COMPLETE:String = "component_api_available";
public function KongregateEvent(_arg1:String){
super(_arg1);
}
}
}//package com.kongregate.as3.client.events
Section 2
//AbstractShadowService (com.kongregate.as3.client.services.AbstractShadowService)
package com.kongregate.as3.client.services {
import flash.events.*;
public class AbstractShadowService extends EventDispatcher {
protected function alert(_arg1:String, _arg2:String, _arg3="", _arg4:String=""):void{
trace(((((((("Kongregate API: " + _arg1) + ".") + _arg2) + "(") + _arg3) + ") ") + _arg4));
}
}
}//package com.kongregate.as3.client.services
Section 3
//HighScoreServiceShadow (com.kongregate.as3.client.services.HighScoreServiceShadow)
package com.kongregate.as3.client.services {
public class HighScoreServiceShadow extends AbstractShadowService implements IHighScoreServices {
private var mode:String;
public function HighScoreServiceShadow(){
mode = "";
}
public function submit(_arg1:Number, _arg2:String=null):void{
alert("IHighScoreServices", "submit", arguments);
}
public function connect():Boolean{
alert("IKongregateServices", "connect");
return (true);
}
public function requestList(_arg1:Function):void{
alert("IHighScoreServices", "requestList", "", (("[Mode: " + mode) + "]"));
_arg1({success:false});
}
public function setMode(_arg1:String):void{
alert("IHighScoreServices", "setMode", arguments);
this.mode = _arg1;
}
}
}//package com.kongregate.as3.client.services
Section 4
//IHighScoreServices (com.kongregate.as3.client.services.IHighScoreServices)
package com.kongregate.as3.client.services {
public interface IHighScoreServices {
function setMode(_arg1:String):void;
function submit(_arg1:Number, _arg2:String=null):void;
function requestList(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 5
//IKongregateServices (com.kongregate.as3.client.services.IKongregateServices)
package com.kongregate.as3.client.services {
import flash.events.*;
public interface IKongregateServices extends IEventDispatcher {
function getPlayerInfo(_arg1:Function):void;
function connect(_arg1:Number=-1):Boolean;
}
}//package com.kongregate.as3.client.services
Section 6
//IStatServices (com.kongregate.as3.client.services.IStatServices)
package com.kongregate.as3.client.services {
public interface IStatServices {
function submitArray(_arg1:Array):void;
function submit(_arg1:String, _arg2:Number):void;
}
}//package com.kongregate.as3.client.services
Section 7
//IUserServices (com.kongregate.as3.client.services.IUserServices)
package com.kongregate.as3.client.services {
public interface IUserServices {
function getName():String;
function getPlayerInfo(_arg1:Function):void;
}
}//package com.kongregate.as3.client.services
Section 8
//KongregateServiceShadow (com.kongregate.as3.client.services.KongregateServiceShadow)
package com.kongregate.as3.client.services {
public class KongregateServiceShadow extends AbstractShadowService implements IKongregateServices {
public function getName():String{
alert("IKongregateServices", "getName");
return ("Guest");
}
public function connect(_arg1:Number=-1):Boolean{
alert("IKongregateServices", "connect", arguments);
return (true);
}
public function getPlayerInfo(_arg1:Function):void{
alert("IKongregateServices", "getPlayerInfo");
_arg1(new Object());
}
}
}//package com.kongregate.as3.client.services
Section 9
//StatServiceShadow (com.kongregate.as3.client.services.StatServiceShadow)
package com.kongregate.as3.client.services {
public class StatServiceShadow extends AbstractShadowService implements IStatServices {
public function submitArray(_arg1:Array):void{
alert("IStatServices", "submitArray", arguments);
}
public function submit(_arg1:String, _arg2:Number):void{
alert("IStatServices", "submitStat", arguments);
}
}
}//package com.kongregate.as3.client.services
Section 10
//UserServiceShadow (com.kongregate.as3.client.services.UserServiceShadow)
package com.kongregate.as3.client.services {
public class UserServiceShadow extends AbstractShadowService implements IUserServices {
public function getName():String{
alert("UserService", "getName");
return ("Guest");
}
public function getPlayerInfo(_arg1:Function):void{
alert("UserService", "getPlayerInfo");
_arg1({isGuest:true, name:"Guest", points:0, level:0, isMode:false, isAdmin:false, isDeveloper:false, avatarPath:"", chatAvatarPath:""});
}
}
}//package com.kongregate.as3.client.services
Section 11
//IAPIBootstrap (com.kongregate.as3.client.IAPIBootstrap)
package com.kongregate.as3.client {
import flash.display.*;
import flash.events.*;
public interface IAPIBootstrap {
function init(_arg1:Event=null, _arg2:Stage=null):void;
function hideLog():void;
function showLog(_arg1:int=0):void;
}
}//package com.kongregate.as3.client
Section 12
//KongregateAPI (com.kongregate.as3.client.KongregateAPI)
package com.kongregate.as3.client {
import flash.display.*;
import flash.events.*;
import com.kongregate.as3.client.services.*;
import flash.system.*;
import com.kongregate.as3.client.events.*;
import flash.utils.*;
import flash.net.*;
import flash.errors.*;
public class KongregateAPI extends Sprite {
private const VERSION:Number = 1;
private var loader:Loader;
private var loadedDomain:ApplicationDomain;
private static const CLASS_USER:String = "com.kongregate.as3.client.services.UserServices";
private static const CLASS_STATS:String = "com.kongregate.as3.client.services.StatServices";
private static const CLASS_SERVICES:String = "com.kongregate.as3.client.services.KongregateServices";
private static const CLASS_SCORES:String = "com.kongregate.as3.client.services.HighScoreServices";
private static const DEBUG_API_URL:String = "//Linuxpc/kongregate/public/flash/API_AS3.swf";
private static var _connected:Boolean;
private static var kUser:IUserServices;
private static var _loaded:Boolean;
private static var kServices:IKongregateServices;
private static var kScores:IHighScoreServices;
private static var mInstance:KongregateAPI;
private static var kStats:IStatServices;
private static var kAPI:IAPIBootstrap;
public function KongregateAPI(){
if (mInstance != null){
throw (new Error("Warning: KongregateAPI has been added to stage more than once or accessed improperly. Use getInstance() or a stage reference to access."));
};
mInstance = this;
this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
public function get loaded():Boolean{
return (_loaded);
}
public function get connected():Boolean{
return (_connected);
}
private function alertConnected(_arg1:TimerEvent=null):void{
var _local2:KongregateEvent;
var _local3:Boolean;
_local2 = new KongregateEvent(KongregateEvent.COMPLETE);
_local3 = this.dispatchEvent(_local2);
}
private function init(_arg1:Event):void{
var _local2:Object;
var _local3:String;
var _local4:URLRequest;
var _local5:LoaderContext;
this.removeEventListener(Event.ADDED_TO_STAGE, init);
_loaded = false;
_connected = false;
_local2 = LoaderInfo(root.loaderInfo).parameters;
_local3 = _local2.api_path;
if (_local3 == null){
trace("Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.");
createShadowServices();
return;
};
Security.allowDomain("*.kongregate.com");
Security.allowDomain("kongregatetrunk.com");
_local4 = new URLRequest(_local3);
_local5 = new LoaderContext(false);
_local5.applicationDomain = ApplicationDomain.currentDomain;
_local5.securityDomain = SecurityDomain.currentDomain;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(_local4, _local5);
}
public function get api():IAPIBootstrap{
return (kAPI);
}
private function loadComplete(_arg1:Event):void{
getServices();
}
public function get scores():IHighScoreServices{
return (kScores);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
throw (new IOError(("API file not found. " + _arg1)));
}
public function get services():IKongregateServices{
return (kServices);
}
public function get stats():IStatServices{
return (kStats);
}
private function createShadowServices():void{
var _local1:Timer;
trace(">>> Kongregate Shadow Services instantiated for local development..");
kServices = new KongregateServiceShadow();
kScores = new HighScoreServiceShadow();
kStats = new StatServiceShadow();
kUser = new UserServiceShadow();
_local1 = new Timer(200, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, alertConnected);
_local1.start();
_connected = true;
}
public function get user():IUserServices{
return (kUser);
}
private function getServices():void{
var _local1:ApplicationDomain;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = ApplicationDomain.currentDomain;
kAPI = IAPIBootstrap(loader.getChildAt(0));
this.addChild(loader);
_local2 = _local1.getDefinition(CLASS_SERVICES);
trace(_local2);
kServices = _local2.getInstance();
_local3 = _local1.getDefinition(CLASS_SCORES);
kScores = _local3.getInstance();
_local4 = _local1.getDefinition(CLASS_STATS);
kStats = _local4.getInstance();
_local5 = _local1.getDefinition(CLASS_USER);
kUser = _local5.getInstance();
kServices.connect(VERSION);
_loaded = true;
_connected = true;
alertConnected();
}
public static function getInstance():KongregateAPI{
if (!mInstance){
throw (new IllegalOperationError("You must add the Kongregate API component to the stage before attempting to access it."));
};
return (mInstance);
}
}
}//package com.kongregate.as3.client
Section 13
//LevelData (Data.LevelData)
package Data {
public class LevelData {
public static const ExplodeTest:XML = <level title="TEST">
<script>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="0"/>
</script>
<layers>
<layer color="0x000099" value="1">
<sector/>
<sector type="1"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelD1:XML = <level timeLimit="20" type="1" title="Taking Out the Trash" precursor="Chocolate Coated">
<summary>Candy? How ghastly! Get rid of it!</summary>
<script>
<speech>Well! If you're done hanging around with that rather simple miner, I have an issue that could be handled.</speech>
<speech>My name is Daphne Leigh Kellogg VII, and I simply abhor candy. Ghastly stuff. Rots your teeth. I only eat organic vegetables and distilled water.</speech>
<speech>And now I discover that I have candy orbs infesting my own estate! I need someone with experience to get rid of them so that I can build my new greenhouse.</speech>
<speech>Here's what I want you to do: DESTROY THOSE ORBS AS QUICKLY AS POSSIBLE by hitting their cores. If you run out of time, I will be most incensed.</speech>
<speech>You have twenty seconds. Get rid of that orb!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="5"/>
</script>
<layers>
<layer color="0xff0000" value="5">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xeeff00" value="10">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x00ff00" value="20">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x0000ff" value="40">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelD3:XML = <level timeLimit="20" type="1" title="Introduction to Armor" precursor="Cocoa Foolishness">
<summary>Wait, what? Introduction to WHAT?!</summary>
<script>
<speech>Now, just one moment. What did that level title say? "Introduction to ARMOR?!" Well, this is simply intolerable!</speech>
<speech>Why, it's fundamentally IMPLAUSIBLE! How could a naturally-formed candy orb develop metal plating?! I refuse to believe it.</speech>
<speech>Oh, and it appears the armor is impervious to bullets. How lovely. You have twenty seconds. I simply must go lie down.</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="3"/>
</script>
<layers>
<layer color="0x66ff00" value="10">
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
</layer>
<layer color="0xdddd00" value="8">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x22bb00" value="6">
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
</layer>
<layer color="0x999900" value="8">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelD5:XML = <level timeLimit="10" type="1" title="Necessary Precision" precursor="Use the Force">
<summary>This is just implausible.</summary>
<script>
<speech>Tell me, do you think there's an intelligent being out there just trying to make this job inconvenient?</speech>
<speech>Please, for the sake of my sanity, don't answer that. You have ten seconds.</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="2"/>
</script>
<layers>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="3"/>
<sector type="2"/>
<sector type="2"/>
<sector type="3"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="3"/>
<sector type="2"/>
<sector type="2"/>
<sector type="3"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="3"/>
<sector type="2"/>
<sector type="2"/>
<sector type="3"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="3"/>
<sector type="2"/>
<sector type="2"/>
<sector type="3"/>
<sector type="1"/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="3"/>
<sector type="2"/>
<sector type="2"/>
<sector type="3"/>
</layer>
</layers>
</level>
;
public static const LevelD2:XML = <level timeLimit="20" type="1" title="Cocoa Foolishness" precursor="Taking Out the Trash">
<summary>Chocolate? Honestly! Rubbish.</summary>
<script>
<speech>Oh, my! Oh, goodness! Chocolate? On MY property? I simply won't have it. Get rid of the whole orb; that's right.</speech>
<speech>You have twenty seconds. I can't be kept waiting all day, after all.</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="2"/>
</script>
<layers>
<layer color="0x00ffcc" value="5">
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
</layer>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer color="0x00bb00" value="10">
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
<sector type="1"/>
<sector/>
</layer>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
</layers>
</level>
;
public static const LevelD4:XML = <level timeLimit="5" type="1" title="Use the Force" precursor="Introduction to Armor">
<summary>Let's see if you can think fast!</summary>
<script>
<speech>No time to talk. The guests will be here any minute, and they'll be expecting an absence of candy.</speech>
<speech>You have five seconds. Go.</speech>
<pause length="1"/>
<bullet angle="1"/>
<pause length="0.1"/>
<bullet angle="0"/>
<pause length="2"/>
<bullet angle="0"/>
<pause length="0.1"/>
<bullet angle=".25"/>
<pause length="0.1"/>
<bullet angle=".5"/>
<pause length="0.1"/>
<bullet angle=".75"/>
<pause length="0.1"/>
<bullet angle="1"/>
<pause length="0.1"/>
<bullet angle="1.25"/>
<pause length="0.1"/>
<bullet angle="1.5"/>
<pause length="0.1"/>
<bullet angle="1.75"/>
</script>
<layers>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="2"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="2"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="2"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="2"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer>
<sector color="0xff0000" value="0"/>
</layer>
<layer>
<sector type="1"/>
<sector type="2"/>
<sector type="1"/>
<sector type="1"/>
<sector type="2"/>
<sector type="1"/>
</layer>
</layers>
</level>
;
public static const LevelD6:XML = <level timeLimit="45" type="1" title="A Job Well Done" precursor="Necessary Precision">
<summary>Let's get this over with.</summary>
<script>
<speech>Well, I must say that you haven't been entirely incompetent during our association. You've been quite... satisfactory.</speech>
<speech>I've got just one more task for you to take care of, and our business arrangement will be done.</speech>
<speech>This orb sits in the middle of the land reserved for my greenhouse. Destroy it within forty-five seconds.</speech>
<pause length="1"/>
<speech>...I shall miss you.</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="5"/>
</script>
<layers>
<layer color="0xff00dd" value="2">
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
<sector/>
<sector type="3"/>
</layer>
<layer color="0xff33ff" value="4">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer color="0xff99ff" value="8">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffccff" value="16">
<sector/>
<sector/>
<sector/>
<sector type="1" value="0"/>
<sector/>
<sector/>
<sector/>
<sector type="1" value="0"/>
<sector/>
<sector/>
<sector/>
<sector type="1" value="0"/>
</layer>
<layer color="0xff9900" value="32">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelS2:XML = <level timeLimit="60" type="2" title="Stars and Stripes" precursor="Basic Training">
<summary>If there's one thing the Americans understand, it's WAR!</summary>
<script>
<speech>Good news, maggot! We've managed to acquire some armor from the mighty army of the U.S. of A.! Our orbs are stronger than ever!</speech>
<speech>Of course, the enemy's bullets are also U.S. Army surplus... but we will prevail, soldier!</speech>
<speech>Survive for 60 seconds! And watch your back, recruit! The enemy's likely to try and pull some mean tricks!</speech>
<bullet angle="1.5"/>
<pause length=".75"/>
<bullet angle=".5"/>
<pause length=".75"/>
<bullet angle="0"/>
<pause length=".75"/>
<bullet angle="1"/>
<pause length=".75"/>
<bullet angle="1.5"/>
<bullet angle=".5"/>
<pause length=".75"/>
<bullet angle="1"/>
<bullet angle="0"/>
<pause length=".75"/>
<loop target="3"/>
</script>
<layers>
<layer color="0xff0000" value="5">
<sector type="3"/>
<sector color="0x0000ff"/>
<sector color="0x0000ff"/>
<sector color="0x0000ff"/>
<sector color="0x0000ff"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="3"/>
</layer>
<layer color="0xffffff" value="5">
<sector color="0x0000ff"/>
<sector color="0xffff00" value="10"/>
<sector color="0x0000ff"/>
<sector color="0xffff00" value="10"/>
<sector color="0x0000ff"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xff0000" value="5">
<sector color="0x0000ff"/>
<sector color="0x0000ff"/>
<sector color="0x0000ff"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffffff" value="5">
<sector color="0x0000ff"/>
<sector color="0xffff00" value="10"/>
<sector color="0x0000ff"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xff0000" value="5">
<sector color="0x0000ff"/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM1:XML = <level timeLimit="35" type="0" goal="700" title="Jawbreaker">
<summary>Learn the ropes with this straightforward level!</summary>
<script>
<speech>Well, hello! Hal Lolly here. I'm a candy miner. I'm betting you're wondering where we get the candy you buy in stores.</speech>
<speech>Well, we sure as heck don't cook it in pots! That would be weird. No, candy comes from these colorful suckers here. Candy Orbs!</speech>
<speech>Since you're new around here, I'll show you the ropes. In order to get the candy off of the orb, we need to hit it with high-mass projectiles. Watch!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<speech>See? You'll notice the candy bits all got collected in the upper right of your screen.</speech>
<speech>Your job for this level is to rotate the orb using your mouse and collect at least 700 units of candy in the time provided!</speech>
<speech>Here's a hint: In this orb, the deeper the candy is hidden, the more valuable it is!</speech>
<speech>Just be careful not to hit that red ball at the center too soon. It'll make the whole darn thing explode!</speech>
<speech>Good luck!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="10"/>
</script>
<layers>
<layer color="0xff0000" value="5">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xeeff00" value="10">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x00ff00" value="20">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x0000ff" value="40">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM3:XML = <level timeLimit="45" goal="500" type="0" title="Chocolate Coated" precursor="Golden Nuggets">
<summary>Chocolate coatings are tasty, but they can be inconvenient.</summary>
<script>
<speech>Well, good to see you! What we have here is a chocolate-covered orb. Those brown pieces with the fancy pattern, they're made of pure concentrated chocolate ore!</speech>
<speech>Now, chocolate's mighty tasty, but it's also durned inconvenient. You hit some ore, and it'll burst forth with molten chocolate.</speech>
<speech>The thing is, chocolate ain't worth all that much. It's almost like it grows on trees! So be careful of chocolate ore, or you'll undo a lot of good work!</speech>
<speech>As for the rest of the candy here, it's all pretty much the same. Get 500 units of candy to win!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="4"/>
</script>
<layers>
<layer value="1">
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
</layer>
<layer value="10" color="0xffaa00">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer value="10" color="0xdd8800">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer value="10" color="0xaa6600">
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM4:XML = <level timeLimit="45" goal="275" type="0" title="Hollow Inside" precursor="Chocolate Coated">
<summary>Don't hit the core!</summary>
<script>
<speech>Well, this one's a doozy! Sometimes air pockets'll form inside the orbs. That's fine, though... just make sure not to hit the core too soon.</speech>
<speech>Oh, hey, and that green candy is sour apple. It's worth a bundle. Get 275 units of candy to win!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="2"/>
</script>
<layers>
<layer color="0xff0000" value="2">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xcc0000" value="2">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer>
<sector type="2"/>
</layer>
<layer color="0x00ff00" value="20">
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
</layer>
<layer>
<sector type="2"/>
</layer>
</layers>
</level>
;
public static const LevelM5:XML = <level timeLimit="45" goal="500" type="0" title="Fudge Ripple" precursor="Hollow Inside">
<summary>There's a vein of chocolate ore around this orb's core.</summary>
<script>
<speech>This should be simple enough. A chocolate mint! I reckon it's the green mint we want here; that white stuff's worthless.</speech>
<speech>Be careful of that chocolate ore, though. Hit it, and your job could get real hard, if you catch my meaning.</speech>
<speech>We're tryin' to get 500 units of candy this time. Good luck!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="3"/>
</script>
<layers>
<layer color="0xeeffee" value="2">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer color="0x33ff00" value="10">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
<sector type="1"/>
</layer>
</layers>
</level>
;
public static const LevelM6:XML = <level timeLimit="15" goal="700" type="0" title="Konpeito" precursor="Fudge Ripple">
<summary>Spikey!</summary>
<script>
<speech>I think we work well together, don't you? Aw, don't get all emotional on me.</speech>
<speech>This one's pretty simple. The more valuable candy is closer to the surface. Get 700 units of candy.</speech>
<bullet angle=".6666"/>
<bullet angle="1.3333"/>
<bullet angle="0"/>
<pause length="1"/>
<bullet angle=".1666"/>
<bullet angle=".8333"/>
<bullet angle="1.5"/>
<pause length="1"/>
<bullet angle=".3333"/>
<bullet angle="1"/>
<bullet angle="1.6666"/>
<pause length="1"/>
<bullet angle="1.1666"/>
<bullet angle="1.8333"/>
<bullet angle=".5"/>
<pause length="1"/>
<loop target="2"/>
</script>
<layers>
<layer color="0x00bbbb" value="10">
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector type="2"/>
</layer>
<layer color="0x00cccc" value="5">
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector type="2"/>
</layer>
<layer color="0x00dddd" value="3">
<sector type="2"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="2"/>
<sector type="2"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="2"/>
</layer>
<layer color="0x00eeee" value="2">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x00ffff" value="1">
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM7:XML = <level timeLimit="45" goal="450" type="0" title="Have a Nice Day" precursor="Introduction to Armor">
<summary>Well, would ya look at that?</summary>
<script>
<speech>Well, welcome back! I hope that grumpy Ms. Kellogg hasn't been givin' you too much trouble. I've got a humdinger here!</speech>
<speech>Lookit that! It sorta looks like me! That moustache there's where the good stuff is. Licorice. Don't like it myself, but some'll pay loads for it.</speech>
<speech>You gotta get 450 units of candy here. Good luck!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="3"/>
</script>
<layers>
<layer color="0xffff00" value="3">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="3">
<sector/>
<sector type="3"/>
<sector/>
<sector/>
<sector/>
<sector type="3"/>
<sector type="3"/>
<sector type="3"/>
<sector type="3"/>
<sector type="3"/>
<sector type="3"/>
<sector/>
<sector/>
<sector/>
<sector type="3"/>
<sector/>
</layer>
<layer color="0xffff00" value="3">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector color="0x333333" value="20"/>
<sector color="0x333333" value="20"/>
<sector color="0x333333" value="20"/>
<sector color="0x333333" value="20"/>
<sector color="0x333333" value="20"/>
<sector color="0x333333" value="20"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="3">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="3">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM8:XML = <level timeLimit="20" goal="1000" type="0" title="Lemon Drop" precursor="Have a Nice Day">
<summary>It's in there somewhere...</summary>
<script>
<speech>Well, here's the deal. This thing's mostly lemon candy, which ain't been worth all that much since they figured out how to make it out o' lemons and corn.</speech>
<speech>But our candiologist says that somewhere in there is a chunk o' pure golden candy. We'll be turnin' on the rapid fire for this one.</speech>
<speech>You'll prob'ly blow the whole orb, but as long as ya get the gold, you're good. Collect at least 2000 units of candy.</speech>
<bullet angle="1.5"/>
<pause length=".25"/>
<loop target="3"/>
</script>
<layers>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector value="200"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM2:XML = <level timeLimit="30" goal="525" type="0" title="Golden Nuggets" precursor="Jawbreaker">
<summary>Some kinds of candy are worth more than others.</summary>
<script>
<speech>Well done back there! This orb's a little special. That blue candy's sorrow-flavored. Not a very popular choice, and not worth much.</speech>
<speech>That golden candy, though, that's worth quite a bit to the hospitality industry, or so I hear. If you can get to it, you'll make a mint!</speech>
<speech>That's just a figure of speech, by the way. No mint candy here. Anyway, collect 525 units of candy to win!</speech>
<bullet angle="1.25"/>
<pause length="2"/>
<bullet angle=".25"/>
<pause length="2"/>
<bullet angle=".75"/>
<pause length="2"/>
<bullet angle="1.75"/>
<pause length="2"/>
<loop target="3"/>
</script>
<layers>
<layer color="0x0000ff" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector color="0xffff00" value="25"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x0000dd" value="1">
<sector/>
<sector/>
<sector/>
<sector color="0xffff00" value="25"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector color="0xffff00" value="25"/>
</layer>
<layer color="0x0000bb" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector color="0xffff00" value="25"/>
<sector/>
<sector/>
<sector/>
<sector color="0xffff00" value="25"/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x000099" value="1">
<sector color="0xffff00" value="25"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelM9:XML = <level timeLimit="60" goal="7500" type="0" title="Motherlode" precursor="Lemon Drop">
<summary>Now, that's a lot of candy!</summary>
<script>
<speech>Well! We've found a gosh-darned treasure! This thing looks chock-full of candy! You pull this one off, and we can both retire!</speech>
<speech>We'll need 7500 units of candy. Hop to it!</speech>
<bullet angle="1.25"/>
<pause length="1"/>
<bullet angle=".25"/>
<pause length="1"/>
<bullet angle=".75"/>
<pause length="1"/>
<bullet angle="1.75"/>
<pause length="1"/>
<bullet angle="1"/>
<pause length="1"/>
<bullet angle="0"/>
<pause length="1"/>
<bullet angle=".5"/>
<pause length="1"/>
<bullet angle="1.5"/>
<pause length="1"/>
<loop target="2"/>
</script>
<layers>
<layer color="0xff0000" value="5">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffbb00" value="10">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xeeee00" value="20">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x00ff00" value="40">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x0088ff" value="50">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x8800ff" value="100">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xff00cc" value="200">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelS1:XML = <level timeLimit="45" type="2" title="Basic Training" precursor="Introduction to Armor">
<summary>CANDY IS NOT A PLEASURE CRUISE! CANDY IS WAR!</summary>
<script>
<speech>All right, maggot! Listen up! My name is Sergeant P.C. Cola, and I do not tolerate slouching, malingering, or navel-gazing!</speech>
<speech>You think you've had it hard? Mining and demolitions is nothing compared to the horrors of the battlefield!</speech>
<speech>Up 'til now, the people firing bullets at you have been your FRIENDS! They have been on your SIDE! They have had SOULS!</speech>
<speech>But now, it's your turn to defend our nation's candy against those who would destroy our very way of eating!</speech>
<speech>Reinforcements come in 45 seconds. Survive until then with the orb intact, soldier!</speech>
<bullet angle="1.25"/>
<pause length=".75"/>
<bullet angle=".25"/>
<pause length=".75"/>
<bullet angle=".75"/>
<pause length=".75"/>
<bullet angle="1.75"/>
<pause length=".75"/>
<loop target="5"/>
</script>
<layers>
<layer color="0xff0000" value="5">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xeeff00" value="10">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x00ff00" value="20">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0x0000ff" value="40">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
public static const LevelS3:XML = <level timeLimit="120" type="2" title="Vital Strategic Importance" precursor="Stars and Stripes">
<summary>Chocolate is a valuable resource... IN TIMES OF WAR!</summary>
<script>
<speech>All right, soldier. This is the big one. You're gonna face some tough times, but your name will go down in history.</speech>
<speech>That miner probably told you chocolate ore was a hassle, didn't he? Well, you just forget that, private! Chocolate can be the difference between life and death!</speech>
<speech>It'll be a long haul, maggot. You're on your own for two minutes. But once it's done, you'll be a true man. Or woman. We all look the same in these uniforms.</speech>
<bullet angle="0"/>
<pause length=".5"/>
<bullet angle="1"/>
<pause length=".5"/>
<bullet angle="1.5"/>
<bullet angle=".5"/>
<pause length=".5"/>
<bullet angle="1"/>
<bullet angle="0"/>
<pause length=".5"/>
<bullet angle="1.5"/>
<pause length=".5"/>
<bullet angle=".5"/>
<pause length=".5"/>
<loop target="3"/>
</script>
<layers>
<layer color="0xffff00" value="1">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xffcc00" value="2">
<sector/>
<sector/>
<sector type="1"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector type="1"/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xff9900" value="3">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
<layer color="0xff6600" value="4">
<sector/>
<sector/>
<sector/>
<sector type="1"/>
<sector/>
<sector/>
<sector/>
<sector type="1"/>
</layer>
<layer color="0xff3300" value="5">
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
<sector/>
</layer>
</layers>
</level>
;
}
}//package Data
Section 14
//SaveData (Data.SaveData)
package Data {
import com.kongregate.as3.client.*;
import flash.net.*;
public class SaveData {
private static const HIGHSCORE:String = "_HIGHSCORE";
private static const COMPLETE:String = "_COMPLETE";
private static const ENDINGPLAYED:String = "ENDINGPLAYED";
private static var datastore:SharedObject = SharedObject.getLocal("Sugarcore", "/");
private static var kongregate:KongregateAPI = KongregateAPI.getInstance();
public static function getHighScore(_arg1:String):int{
if (datastore.data[(_arg1 + HIGHSCORE)] != null){
return (datastore.data[(_arg1 + HIGHSCORE)]);
};
return (-1);
}
public static function isComplete(_arg1:String):Boolean{
if (datastore.data[(_arg1 + COMPLETE)] == true){
return (true);
};
return (false);
}
public static function reportLevelsBeaten(_arg1:int):void{
kongregate.stats.submit("Levels Beaten", _arg1);
}
public static function saveLevel(_arg1:String, _arg2:Boolean, _arg3:int):void{
if (_arg2){
datastore.data[(_arg1 + COMPLETE)] = true;
if ((((datastore.data[(_arg1 + HIGHSCORE)] == null)) || ((datastore.data[(_arg1 + HIGHSCORE)] < _arg3)))){
datastore.data[(_arg1 + HIGHSCORE)] = _arg3;
kongregate.stats.submit(_arg1, _arg3);
};
};
datastore.flush();
}
public static function endingPlayed():Boolean{
if (datastore.data[ENDINGPLAYED] == true){
return (true);
};
return (false);
}
public static function playEnding():void{
datastore.data[ENDINGPLAYED] = true;
datastore.flush();
kongregate.stats.submit("Game Beaten", 1);
}
public static function reportTotalScore(_arg1:int):void{
kongregate.scores.submit(_arg1, "Total");
}
public static function clearAllData():void{
datastore.clear();
}
}
}//package Data
Section 15
//Music (Effects.Music)
package Effects {
import flash.events.*;
import mx.events.*;
import flash.media.*;
public class Music implements IEventDispatcher {
private var _bindingEventDispatcher:EventDispatcher;
private static var _887348308bgmJolly:Class = Music_bgmJolly;
private static var _staticBindingEventDispatcher:EventDispatcher = new EventDispatcher();
private static var musicToggle:Boolean = true;
private static var soundTransform:SoundTransform = new SoundTransform(0.5);
private static var musicChannel:SoundChannel;
private static var _1001522156bgmHarmonica:Class = Music_bgmHarmonica;
private static var nowPlaying:Class;
private static var _10183688bgmInfiltrate:Class = Music_bgmInfiltrate;
public function Music(){
_bindingEventDispatcher = new EventDispatcher(IEventDispatcher(this));
super();
}
public function dispatchEvent(_arg1:Event):Boolean{
return (_bindingEventDispatcher.dispatchEvent(_arg1));
}
public function willTrigger(_arg1:String):Boolean{
return (_bindingEventDispatcher.willTrigger(_arg1));
}
public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
_bindingEventDispatcher.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
}
public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
_bindingEventDispatcher.removeEventListener(_arg1, _arg2, _arg3);
}
public function hasEventListener(_arg1:String):Boolean{
return (_bindingEventDispatcher.hasEventListener(_arg1));
}
public static function stopMusic():void{
nowPlaying = null;
musicChannel.stop();
}
public static function get bgmInfiltrate():Class{
return (Music._10183688bgmInfiltrate);
}
public static function get staticEventDispatcher():IEventDispatcher{
return (_staticBindingEventDispatcher);
}
public static function set bgmHarmonica(_arg1:Class):void{
var _local3:IEventDispatcher;
var _local2:Object = Music._1001522156bgmHarmonica;
if (_local2 !== _arg1){
Music._1001522156bgmHarmonica = _arg1;
_local3 = Music.staticEventDispatcher;
if (_local3 != null){
_local3.dispatchEvent(PropertyChangeEvent.createUpdateEvent(Music, "bgmHarmonica", _local2, _arg1));
};
};
}
public static function musicMute(_arg1:Boolean):void{
var mute = _arg1;
musicToggle = !(mute);
if (mute){
musicChannel.stop();
} else {
if (nowPlaying != null){
musicChannel = (new nowPlaying() as Sound).play(0, 0, soundTransform);
musicChannel.addEventListener(Event.SOUND_COMPLETE, function (_arg1:Event):void{
startMusic(nowPlaying);
});
};
};
}
public static function set bgmJolly(_arg1:Class):void{
var _local3:IEventDispatcher;
var _local2:Object = Music._887348308bgmJolly;
if (_local2 !== _arg1){
Music._887348308bgmJolly = _arg1;
_local3 = Music.staticEventDispatcher;
if (_local3 != null){
_local3.dispatchEvent(PropertyChangeEvent.createUpdateEvent(Music, "bgmJolly", _local2, _arg1));
};
};
}
public static function startMusic(_arg1:Class, _arg2:Boolean=true):void{
var song = _arg1;
var dontRestart = _arg2;
if (((!(dontRestart)) || (!((nowPlaying == song))))){
if (musicChannel != null){
musicChannel.stop();
};
nowPlaying = song;
if (musicToggle){
musicChannel = (new (song) as Sound).play(0, 0, soundTransform);
musicChannel.addEventListener(Event.SOUND_COMPLETE, function (_arg1:Event):void{
startMusic(song, false);
});
};
};
}
public static function get bgmHarmonica():Class{
return (Music._1001522156bgmHarmonica);
}
public static function set bgmInfiltrate(_arg1:Class):void{
var _local3:IEventDispatcher;
var _local2:Object = Music._10183688bgmInfiltrate;
if (_local2 !== _arg1){
Music._10183688bgmInfiltrate = _arg1;
_local3 = Music.staticEventDispatcher;
if (_local3 != null){
_local3.dispatchEvent(PropertyChangeEvent.createUpdateEvent(Music, "bgmInfiltrate", _local2, _arg1));
};
};
}
public static function get bgmJolly():Class{
return (Music._887348308bgmJolly);
}
}
}//package Effects
Section 16
//Music_bgmHarmonica (Effects.Music_bgmHarmonica)
package Effects {
import mx.core.*;
public class Music_bgmHarmonica extends SoundAsset {
}
}//package Effects
Section 17
//Music_bgmInfiltrate (Effects.Music_bgmInfiltrate)
package Effects {
import mx.core.*;
public class Music_bgmInfiltrate extends SoundAsset {
}
}//package Effects
Section 18
//Music_bgmJolly (Effects.Music_bgmJolly)
package Effects {
import mx.core.*;
public class Music_bgmJolly extends SoundAsset {
}
}//package Effects
Section 19
//SFX (Effects.SFX)
package Effects {
import flash.media.*;
public class SFX {
private static var soundShatter:Class = SFX_soundShatter;
private static var soundWaahwaah:Class = SFX_soundWaahwaah;
private static var soundBoom:Class = SFX_soundBoom;
private static var soundCollect:Class = SFX_soundCollect;
public static var soundsEnabled:Boolean = true;
private static var soundTink:Class = SFX_soundTink;
private static var soundSquirt:Class = SFX_soundSquirt;
private static var soundFanfare:Class = SFX_soundFanfare;
private static var soundBullet:Class = SFX_soundBullet;
public static function fanfare():void{
if (soundsEnabled){
(new soundFanfare() as Sound).play();
};
}
public static function fireBullet():void{
if (soundsEnabled){
(new soundBullet() as Sound).play();
};
}
public static function shatter():void{
if (soundsEnabled){
(new soundShatter() as Sound).play();
};
}
public static function collect():void{
if (soundsEnabled){
(new soundCollect() as Sound).play();
};
}
public static function boom():void{
if (soundsEnabled){
(new soundBoom() as Sound).play();
};
}
public static function waahwaah():void{
if (soundsEnabled){
(new soundWaahwaah() as Sound).play();
};
}
public static function squirt():void{
if (soundsEnabled){
(new soundSquirt() as Sound).play();
};
}
public static function tink():void{
if (soundsEnabled){
(new soundTink() as Sound).play();
};
}
}
}//package Effects
Section 20
//SFX_soundBoom (Effects.SFX_soundBoom)
package Effects {
import mx.core.*;
public class SFX_soundBoom extends SoundAsset {
}
}//package Effects
Section 21
//SFX_soundBullet (Effects.SFX_soundBullet)
package Effects {
import mx.core.*;
public class SFX_soundBullet extends SoundAsset {
}
}//package Effects
Section 22
//SFX_soundCollect (Effects.SFX_soundCollect)
package Effects {
import mx.core.*;
public class SFX_soundCollect extends SoundAsset {
}
}//package Effects
Section 23
//SFX_soundFanfare (Effects.SFX_soundFanfare)
package Effects {
import mx.core.*;
public class SFX_soundFanfare extends SoundAsset {
}
}//package Effects
Section 24
//SFX_soundShatter (Effects.SFX_soundShatter)
package Effects {
import mx.core.*;
public class SFX_soundShatter extends SoundAsset {
}
}//package Effects
Section 25
//SFX_soundSquirt (Effects.SFX_soundSquirt)
package Effects {
import mx.core.*;
public class SFX_soundSquirt extends SoundAsset {
}
}//package Effects
Section 26
//SFX_soundTink (Effects.SFX_soundTink)
package Effects {
import mx.core.*;
public class SFX_soundTink extends SoundAsset {
}
}//package Effects
Section 27
//SFX_soundWaahwaah (Effects.SFX_soundWaahwaah)
package Effects {
import mx.core.*;
public class SFX_soundWaahwaah extends SoundAsset {
}
}//package Effects
Section 28
//Button (Interface.Button)
package Interface {
import flash.display.*;
import flash.geom.*;
import flash.text.*;
public class Button extends Sprite {
private var labelText:TextField;
public function Button(_arg1:int, _arg2:int, _arg3:String){
buttonMode = true;
mouseChildren = false;
var _local4:Matrix = new Matrix();
_local4.createGradientBox(_arg1, _arg2, 90);
graphics.lineStyle(2, 16737894);
graphics.beginGradientFill(GradientType.LINEAR, [16755370, 16742263], [1, 1], [0, 0xFF], _local4);
graphics.drawRoundRect(0, 0, _arg1, _arg2, 16);
graphics.endFill();
labelText = new TextField();
labelText.defaultTextFormat = Font.BasicSelfDestructCenter;
labelText.embedFonts = true;
labelText.selectable = false;
labelText.text = _arg3;
labelText.width = _arg1;
labelText.height = _arg2;
labelText.y = ((_arg2 - labelText.textHeight) / 2);
this.addChild(labelText);
}
public function setText(_arg1:String):void{
labelText.text = _arg1;
}
}
}//package Interface
Section 29
//CandyCounter (Interface.CandyCounter)
package Interface {
import flash.display.*;
import flash.text.*;
public class CandyCounter extends Sprite {
private var frozen:Boolean;// = false
private var goal:int;
private var totalCount:Number;// = 0
private var text:TextField;
public function CandyCounter(_arg1:int){
this.goal = _arg1;
var _local2:TextField = new TextField();
_local2.defaultTextFormat = Font.BasicSelfDestruct;
_local2.embedFonts = true;
_local2.height = 25;
_local2.text = "Candy:";
this.addChild(_local2);
text = new TextField();
text.defaultTextFormat = Font.BasicSelfDestructRight;
text.embedFonts = true;
text.x = 50;
text.width = 100;
text.height = 25;
addCandy(0);
this.addChild(text);
}
public function get total():int{
return (totalCount);
}
public function addCandy(_arg1:Number):void{
if (!frozen){
this.totalCount = (this.totalCount + _arg1);
text.text = int(totalCount).toString();
if (goal != 0){
text.appendText(("/" + goal));
};
};
}
public function freeze():void{
this.frozen = true;
}
}
}//package Interface
Section 30
//Font (Interface.Font)
package Interface {
import flash.text.*;
public class Font {
private static const SELFDESTRUCT:String = "SelfDestruct";
public static const BasicSelfDestructCenter:TextFormat = new TextFormat(SELFDESTRUCT, 18, null, null, null, null, null, null, TextFormatAlign.CENTER);
public static const BasicSelfDestructRight:TextFormat = new TextFormat(SELFDESTRUCT, 18, null, null, null, null, null, null, TextFormatAlign.RIGHT);
public static const HugeSelfDestruct:TextFormat = new TextFormat(SELFDESTRUCT, 64);
public static const BasicSelfDestruct:TextFormat = new TextFormat(SELFDESTRUCT, 18);
public static const BigSelfDestructCenter:TextFormat = new TextFormat(SELFDESTRUCT, 28, null, null, null, null, null, null, TextFormatAlign.CENTER);
private static var selfDestruct:String = "Font_selfDestruct";
}
}//package Interface
Section 31
//Font_selfDestruct (Interface.Font_selfDestruct)
package Interface {
import mx.core.*;
public class Font_selfDestruct extends FontAsset {
}
}//package Interface
Section 32
//LevelButton (Interface.LevelButton)
package Interface {
import flash.events.*;
import Screens.*;
import flash.text.*;
import Data.*;
public class LevelButton extends Button {
public var enabled:Boolean;
private var levelData:XML;
private var summField:TextField;
public function LevelButton(_arg1:String, _arg2:XML, _arg3:TextField){
super(30, 30, _arg1);
this.levelData = _arg2;
this.summField = _arg3;
if ((((_arg2.@precursor.length() > 0)) && (!(SaveData.isComplete(_arg2.@precursor))))){
enabled = false;
this.alpha = 0.6;
buttonMode = false;
} else {
enabled = true;
addListeners();
buttonMode = true;
};
}
private function onClick(_arg1:MouseEvent):void{
Main.pushScreen(new PlayScreen(levelData));
}
public function update():void{
if ((((levelData.@precursor.length() > 0)) && (!(SaveData.isComplete(levelData.@precursor))))){
if (enabled){
this.enabled = false;
buttonMode = false;
this.alpha = 0.75;
this.removeListeners();
};
} else {
if (!enabled){
buttonMode = true;
this.enabled = true;
this.alpha = 1;
this.addListeners();
};
};
}
private function onOut(_arg1:MouseEvent):void{
summField.text = "SELECT A LEVEL";
}
private function onOver(_arg1:MouseEvent):void{
summField.text = levelData.@title;
summField.appendText(("\n\n" + levelData.summary));
summField.appendText("\n\nHigh Score: ");
var _local2:int = SaveData.getHighScore(levelData.@title);
if (_local2 != -1){
summField.appendText(_local2.toString());
} else {
summField.appendText("--");
};
}
private function removeListeners():void{
this.removeEventListener(MouseEvent.CLICK, onClick);
this.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
this.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
}
public function get topScore():int{
return (SaveData.getHighScore(levelData.@title));
}
private function addListeners():void{
this.addEventListener(MouseEvent.CLICK, onClick);
this.addEventListener(MouseEvent.MOUSE_OVER, onOver);
this.addEventListener(MouseEvent.MOUSE_OUT, onOut);
}
public function get beaten():Boolean{
return (SaveData.isComplete(levelData.@title));
}
}
}//package Interface
Section 33
//LevelTimer (Interface.LevelTimer)
package Interface {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
public class LevelTimer extends Sprite {
private var timer:Timer;
private var text:TextField;
private var totalTime:Number;
public function LevelTimer(_arg1:Number){
this.totalTime = _arg1;
var _local2:TextField = new TextField();
_local2.defaultTextFormat = Font.BasicSelfDestruct;
_local2.embedFonts = true;
_local2.height = 25;
_local2.width = 125;
_local2.text = "Time Remaining:";
this.addChild(_local2);
text = new TextField();
text.defaultTextFormat = Font.BasicSelfDestructRight;
text.embedFonts = true;
text.x = 100;
text.width = 50;
text.height = 25;
text.text = _arg1.toFixed(1);
this.addChild(text);
timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, updateCount);
timer.start();
}
public function updateCount(_arg1:TimerEvent):void{
var _local2:Number = this.timeLeft;
if (_local2 < 0){
_local2 = 0;
};
text.text = _local2.toFixed(1);
}
public function get expired():Boolean{
return (((totalTime * 10) < timer.currentCount));
}
public function resume():void{
timer.start();
}
public function get timeLeft():Number{
return ((totalTime - (Number(timer.currentCount) / 10)));
}
public function pause():void{
timer.stop();
}
public function clear():void{
timer.stop();
text.text = "--";
}
}
}//package Interface
Section 34
//MusicToggle (Interface.MusicToggle)
package Interface {
import flash.display.*;
import Effects.*;
public class MusicToggle extends ToggleButton {
private static var spriteMusic:Class = MusicToggle_spriteMusic;
private static var _enabled:Boolean = true;
public function MusicToggle(){
this.iconBitmap = (new spriteMusic() as Bitmap);
super();
}
override protected function disable():void{
Music.musicMute(true);
}
override protected function get enabled():Boolean{
return (_enabled);
}
override protected function set enabled(_arg1:Boolean):void{
_enabled = _arg1;
}
override protected function enable():void{
Music.musicMute(false);
}
}
}//package Interface
Section 35
//MusicToggle_spriteMusic (Interface.MusicToggle_spriteMusic)
package Interface {
import mx.core.*;
public class MusicToggle_spriteMusic extends BitmapAsset {
}
}//package Interface
Section 36
//SoundToggle (Interface.SoundToggle)
package Interface {
import flash.display.*;
import Effects.*;
public class SoundToggle extends ToggleButton {
private static var spriteSound:Class = SoundToggle_spriteSound;
private static var _enabled:Boolean = true;
public function SoundToggle(){
this.iconBitmap = (new spriteSound() as Bitmap);
super();
}
override protected function disable():void{
SFX.soundsEnabled = false;
}
override protected function get enabled():Boolean{
return (_enabled);
}
override protected function set enabled(_arg1:Boolean):void{
_enabled = _arg1;
}
override protected function enable():void{
SFX.soundsEnabled = true;
}
}
}//package Interface
Section 37
//SoundToggle_spriteSound (Interface.SoundToggle_spriteSound)
package Interface {
import mx.core.*;
public class SoundToggle_spriteSound extends BitmapAsset {
}
}//package Interface
Section 38
//ToggleButton (Interface.ToggleButton)
package Interface {
import flash.display.*;
import flash.events.*;
import Util.*;
public class ToggleButton extends Sprite {
private var noBitmap:Bitmap;
protected var iconBitmap:Bitmap;
private static var spriteNo:Class = ToggleButton_spriteNo;
public function ToggleButton(){
noBitmap = (new spriteNo() as Bitmap);
super();
draw();
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, toggle);
}
protected function get enabled():Boolean{
return (true);
}
protected function set enabled(_arg1:Boolean):void{
}
private function draw():void{
graphics.clear();
SugarGraphics.drawSprite(graphics, iconBitmap.bitmapData, 0, 0);
if (!enabled){
SugarGraphics.drawSprite(graphics, noBitmap.bitmapData, 0, 0);
};
}
protected function disable():void{
trace("oops.");
}
protected function enable():void{
trace("oops.");
}
private function toggle(_arg1:Event):void{
if (this.enabled){
enabled = false;
disable();
draw();
} else {
enabled = true;
enable();
draw();
};
}
}
}//package Interface
Section 39
//ToggleButton_spriteNo (Interface.ToggleButton_spriteNo)
package Interface {
import mx.core.*;
public class ToggleButton_spriteNo extends BitmapAsset {
}
}//package Interface
Section 40
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 41
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi.as3
Section 42
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
import flash.geom.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__ms_";
private static var _servicesURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
public static var netup:Boolean = true;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().getTime()));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var avm1Click:DisplayObject;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
var vars:Object = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
var s = "?";
var i:Number = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.0");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
public static function get id():String{
return (_id);
}
private static function urlOptions(_arg1:Object):Object{
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
var _local3:String = _arg1.loaderInfo.parameters.mochiad_options;
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_listenChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = this.client._callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
trace("connected!");
_connecting = false;
_connected = true;
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var id = _arg1;
var clip = _arg2;
var clipname:String = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(clip).servicesURL != undefined){
_servicesURL = urlOptions(clip).servicesURL;
};
MochiServices.allowDomains(_servicesURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
var f:Function = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().getTime()) + "_") + Math.floor((Math.random() * 99999))));
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
var req:URLRequest = new URLRequest(_servicesURL);
var vars:URLVariables = new URLVariables();
vars.listenLC = _listenChannelName;
vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options;
if (widget){
vars.widget = true;
};
req.data = vars;
listen();
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function get clip():Object{
return (_container);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
var mc:MovieClip = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package mochi.as3
Section 43
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.0.0.0";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 44
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 45
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 46
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 47
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 48
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 49
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 50
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 51
//PropertyChangeEvent (mx.events.PropertyChangeEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class PropertyChangeEvent extends Event {
public var newValue:Object;
public var kind:String;
public var property:Object;
public var oldValue:Object;
public var source:Object;
mx_internal static const VERSION:String = "3.0.0.0";
public static const PROPERTY_CHANGE:String = "propertyChange";
public function PropertyChangeEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:String=null, _arg5:Object=null, _arg6:Object=null, _arg7:Object=null, _arg8:Object=null){
super(_arg1, _arg2, _arg3);
this.kind = _arg4;
this.property = _arg5;
this.oldValue = _arg6;
this.newValue = _arg7;
this.source = _arg8;
}
override public function clone():Event{
return (new PropertyChangeEvent(type, bubbles, cancelable, kind, property, oldValue, newValue, source));
}
public static function createUpdateEvent(_arg1:Object, _arg2:Object, _arg3:Object, _arg4:Object):PropertyChangeEvent{
var _local5:PropertyChangeEvent = new PropertyChangeEvent(PROPERTY_CHANGE);
_local5.kind = PropertyChangeEventKind.UPDATE;
_local5.oldValue = _arg3;
_local5.newValue = _arg4;
_local5.source = _arg1;
_local5.property = _arg2;
return (_local5);
}
}
}//package mx.events
Section 52
//PropertyChangeEventKind (mx.events.PropertyChangeEventKind)
package mx.events {
import mx.core.*;
public final class PropertyChangeEventKind {
mx_internal static const VERSION:String = "3.0.0.0";
public static const UPDATE:String = "update";
public static const DELETE:String = "delete";
}
}//package mx.events
Section 53
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local4:String;
var _local5:Array;
var _local3:DisplayObject = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 54
//CreditsScreen (Screens.CreditsScreen)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import Interface.*;
public class CreditsScreen extends Sprite {
public function CreditsScreen(){
super();
var creditsText:TextField = new TextField();
creditsText.defaultTextFormat = Font.BasicSelfDestruct;
creditsText.embedFonts = true;
creditsText.x = 50;
creditsText.y = 100;
creditsText.width = (Preloader.GAME_WIDTH - 100);
creditsText.height = (Preloader.GAME_HEIGHT - 200);
creditsText.wordWrap = true;
creditsText.text = "Sugarcore was designed and developed by Gregory Weir.";
creditsText.appendText("\n\nThanks to Troy Gilbert for his collision detection class.");
creditsText.appendText("\n\nSugarcore uses sounds and music from BLASTWAVEFX, Radio Mall, Dynamedion, Andrew Potterton, and Shriek Productions, found on soundsnap.com.");
creditsText.appendText("\n\nSugarcore uses the font \"Self Destruct Button\" by Blambot Comic Fonts and Lettering.");
creditsText.appendText("\n\nThanks to Melissa Avery for testing, inspiration, and emotional support.");
this.addChild(creditsText);
var backButton:Button = new Button(75, 30, "Back");
backButton.x = 400;
backButton.y = 460;
backButton.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
Main.popScreen();
});
this.addChild(backButton);
}
public function update():void{
}
public function step():void{
}
}
}//package Screens
Section 55
//EndScreen (Screens.EndScreen)
package Screens {
import flash.display.*;
import flash.text.*;
import WorldObjects.*;
import Interface.*;
import Effects.*;
import mochi.as3.*;
import Data.*;
public class EndScreen extends Sprite {
private var stepCount:int;
private var totalScore:int;
public function EndScreen(_arg1:int){
this.totalScore = _arg1;
var _local2:Orb = new Orb(null, LevelData.LevelM1.layers);
_local2.rotation = 45;
this.addChild(_local2);
this.x = (Preloader.GAME_WIDTH / 2);
this.y = (Preloader.GAME_HEIGHT / 2);
var _local3:TextField = new TextField();
_local3.defaultTextFormat = Font.HugeSelfDestruct;
_local3.embedFonts = true;
_local3.width = 500;
_local3.x = -125;
_local3.y = -225;
_local3.text = "YOU WIN!";
_local3.selectable = false;
_local3.textColor = 16737894;
this.addChild(_local3);
}
private function closeScores():void{
Music.stopMusic();
MochiAd.showInterLevelAd({clip:root, id:"60f7199bdd383df2", res:"500x500", no_bg:true, ad_finished:closeEndingForReal});
}
private function showScores():void{
var o:Object = {n:[10, 15, 8, 5, 14, 5, 10, 1, 13, 4, 10, 3, 12, 2, 8, 10], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
var boardID:String = o.f(0, "");
this.visible = false;
MochiScores.showLeaderboard({boardID:boardID, score:totalScore, res:"500x500", showTableRank:true, onClose:closeScores});
}
private function closeEndingForReal():void{
Main.popScreen();
}
public function update():void{
}
public function step():void{
switch (stepCount){
case 0:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "Well, hey! You managed to take care of all the levels, didn't you?"));
break;
case 1:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "Mighty fine job! I always knew you had it in you."));
break;
case 2:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "Oh, and look who the cat dragged in!"));
break;
case 3:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_DEMOLITION, "Why, Mr. Lolly. I didn't expect to see you here. Don't you have some taffy to pull or some such nonsense?"));
break;
case 4:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "Nope! Taffy's all pulled."));
break;
case 5:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_DEMOLITION, "...quite. Well, I just thought I'd congratulate our mutual friend here, if that's all right with you."));
break;
case 6:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "Fine with me! Our friend's done durned fine work."));
break;
case 7:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_DEMOLITION, "Very well, then. By the honor I possess as Daph..."));
break;
case 8:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_SURVIVAL, "HOOOOOOOOO-WAH!"));
break;
case 9:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_DEMOLITION, "Oh, goodness me! What on earth was that?"));
break;
case 10:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_SURVIVAL, "Well done, soldier! It's been an honor to serve with you in this campaign!"));
break;
case 11:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_DEMOLITION, "I see... a military man. Enchante."));
break;
case 12:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_SURVIVAL, "Enchanty yourself, ma'am! Sergeant Cola at your service, ma'am!"));
break;
case 13:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_DEMOLITION, "Oh, and aren't you just? Call me Daphne."));
break;
case 14:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "I think we'd better let them get acquainted-like."));
break;
case 15:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "It really has been one heck of a pleasure, though."));
break;
case 16:
Main.pushScreen(new SpeechPopup(PlayScreen.TYPE_MINING, "Nice workin' with you. See you around!"));
break;
case 17:
showScores();
break;
};
stepCount++;
}
}
}//package Screens
Section 56
//HelpScreen (Screens.HelpScreen)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import Interface.*;
import Util.*;
public class HelpScreen extends Sprite {
public function HelpScreen(){
super();
SugarGraphics.drawSprite(graphics, (new SpeechPopup.portraitMiner() as Bitmap).bitmapData, 15, 200);
SugarGraphics.drawSprite(graphics, (new SpeechPopup.portraitNoblewoman() as Bitmap).bitmapData, 15, 275);
SugarGraphics.drawSprite(graphics, (new SpeechPopup.portraitGeneral() as Bitmap).bitmapData, 15, 350);
var helpText:TextField = new TextField();
helpText.defaultTextFormat = Font.BasicSelfDestruct;
helpText.embedFonts = true;
helpText.x = 90;
helpText.y = 25;
helpText.width = (Preloader.GAME_WIDTH - 100);
helpText.height = (Preloader.GAME_HEIGHT - 25);
helpText.wordWrap = true;
helpText.text = "- Rotate the candy orbs with your mouse and click to advance dialogue!";
helpText.appendText("\n\n- When a bullet hits the orb, candy bits are released! Release candy bits to increase your score!");
helpText.appendText("\n\n- If a bullet hits the red core of an orb, the orb will explode and the level will end!");
helpText.appendText("\n\n- Different characters give you different types of goals:");
helpText.appendText("\n\n\nMINING:\nCollect a certain amount of candy before time runs out!\n");
helpText.appendText("\n\n\nDEMOLITION:\nDestroy the orb by hitting the core before time runs out!\n");
helpText.appendText("\n\n\nSURVIVAL:\nKeep the orb from exploding until time runs out!");
helpText.appendText("\n\n- Some orbs have special materials in them! These will be explained the first time they appear!");
this.addChild(helpText);
var backButton:Button = new Button(75, 30, "Back");
backButton.x = 400;
backButton.y = 460;
backButton.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
Main.popScreen();
});
this.addChild(backButton);
}
public function update():void{
}
public function step():void{
}
}
}//package Screens
Section 57
//LevelSelectScreen (Screens.LevelSelectScreen)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import Interface.*;
import Util.*;
import Effects.*;
import mochi.as3.*;
import Data.*;
public class LevelSelectScreen extends Sprite {
private var realClearButton:Button;
private var cancelClearButton:Button;
private var endButton:Button;
private var totalScore:int;
private var clearButton:Button;
public function LevelSelectScreen(){
super();
graphics.lineStyle(3, 16737894);
graphics.beginFill(16764108);
graphics.drawRoundRect(25, 25, (Preloader.GAME_WIDTH - 50), 100, 25);
graphics.endFill();
SugarGraphics.drawSprite(graphics, (new SpeechPopup.portraitMiner() as Bitmap).bitmapData, 10, 140);
SugarGraphics.drawSprite(graphics, (new SpeechPopup.portraitNoblewoman() as Bitmap).bitmapData, 10, 240);
SugarGraphics.drawSprite(graphics, (new SpeechPopup.portraitGeneral() as Bitmap).bitmapData, 10, 340);
graphics.lineStyle(3, 16737894, 0.5);
graphics.moveTo(105, 170);
graphics.lineTo(330, 170);
graphics.moveTo(195, 170);
graphics.lineTo(240, 270);
graphics.lineTo(465, 270);
graphics.moveTo(330, 270);
graphics.lineTo(375, 170);
graphics.lineTo(465, 170);
graphics.moveTo(330, 270);
graphics.lineTo(375, 370);
graphics.lineTo(465, 370);
var levelText:TextField = new TextField();
levelText.defaultTextFormat = Font.BasicSelfDestructCenter;
levelText.embedFonts = true;
levelText.x = 30;
levelText.y = 30;
levelText.width = (Preloader.GAME_WIDTH - 60);
levelText.height = 90;
levelText.selectable = false;
levelText.text = "SELECT A LEVEL";
this.addChild(levelText);
addLevel("01", LevelData.LevelM1, 90, 155, levelText);
addLevel("02", LevelData.LevelM2, 135, 155, levelText);
addLevel("03", LevelData.LevelM3, 180, 155, levelText);
addLevel("04", LevelData.LevelM4, 225, 155, levelText);
addLevel("05", LevelData.LevelM5, 270, 155, levelText);
addLevel("06", LevelData.LevelM6, 315, 155, levelText);
addLevel("07", LevelData.LevelM7, 360, 155, levelText);
addLevel("08", LevelData.LevelM8, 405, 155, levelText);
addLevel("09", LevelData.LevelM9, 450, 155, levelText);
addLevel("01", LevelData.LevelD1, 225, 0xFF, levelText);
addLevel("02", LevelData.LevelD2, 270, 0xFF, levelText);
addLevel("03", LevelData.LevelD3, 315, 0xFF, levelText);
addLevel("04", LevelData.LevelD4, 360, 0xFF, levelText);
addLevel("05", LevelData.LevelD5, 405, 0xFF, levelText);
addLevel("06", LevelData.LevelD6, 450, 0xFF, levelText);
addLevel("01", LevelData.LevelS1, 360, 355, levelText);
addLevel("02", LevelData.LevelS2, 405, 355, levelText);
addLevel("03", LevelData.LevelS3, 450, 355, levelText);
clearButton = new Button(150, 30, "Clear Saved Game!");
clearButton.x = 10;
clearButton.y = 420;
this.addChild(clearButton);
clearButton.addEventListener(MouseEvent.CLICK, askClear);
cancelClearButton = new Button(150, 30, "Never mind.");
cancelClearButton.x = 175;
cancelClearButton.y = 420;
realClearButton = new Button(150, 30, "Yes, really!");
realClearButton.x = 340;
realClearButton.y = 420;
endButton = new Button(150, 30, "Replay Ending");
endButton.x = 60;
endButton.y = 460;
endButton.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
Main.pushScreen(new EndScreen(totalScore));
});
this.addChild(endButton);
var scoresButton:Button = new Button(150, 30, "Submit High Score");
scoresButton.x = 225;
scoresButton.y = 460;
scoresButton.addEventListener(MouseEvent.CLICK, showScores);
this.addChild(scoresButton);
var backButton:Button = new Button(75, 30, "Back");
backButton.x = 400;
backButton.y = 460;
backButton.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
Main.popScreen();
});
this.addChild(backButton);
}
private function addLevel(_arg1:String, _arg2:XML, _arg3:int, _arg4:int, _arg5:TextField):void{
var _local6:LevelButton = new LevelButton(_arg1, _arg2, _arg5);
_local6.x = _arg3;
_local6.y = _arg4;
this.addChild(_local6);
}
private function makeVisible():void{
this.visible = true;
this.update();
}
public function update():void{
var _local3:*;
Music.startMusic(Music.bgmJolly);
var _local1:Boolean;
var _local2:int;
totalScore = 0;
var _local4:int;
while (_local4 < this.numChildren) {
_local3 = this.getChildAt(_local4);
if ((_local3 is LevelButton)){
LevelButton(_local3).update();
if (_local3.beaten){
_local2++;
totalScore = (totalScore + _local3.topScore);
} else {
_local1 = false;
};
};
_local4++;
};
SaveData.reportLevelsBeaten(_local2);
SaveData.reportTotalScore(totalScore);
if (_local1){
endButton.visible = true;
if (!SaveData.endingPlayed()){
SaveData.playEnding();
Main.pushScreen(new EndScreen(totalScore));
};
} else {
endButton.visible = false;
};
}
private function cancelClear(_arg1:MouseEvent):void{
clearButton.setText("Clear Saved Game!");
clearButton.alpha = 1;
this.removeChild(cancelClearButton);
this.removeChild(realClearButton);
clearButton.addEventListener(MouseEvent.CLICK, askClear);
cancelClearButton.removeEventListener(MouseEvent.CLICK, cancelClear);
realClearButton.removeEventListener(MouseEvent.CLICK, reallyClear);
}
public function step():void{
}
private function reallyClear(_arg1:MouseEvent):void{
SaveData.clearAllData();
this.update();
cancelClear(_arg1);
}
private function askClear(_arg1:MouseEvent):void{
clearButton.setText("Clear Saved Game?");
clearButton.alpha = 0.5;
clearButton.removeEventListener(MouseEvent.CLICK, askClear);
this.addChild(cancelClearButton);
this.addChild(realClearButton);
cancelClearButton.addEventListener(MouseEvent.CLICK, cancelClear);
realClearButton.addEventListener(MouseEvent.CLICK, reallyClear);
}
private function showScores(_arg1:MouseEvent):void{
var e = _arg1;
var o:Object = {n:[10, 15, 8, 5, 14, 5, 10, 1, 13, 4, 10, 3, 12, 2, 8, 10], f:function (_arg1:Number, _arg2:String):String{
if (_arg2.length == 16){
return (_arg2);
};
return (this.f((_arg1 + 1), (_arg2 + this.n[_arg1].toString(16))));
}};
var boardID:String = o.f(0, "");
this.visible = false;
MochiScores.showLeaderboard({boardID:boardID, score:totalScore, res:"500x500", showTableRank:true, onClose:closeScores});
}
private function closeScores():void{
Music.stopMusic();
MochiAd.showInterLevelAd({clip:root, id:"60f7199bdd383df2", res:"500x500", no_bg:true, ad_finished:makeVisible});
}
}
}//package Screens
Section 58
//PlayScreen (Screens.PlayScreen)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import WorldObjects.*;
import Interface.*;
import Util.*;
import Effects.*;
public class PlayScreen extends Sprite {
private var orb:Orb;
private var scriptIndex:int;// = 0
private var goal:int;
private var levelData:XML;
public var candyCounter:CandyCounter;
private var title:String;
private var levelTimer:LevelTimer;
private var waitTime:int;// = 0
public var bullets:Array;
private var levelOver:Boolean;// = false
private var leveltype:int;
public static const TYPE_SURVIVAL:int = 2;
public static const TYPE_MINING:int = 0;
public static const TYPE_DEMOLITION:int = 1;
private static const BULLET_SPEED:Number = 5;
public function PlayScreen(_arg1:XML){
bullets = new Array();
super();
this.levelData = _arg1;
this.x = (Preloader.GAME_WIDTH / 2);
this.y = (Preloader.GAME_HEIGHT / 2);
graphics.beginFill(0, 0);
graphics.drawRect(-(this.x), -(this.y), Preloader.GAME_WIDTH, Preloader.GAME_HEIGHT);
graphics.endFill();
orb = new Orb(this, levelData.layers);
orb.x = 0;
orb.y = 0;
this.addChild(orb);
candyCounter = new CandyCounter(parseInt(_arg1.@goal));
candyCounter.x = 90;
candyCounter.y = -240;
this.addChild(candyCounter);
if (_arg1.@timeLimit.length() != 0){
levelTimer = new LevelTimer(parseFloat(_arg1.@timeLimit));
levelTimer.x = 90;
levelTimer.y = 230;
this.addChild(levelTimer);
};
this.leveltype = parseInt(_arg1.@type);
switch (this.leveltype){
case TYPE_MINING:
Music.startMusic(Music.bgmHarmonica);
this.goal = parseInt(_arg1.@goal);
break;
case TYPE_DEMOLITION:
Music.startMusic(Music.bgmJolly);
break;
case TYPE_SURVIVAL:
Music.startMusic(Music.bgmInfiltrate);
break;
};
this.title = _arg1.@title;
this.mouseChildren = false;
this.addEventListener(MouseEvent.MOUSE_MOVE, orb.mouseMove);
orb.mouseMove(null);
}
public function get collectPoint():Point{
return (new Point((candyCounter.x + (candyCounter.width / 2)), (candyCounter.y + (candyCounter.height / 2))));
}
public function update():void{
if (levelTimer != null){
levelTimer.resume();
};
this.addEventListener(MouseEvent.MOUSE_MOVE, orb.mouseMove);
orb.mouseMove(null);
}
private function endLevel():void{
var _local2:*;
var _local1:int = (bullets.length - 1);
var _local3:int;
while (_local3 < this.numChildren) {
_local2 = this.getChildAt(_local3);
if ((_local2 is Bullet)){
} else {
if ((_local2 is CandyBit)){
this.removeChild(_local2);
};
};
_local3++;
};
_local3 = 0;
while (_local3 <= _local1) {
Bullet(bullets[0]).destroy();
_local3++;
};
candyCounter.freeze();
var _local4:Number = 0;
if (levelTimer != null){
_local4 = levelTimer.timeLeft;
levelTimer.clear();
};
if (_local4 < 0){
_local4 = 0;
};
this.removeEventListener(MouseEvent.MOUSE_MOVE, orb.mouseMove);
this.levelOver = true;
Main.pushScreen(new SummaryScreen(this, title, leveltype, goal, _local4, candyCounter.total));
}
public function step():void{
var _local1:*;
var _local2:int;
while (_local2 < this.numChildren) {
_local1 = this.getChildAt(_local2);
if ((_local1 is Orb)){
Orb(_local1).step();
} else {
if ((_local1 is NewtonObject)){
NewtonObject(_local1).step();
};
};
_local2++;
};
if (this.levelOver){
return;
};
if (((orb.exploded) || (((!((levelTimer == null))) && (levelTimer.expired))))){
endLevel();
} else {
stepScript();
};
}
private function stepScript():void{
if (scriptIndex == -1){
return;
};
if (waitTime >= 1){
waitTime--;
return;
};
var _local1:XML = levelData.script.children()[scriptIndex];
if (_local1.localName() == "bullet"){
fireBullet((parseFloat(_local1.@angle) * Math.PI));
} else {
if (_local1.localName() == "pause"){
waitTime = (parseFloat(_local1.@length) * Main.STEP_RATE);
} else {
if (_local1.localName() == "loop"){
scriptIndex = (parseInt(_local1.@target) - 1);
} else {
if (_local1.localName() == "speech"){
if (levelTimer != null){
levelTimer.pause();
};
this.removeEventListener(MouseEvent.MOUSE_MOVE, orb.mouseMove);
Main.pushScreen(new SpeechPopup(this.leveltype, _local1.toString()));
};
};
};
};
scriptIndex++;
if (scriptIndex == levelData.script.children().length()){
scriptIndex = -1;
};
}
private function skipLevel(_arg1:MouseEvent):void{
this.leveltype = TYPE_DEMOLITION;
endLevel();
}
private function fireBullet(_arg1:Number):void{
var _local2:Number = (Math.sqrt(((Preloader.GAME_HEIGHT * Preloader.GAME_HEIGHT) + (Preloader.GAME_WIDTH * Preloader.GAME_WIDTH))) / 2);
var _local3:Point = SugarMath.Polar2Cartesian(_local2, _arg1);
var _local4:Bullet = new Bullet(this);
_local4.x = _local3.x;
_local4.y = _local3.y;
_local4.applyForce(_local4.getForceToward(0, 0, BULLET_SPEED));
this.addChild(_local4);
bullets.push(_local4);
SFX.fireBullet();
}
public function addCandy(_arg1:Number):void{
candyCounter.addCandy(_arg1);
}
}
}//package Screens
Section 59
//SpeechPopup (Screens.SpeechPopup)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import Interface.*;
import Util.*;
public class SpeechPopup extends Sprite {
private var field:TextField;
private var charCount:int;// = 0
private var text:String;
public static var portraitNoblewoman:Class = SpeechPopup_portraitNoblewoman;
public static var portraitMiner:Class = SpeechPopup_portraitMiner;
public static var portraitGeneral:Class = SpeechPopup_portraitGeneral;
public function SpeechPopup(_arg1:int, _arg2:String){
var _local3:Bitmap;
super();
graphics.lineStyle(3, 16737894);
graphics.beginFill(16764108, 0.95);
graphics.drawRoundRect(25, 350, 450, 100, 25);
graphics.endFill();
switch (_arg1){
case PlayScreen.TYPE_MINING:
_local3 = (new portraitMiner() as Bitmap);
break;
case PlayScreen.TYPE_DEMOLITION:
_local3 = (new portraitNoblewoman() as Bitmap);
break;
case PlayScreen.TYPE_SURVIVAL:
_local3 = (new portraitGeneral() as Bitmap);
break;
};
SugarGraphics.drawSprite(graphics, _local3.bitmapData, 40, 365);
field = new TextField();
field.defaultTextFormat = Font.BasicSelfDestruct;
field.embedFonts = true;
field.selectable = false;
field.x = 125;
field.y = 360;
field.width = 325;
field.height = 80;
field.wordWrap = true;
this.addChild(field);
this.text = _arg2;
Main.theMain.addEventListener(MouseEvent.CLICK, close);
}
public function update():void{
}
private function close(_arg1:MouseEvent):void{
Main.theMain.removeEventListener(MouseEvent.CLICK, close);
Main.popScreen();
}
public function step():void{
var _local1:int;
while (_local1 < 4) {
if (charCount >= text.length){
return;
};
field.appendText(text.charAt(charCount));
charCount++;
_local1++;
};
}
}
}//package Screens
Section 60
//SpeechPopup_portraitGeneral (Screens.SpeechPopup_portraitGeneral)
package Screens {
import mx.core.*;
public class SpeechPopup_portraitGeneral extends BitmapAsset {
}
}//package Screens
Section 61
//SpeechPopup_portraitMiner (Screens.SpeechPopup_portraitMiner)
package Screens {
import mx.core.*;
public class SpeechPopup_portraitMiner extends BitmapAsset {
}
}//package Screens
Section 62
//SpeechPopup_portraitNoblewoman (Screens.SpeechPopup_portraitNoblewoman)
package Screens {
import mx.core.*;
public class SpeechPopup_portraitNoblewoman extends BitmapAsset {
}
}//package Screens
Section 63
//SummaryScreen (Screens.SummaryScreen)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import Interface.*;
import Effects.*;
import Data.*;
public class SummaryScreen extends Sprite {
private var playScreen:PlayScreen;
private var successful:Boolean;// = false
public static const WIDTH:int = 400;
public static const HEIGHT:int = 200;
public function SummaryScreen(_arg1:PlayScreen, _arg2:String, _arg3:int, _arg4:int, _arg5:Number, _arg6:int){
Music.stopMusic();
this.playScreen = _arg1;
this.alpha = 0;
graphics.lineStyle(3, 16737894);
graphics.beginFill(16764108, 0.9);
graphics.drawRoundRect(0, 0, WIDTH, HEIGHT, 25);
graphics.endFill();
this.x = ((Preloader.GAME_WIDTH - WIDTH) / 2);
this.y = ((Preloader.GAME_HEIGHT - HEIGHT) / 2);
var _local7:TextField = new TextField();
_local7.defaultTextFormat = Font.BigSelfDestructCenter;
_local7.embedFonts = true;
_local7.width = WIDTH;
_local7.y = 10;
_local7.selectable = false;
_local7.text = _arg2;
this.addChild(_local7);
var _local8:TextField = new TextField();
_local8.defaultTextFormat = Font.BasicSelfDestruct;
_local8.embedFonts = true;
_local8.width = 350;
_local8.height = 100;
_local8.x = ((WIDTH - _local8.width) / 2);
_local8.y = 60;
_local8.selectable = false;
setSummaryText(_local8, _arg3, _arg4, _arg5, _arg6);
this.addChild(_local8);
var _local9:Button = new Button(175, 25, "Return to Level Select");
_local9.y = (HEIGHT - 35);
_local9.x = ((WIDTH - _local9.width) / 2);
_local9.addEventListener(MouseEvent.CLICK, returnToMenu);
this.addChild(_local9);
SaveData.saveLevel(_arg2, successful, _arg6);
}
private function setSummaryText(_arg1:TextField, _arg2:int, _arg3:int, _arg4:Number, _arg5:int):void{
switch (_arg2){
case PlayScreen.TYPE_MINING:
if (_arg3 <= _arg5){
successful = true;
};
break;
case PlayScreen.TYPE_DEMOLITION:
if (_arg4 > 0){
successful = true;
};
break;
case PlayScreen.TYPE_SURVIVAL:
if (_arg4 <= 0){
successful = true;
};
break;
};
if (successful){
_arg1.text = "SUCCESS!";
SFX.fanfare();
} else {
_arg1.text = "Try again...";
SFX.waahwaah();
};
_arg1.appendText(("\n\nCandy collected:\t\t\t\t" + _arg5));
if (_arg2 == PlayScreen.TYPE_MINING){
_arg1.appendText(("/" + _arg3));
};
_arg1.appendText((("\n\nTime remaining:\t\t\t\t" + _arg4.toFixed(1)) + "s"));
}
public function update():void{
}
private function returnToMenu(_arg1:MouseEvent):void{
Main.popScreen();
Main.popScreen();
}
public function step():void{
if (this.alpha < 1){
this.alpha = (this.alpha + 0.025);
};
playScreen.step();
}
}
}//package Screens
Section 64
//TitleScreen (Screens.TitleScreen)
package Screens {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import WorldObjects.*;
import Interface.*;
import Effects.*;
import Data.*;
public class TitleScreen extends Sprite {
public function TitleScreen(){
Music.startMusic(Music.bgmJolly);
var _local1:TextField = new TextField();
_local1.defaultTextFormat = Font.HugeSelfDestruct;
_local1.embedFonts = true;
_local1.width = 500;
_local1.x = 75;
_local1.y = 75;
_local1.text = "SUGARCORE";
_local1.selectable = false;
_local1.textColor = 16737894;
this.addChild(_local1);
var _local2:TextField = new TextField();
_local2.htmlText = "<a href=\"http://ludusnovus.net\" target=\"_blank\">by Gregory Weir - http://ludusnovus.net</a>";
_local2.textColor = 16724787;
_local2.x = 200;
_local2.y = 475;
_local2.width = 300;
_local2.setTextFormat(Font.BasicSelfDestruct);
_local2.embedFonts = true;
this.addChild(_local2);
var _local3:Button = new Button(100, 30, "Select Level");
_local3.x = (Preloader.GAME_WIDTH - 125);
_local3.y = 150;
this.addChild(_local3);
_local3.addEventListener(MouseEvent.CLICK, playClick);
var _local4:Button = new Button(100, 30, "Instructions");
_local4.x = (Preloader.GAME_WIDTH - 125);
_local4.y = 200;
this.addChild(_local4);
_local4.addEventListener(MouseEvent.CLICK, helpClick);
var _local5:Button = new Button(100, 30, "Credits");
_local5.x = (Preloader.GAME_WIDTH - 125);
_local5.y = 250;
this.addChild(_local5);
_local5.addEventListener(MouseEvent.CLICK, creditsClick);
var _local6:Orb = new Orb(null, LevelData.LevelM1.layers);
new Orb(null, LevelData.LevelM1.layers).width = (_local6.width / 2);
_local6.height = (_local6.height / 2);
_local6.x = 150;
_local6.y = 300;
_local6.rotation = 45;
this.addChild(_local6);
}
public function update():void{
}
public function step():void{
var _local1:*;
var _local2:int;
while (_local2 < this.numChildren) {
_local1 = this.getChildAt(_local2);
if ((_local1 is NewtonObject)){
NewtonObject(_local1).step();
};
_local2++;
};
}
private function creditsClick(_arg1:MouseEvent):void{
Main.pushScreen(new CreditsScreen());
}
private function playClick(_arg1:MouseEvent):void{
Main.pushScreen(new LevelSelectScreen());
}
private function helpClick(_arg1:MouseEvent):void{
Main.pushScreen(new HelpScreen());
}
}
}//package Screens
Section 65
//GilbertHitTest (Util.GilbertHitTest)
package Util {
import flash.display.*;
import flash.geom.*;
public class GilbertHitTest {
public static function getCollisionRect(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:DisplayObjectContainer, _arg4:Boolean=false, _arg5:Number=0):Rectangle{
var _local9:BitmapData;
var _local10:BitmapData;
var _local11:uint;
var _local12:Rectangle;
var _local13:int;
var _local6:Rectangle = _arg1.getBounds(_arg3);
var _local7:Rectangle = _arg2.getBounds(_arg3);
var _local8:Rectangle = _local6.intersection(_local7);
if (_local8.size.length > 0){
if (_arg4){
_local8.width = Math.ceil(_local8.width);
_local8.height = Math.ceil(_local8.height);
_local9 = getAlphaMap(_arg1, _local8, BitmapDataChannel.RED, _arg3);
_local10 = getAlphaMap(_arg2, _local8, BitmapDataChannel.GREEN, _arg3);
_local9.draw(_local10, null, null, BlendMode.LIGHTEN);
if (_arg5 <= 0){
_local11 = 65792;
} else {
if (_arg5 > 1){
_arg5 = 1;
};
_local13 = Math.round((_arg5 * 0xFF));
_local11 = (((_local13 << 16) | (_local13 << 8)) | 0);
};
_local12 = _local9.getColorBoundsRect(_local11, _local11);
_local9.getColorBoundsRect(_local11, _local11).x = (_local12.x + _local8.x);
_local12.y = (_local12.y + _local8.y);
return (_local12);
} else {
return (_local8);
};
//unresolved jump
};
return (null);
}
public static function isColliding(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:DisplayObjectContainer, _arg4:Boolean=false, _arg5:Number=0):Boolean{
var _local6:Rectangle = getCollisionRect(_arg1, _arg2, _arg3, _arg4, _arg5);
if (((!((_local6 == null))) && ((_local6.size.length > 0)))){
return (true);
};
return (false);
}
public static function getCollisionPoint(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:DisplayObjectContainer, _arg4:Boolean=false, _arg5:Number=0):Point{
var _local7:Number;
var _local8:Number;
var _local6:Rectangle = getCollisionRect(_arg1, _arg2, _arg3, _arg4, _arg5);
if (((!((_local6 == null))) && ((_local6.size.length > 0)))){
_local7 = ((_local6.left + _local6.right) / 2);
_local8 = ((_local6.top + _local6.bottom) / 2);
return (new Point(_local7, _local8));
};
return (null);
}
private static function getAlphaMap(_arg1:DisplayObject, _arg2:Rectangle, _arg3:uint, _arg4:DisplayObjectContainer):BitmapData{
var _local5:Matrix = _arg4.transform.concatenatedMatrix.clone();
_local5.invert();
var _local6:Matrix = _arg1.transform.concatenatedMatrix.clone();
_local6.concat(_local5);
_local6.translate(-(_arg2.x), -(_arg2.y));
var _local7:BitmapData = new BitmapData(_arg2.width, _arg2.height, true, 0);
_local7.draw(_arg1, _local6);
var _local8:BitmapData = new BitmapData(_arg2.width, _arg2.height, false, 0);
_local8.copyChannel(_local7, _local7.rect, new Point(0, 0), BitmapDataChannel.ALPHA, _arg3);
return (_local8);
}
}
}//package Util
Section 66
//SugarGraphics (Util.SugarGraphics)
package Util {
import flash.display.*;
import flash.geom.*;
public class SugarGraphics {
public static function drawSprite(_arg1:Graphics, _arg2:BitmapData, _arg3:int, _arg4:int, _arg5:Matrix=null):void{
if (_arg5 == null){
_arg5 = new Matrix();
};
_arg5.translate(_arg3, _arg4);
_arg1.beginBitmapFill(_arg2, _arg5);
_arg1.drawRect(_arg3, _arg4, _arg2.width, _arg2.height);
_arg1.endFill();
}
}
}//package Util
Section 67
//SugarMath (Util.SugarMath)
package Util {
import flash.geom.*;
public class SugarMath {
public static function Cartesian2Theta(_arg1:Number, _arg2:Number):Number{
return (Math.atan2(_arg2, _arg1));
}
public static function distance(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (Math.sqrt((((_arg1 - _arg3) * (_arg1 - _arg3)) + ((_arg2 - _arg4) * (_arg2 - _arg4)))));
}
public static function Degrees2Radians(_arg1:Number):Number{
return (((_arg1 / 360) * (2 * Math.PI)));
}
public static function randint(_arg1:int, _arg2:int):int{
if (_arg1 == _arg2){
return (_arg1);
};
var _local3:Number = Math.random();
var _local4:int = (Math.floor((_local3 * ((_arg2 - _arg1) + 1))) + _arg1);
if (_local4 > _arg2){
return (_arg2);
};
return (_local4);
}
public static function Polar2Cartesian(_arg1:Number, _arg2:Number):Point{
var _local3:Number = (Math.cos(_arg2) * _arg1);
var _local4:Number = (Math.sin(_arg2) * _arg1);
return (new Point(_local3, _local4));
}
public static function Radians2Degrees(_arg1:Number):Number{
return (((_arg1 / (2 * Math.PI)) * 360));
}
public static function getVectorBetween(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=NaN):Point{
var _local6:Point = new Point((_arg3 - _arg1), (_arg4 - _arg2));
if (!isNaN(_arg5)){
if (_arg5 < 0){
_local6.x = -(_local6.x);
_local6.y = -(_local6.y);
_arg5 = -(_arg5);
};
_local6.normalize(_arg5);
};
return (_local6);
}
}
}//package Util
Section 68
//AnnulusSector (WorldObjects.AnnulusSector)
package WorldObjects {
import flash.display.*;
import flash.geom.*;
import Screens.*;
import Util.*;
import Effects.*;
public class AnnulusSector extends NewtonObject {
private var angularWidth:Number;
private var innerRadius:Number;
private var value:Number;// = 0
private var startingAngle:Number;
private var outerRadius:Number;
private var myColor:uint;
private var type:int;
public static const COLOR_CHOCOLATE:uint = 0x552200;
public static const TYPE_CANDY:int = 0;
public static const TYPE_CHOCOLATE:int = 1;
public static const TYPE_VOID:int = 2;
public static const TYPE_ARMOR:int = 3;
private static var texChoco:Class = AnnulusSector_texChoco;
private static var texArmor:Class = AnnulusSector_texArmor;
public function AnnulusSector(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint, _arg6:Number, _arg7:PlayScreen, _arg8:int=0){
super(_arg7);
this.type = _arg8;
if (this.type != TYPE_CHOCOLATE){
this.value = (_arg6 * 5);
};
this.innerRadius = _arg1;
this.outerRadius = _arg2;
this.startingAngle = _arg3;
this.angularWidth = _arg4;
this.myColor = _arg5;
this.playScreen = _arg7;
this.drawSector();
}
public function getCenterPoint(_arg1:Boolean=true):Point{
if (_arg1){
return (SugarMath.Polar2Cartesian(((innerRadius + outerRadius) / 2), ((startingAngle + (angularWidth / 2)) + SugarMath.Degrees2Radians(this.parent.rotation))));
};
return (SugarMath.Polar2Cartesian(((innerRadius + outerRadius) / 2), (startingAngle + (angularWidth / 2))));
}
private function drawSector():void{
var _local4:Matrix;
var _local5:ColorTransform;
var _local1:Point = SugarMath.Polar2Cartesian(innerRadius, startingAngle);
var _local2:Matrix = new Matrix();
_local2.rotate((startingAngle + (angularWidth / 2)));
graphics.moveTo(_local1.x, _local1.y);
graphics.lineStyle(2, 0);
if (type == TYPE_CHOCOLATE){
graphics.beginBitmapFill((new texChoco() as Bitmap).bitmapData, _local2);
} else {
if (type == TYPE_ARMOR){
graphics.beginBitmapFill((new texArmor() as Bitmap).bitmapData, _local2);
} else {
_local4 = new Matrix();
_local4.createGradientBox((outerRadius * 2), (outerRadius * 2), 0, -(outerRadius), -(outerRadius));
_local5 = new ColorTransform();
_local5.color = myColor;
_local5.redOffset = Math.max((_local5.redOffset - 68), 0);
_local5.blueOffset = Math.max((_local5.blueOffset - 68), 0);
_local5.greenOffset = Math.max((_local5.greenOffset - 68), 0);
graphics.beginGradientFill(GradientType.RADIAL, [myColor, _local5.color], [1, 1], [(0xFF * (innerRadius / outerRadius)), 0xFF], _local4);
};
};
var _local3:Number = startingAngle;
while (_local3 < ((startingAngle + angularWidth) + 0.0001)) {
_local1 = SugarMath.Polar2Cartesian(outerRadius, _local3);
graphics.lineTo(_local1.x, _local1.y);
_local3 = (_local3 + (angularWidth / SUBDIVISIONS));
};
_local3 = (startingAngle + angularWidth);
while (_local3 > (startingAngle - 0.0001)) {
_local1 = SugarMath.Polar2Cartesian(innerRadius, _local3);
graphics.lineTo(_local1.x, _local1.y);
_local3 = (_local3 - (angularWidth / SUBDIVISIONS));
};
graphics.endFill();
}
override public function step():void{
var _local1:Bullet;
super.step();
var _local2:int;
while (_local2 < playScreen.bullets.length) {
_local1 = Bullet(playScreen.bullets[_local2]);
if (GilbertHitTest.isColliding(this, _local1, playScreen, true, 0xFF)){
this.getHit(_local1);
};
_local2++;
};
}
private function get SUBDIVISIONS():int{
if (angularWidth >= (Math.PI / 2)){
return (16);
};
return (4);
}
private function getHit(_arg1:Bullet):void{
var _local2:Point;
var _local3:CandyBit;
var _local4:int;
var _local5:int;
if (this.type == TYPE_CHOCOLATE){
Orb(this.parent).replaceChocolate(this);
SFX.squirt();
this.destroy();
} else {
if (this.type == TYPE_ARMOR){
SFX.tink();
} else {
_local2 = getCenterPoint();
_local4 = (value / 20);
if (_local4 > 5){
_local4 = 5;
};
if ((((_local4 <= 0)) && ((value > 0)))){
_local4 = 1;
};
_local5 = 0;
while (_local5 < _local4) {
_local3 = new CandyBit(_local2.x, _local2.y, myColor, playScreen, (value / _local4));
_local3.applyForce(new Point(((Math.random() * 10) - 5), Math.random()));
this.parent.parent.addChild(_local3);
_local5++;
};
Orb(this.parent).removeSector(this);
SFX.shatter();
this.destroy();
};
};
_arg1.destroy();
}
}
}//package WorldObjects
Section 69
//AnnulusSector_texArmor (WorldObjects.AnnulusSector_texArmor)
package WorldObjects {
import mx.core.*;
public class AnnulusSector_texArmor extends BitmapAsset {
}
}//package WorldObjects
Section 70
//AnnulusSector_texChoco (WorldObjects.AnnulusSector_texChoco)
package WorldObjects {
import mx.core.*;
public class AnnulusSector_texChoco extends BitmapAsset {
}
}//package WorldObjects
Section 71
//Bullet (WorldObjects.Bullet)
package WorldObjects {
import flash.display.*;
import Screens.*;
import Util.*;
public class Bullet extends NewtonObject {
private static var spriteBullet:Class = Bullet_spriteBullet;
public function Bullet(_arg1:PlayScreen){
super(_arg1);
var _local2:BitmapData = (new spriteBullet() as Bitmap).bitmapData;
SugarGraphics.drawSprite(graphics, _local2, 0, -((_local2.height / 2)));
}
override public function destroy():void{
playScreen.bullets.splice(playScreen.bullets.indexOf(this), 1);
this.parent.removeChild(this);
}
override public function step():void{
this.rotation = SugarMath.Radians2Degrees(SugarMath.Cartesian2Theta(velocity.x, velocity.y));
super.step();
}
}
}//package WorldObjects
Section 72
//Bullet_spriteBullet (WorldObjects.Bullet_spriteBullet)
package WorldObjects {
import mx.core.*;
public class Bullet_spriteBullet extends BitmapAsset {
}
}//package WorldObjects
Section 73
//CandyBit (WorldObjects.CandyBit)
package WorldObjects {
import Screens.*;
import Util.*;
import Effects.*;
public class CandyBit extends NewtonObject {
private var value:Number;
private var color:uint;
public function CandyBit(_arg1:int, _arg2:int, _arg3:uint, _arg4:PlayScreen, _arg5:Number=10){
this.x = _arg1;
this.y = _arg2;
this.value = _arg5;
graphics.lineStyle(1, _arg3);
graphics.beginFill(_arg3, 0.5);
graphics.moveTo(-8, -8);
graphics.lineTo(0, -2);
graphics.lineTo(8, -8);
graphics.lineTo(2, 0);
graphics.lineTo(8, 8);
graphics.lineTo(0, 2);
graphics.lineTo(-8, 8);
graphics.lineTo(-2, 0);
graphics.lineTo(-8, -8);
graphics.endFill();
this.rotation = (90 * Math.random());
super(_arg4);
}
override public function step():void{
if ((((((x > (Preloader.GAME_WIDTH / 2))) || ((y > (Preloader.GAME_HEIGHT / 2))))) || (GilbertHitTest.isColliding(playScreen.candyCounter, this, playScreen)))){
SFX.collect();
playScreen.addCandy(this.value);
this.destroy();
};
this.applyForce(getForceToward(playScreen.collectPoint.x, playScreen.collectPoint.y, 2));
super.step();
}
}
}//package WorldObjects
Section 74
//Cloud (WorldObjects.Cloud)
package WorldObjects {
import flash.display.*;
import flash.geom.*;
import Util.*;
public class Cloud extends NewtonObject {
private static var spriteCloud:Class = Cloud_spriteCloud;
public function Cloud(){
super(null);
var _local1:Bitmap = (new spriteCloud() as Bitmap);
SugarGraphics.drawSprite(graphics, _local1.bitmapData, 0, 0);
this.velocity = new Point((Math.random() - 0.5), 0);
}
override public function step():void{
super.step();
if ((((this.x < 0)) || ((this.x > Preloader.GAME_WIDTH)))){
this.velocity.x = (0 - this.velocity.x);
};
}
}
}//package WorldObjects
Section 75
//Cloud_spriteCloud (WorldObjects.Cloud_spriteCloud)
package WorldObjects {
import mx.core.*;
public class Cloud_spriteCloud extends BitmapAsset {
}
}//package WorldObjects
Section 76
//Core (WorldObjects.Core)
package WorldObjects {
import flash.display.*;
import flash.geom.*;
import Screens.*;
import Util.*;
import Effects.*;
public class Core extends NewtonObject {
public function Core(_arg1:Number, _arg2:int, _arg3:int, _arg4:PlayScreen){
super(_arg4);
var _local5:Matrix = new Matrix();
_local5.createGradientBox((_arg1 * 2), (_arg1 * 2), 0, -(_arg1), -(_arg1));
graphics.lineStyle(2, 0);
graphics.beginGradientFill(GradientType.RADIAL, [_arg3, _arg2], [1, 1], [100, 0xFF], _local5);
graphics.drawCircle(0, 0, _arg1);
graphics.endFill();
}
override public function step():void{
var _local1:Bullet;
var _local2:int;
while (_local2 < playScreen.bullets.length) {
_local1 = Bullet(playScreen.bullets[_local2]);
if (GilbertHitTest.isColliding(this, _local1, playScreen, true, 0xFF)){
this.getHit(_local1);
};
_local2++;
};
}
private function getHit(_arg1:Bullet):void{
SFX.boom();
_arg1.destroy();
Orb(this.parent).explode();
this.destroy();
}
}
}//package WorldObjects
Section 77
//NewtonObject (WorldObjects.NewtonObject)
package WorldObjects {
import flash.display.*;
import flash.geom.*;
import Screens.*;
import Util.*;
public class NewtonObject extends Sprite {
protected var playScreen:PlayScreen;
private var _velocity:Point;
public function NewtonObject(_arg1:PlayScreen){
_velocity = new Point(0, 0);
super();
this.playScreen = _arg1;
}
public function destroy():void{
this.parent.removeChild(this);
}
public function step():void{
this.x = (this.x + _velocity.x);
this.y = (this.y + _velocity.y);
if ((((Math.abs(this.x) > (Preloader.GAME_WIDTH + 100))) || ((Math.abs(this.y) > (Preloader.GAME_WIDTH + 100))))){
destroy();
};
}
public function applyForce(_arg1:Point):void{
_velocity = _velocity.add(_arg1);
}
public function set velocity(_arg1:Point):void{
_velocity = _arg1;
}
public function getForceToward(_arg1:Number, _arg2:Number, _arg3:Number):Point{
return (SugarMath.getVectorBetween(this.x, this.y, _arg1, _arg2, _arg3));
}
public function get velocity():Point{
return (_velocity);
}
}
}//package WorldObjects
Section 78
//Orb (WorldObjects.Orb)
package WorldObjects {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import Screens.*;
import Util.*;
public class Orb extends Sprite {
private var playScreen:PlayScreen;
public var exploded:Boolean;// = false
private var chocoFlow:Array;
public var sectors:Array;
private var sectorThickness:Number;
public function Orb(_arg1:PlayScreen, _arg2:XMLList){
var _local8:Number;
super();
this.playScreen = _arg1;
sectors = new Array();
chocoFlow = new Array();
var _local3:int = _arg2.layer.length();
sectorThickness = (125 / _local3);
graphics.lineStyle(2, 0);
graphics.beginFill(0x666666);
graphics.drawCircle(0, 0, ((_local3 + 1) * sectorThickness));
graphics.endFill();
var _local4:int;
while (_local4 < _local3) {
sectors[_local4] = new Array();
_local8 = ((_local3 - _local4) * sectorThickness);
addLayer(_arg2.layer[_local4], _local8, (_local8 + sectorThickness), sectors[_local4]);
_local4++;
};
var _local5:Core = new Core(sectorThickness, 0xCC0000, 0xFF0000, _arg1);
this.addChild(_local5);
var _local6:Sprite = new Sprite();
_local6.graphics.moveTo(0, 0);
_local6.graphics.lineStyle(3, 0);
var _local7:Point = SugarMath.Polar2Cartesian((sectorThickness * (_local3 + 2)), 0);
_local6.graphics.lineTo(_local7.x, _local7.y);
this.addChild(_local6);
}
public function explode():void{
var _local1:*;
var _local2:Point;
this.exploded = true;
var _local3:int;
while (_local3 < this.numChildren) {
_local1 = this.getChildAt(_local3);
if ((_local1 is AnnulusSector)){
_local2 = AnnulusSector(_local1).getCenterPoint(false);
NewtonObject(_local1).applyForce(SugarMath.getVectorBetween(0, 0, _local2.x, _local2.y, 10));
};
_local3++;
};
this.chocoFlow = new Array();
}
private function expandChocolate(_arg1:AnnulusSector):void{
var _local2:int;
var _local3:Array;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local4:int;
while (_local4 < sectors.length) {
_local3 = sectors[_local4];
_local2 = _local3.indexOf(_arg1);
if (_local2 != -1){
if (sectors[_local4][((_local2 + 1) % _local3.length)] == null){
addNewChoco(_local4, ((_local2 + 1) % _local3.length));
};
if (sectors[_local4][(((_local2 - 1) + _local3.length) % _local3.length)] == null){
addNewChoco(_local4, (((_local2 - 1) + _local3.length) % _local3.length));
};
if (_local4 > 0){
_local5 = Math.floor(((Number(_local2) / Number(_local3.length)) * sectors[(_local4 - 1)].length));
_local6 = Math.floor(((Number((_local2 + 1)) / Number(_local3.length)) * sectors[(_local4 - 1)].length));
_local7 = _local5;
while (_local7 <= _local6) {
if (sectors[(_local4 - 1)][(_local7 % sectors[(_local4 - 1)].length)] == null){
addNewChoco((_local4 - 1), (_local7 % sectors[(_local4 - 1)].length));
};
_local7++;
};
};
if (_local4 < (sectors.length - 1)){
_local8 = Math.floor(((Number(_local2) / Number(_local3.length)) * sectors[(_local4 + 1)].length));
_local9 = Math.floor(((Number((_local2 + 1)) / Number(_local3.length)) * sectors[(_local4 + 1)].length));
_local10 = _local8;
while (_local10 <= _local9) {
if (sectors[(_local4 + 1)][(_local10 % sectors[(_local4 + 1)].length)] == null){
addNewChoco((_local4 + 1), (_local10 % sectors[(_local4 + 1)].length));
};
_local10++;
};
};
};
_local4++;
};
}
public function removeSector(_arg1:AnnulusSector):void{
var _local2:int;
var _local3:Array;
var _local4:int;
while (_local4 < sectors.length) {
_local3 = sectors[_local4];
_local2 = _local3.indexOf(_arg1);
if (_local2 != -1){
sectors[_local4][_local2] = null;
};
_local4++;
};
}
public function step():void{
var _local1:*;
if (chocoFlow.length > 0){
expandChocolate(chocoFlow.shift());
};
var _local2:int;
while (_local2 < this.numChildren) {
_local1 = this.getChildAt(_local2);
if ((_local1 is AnnulusSector)){
AnnulusSector(_local1).step();
} else {
if ((_local1 is Core)){
Core(_local1).step();
};
};
_local2++;
};
}
public function replaceChocolate(_arg1:AnnulusSector):void{
var _local2:int;
var _local3:Array;
var _local4:AnnulusSector;
var _local5:Number;
var _local6:Number;
var _local7:int;
while (_local7 < sectors.length) {
_local3 = sectors[_local7];
_local2 = _local3.indexOf(_arg1);
if (_local2 != -1){
_local5 = ((sectors.length - _local7) * sectorThickness);
_local6 = ((2 * Math.PI) / _local3.length);
_local4 = new AnnulusSector(_local5, (_local5 + sectorThickness), (_local6 * _local2), _local6, AnnulusSector.COLOR_CHOCOLATE, 1, playScreen);
sectors[_local7][_local2] = _local4;
this.addChild(_local4);
chocoFlow.push(_local4);
};
_local7++;
};
}
private function addLayer(_arg1:XML, _arg2:Number, _arg3:Number, _arg4:Array):void{
var _local9:AnnulusSector;
var _local10:uint;
var _local11:int;
var _local12:int;
var _local5:int = _arg1.sector.length();
var _local6:Number = ((2 * Math.PI) / _local5);
var _local7:uint = parseInt(_arg1.@color);
var _local8:int = parseInt(_arg1.@value);
var _local13:Number = 0;
for (;_local13 < _local5;_local13++) {
if (_arg1.sector[_local13].@color.length() == 0){
_local10 = _local7;
} else {
_local10 = parseInt(_arg1.sector[_local13].@color);
};
if (_arg1.sector[_local13].@value.length() == 0){
_local11 = _local8;
} else {
_local11 = parseInt(_arg1.sector[_local13].@value);
};
if (_arg1.sector[_local13].@type.length() == 0){
_local12 = AnnulusSector.TYPE_CANDY;
} else {
if (_arg1.sector[_local13].@type == AnnulusSector.TYPE_VOID){
_arg4[_local13] = null;
continue;
};
_local12 = parseInt(_arg1.sector[_local13].@type);
};
_local9 = new AnnulusSector(_arg2, _arg3, (_local13 * _local6), _local6, _local10, _local11, playScreen, _local12);
_arg4[_local13] = _local9;
this.addChild(_local9);
};
}
public function mouseMove(_arg1:MouseEvent):void{
var _local2:Number;
if (!this.exploded){
_local2 = SugarMath.Cartesian2Theta(mouseX, mouseY);
this.rotation = (this.rotation + SugarMath.Radians2Degrees(_local2));
};
}
private function addNewChoco(_arg1:int, _arg2:int):void{
var _local3:Number = ((2 * Math.PI) / sectors[_arg1].length);
var _local4:Number = ((sectors.length - _arg1) * sectorThickness);
var _local5:AnnulusSector = new AnnulusSector(_local4, (_local4 + sectorThickness), (_local3 * _arg2), _local3, AnnulusSector.COLOR_CHOCOLATE, 1, playScreen);
sectors[_arg1][_arg2] = _local5;
this.addChild(_local5);
chocoFlow.push(_local5);
}
}
}//package WorldObjects
Section 79
//Main (Main)
package {
import flash.display.*;
import flash.events.*;
import Screens.*;
import com.kongregate.as3.client.*;
import WorldObjects.*;
import Interface.*;
import Util.*;
import flash.utils.*;
public class Main extends Sprite {
public static const STEP_RATE:int = 30;
public static var theMain:Main;
protected static var screenStack:Array = new Array();
public function Main(){
theMain = this;
if (stage){
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init);
};
}
private function init(_arg1:Event=null):void{
var _local5:Cloud;
removeEventListener(Event.ADDED_TO_STAGE, init);
MochiBot.track(this, "e9441885");
var _local2:KongregateAPI = new KongregateAPI();
this.addChild(_local2);
var _local3:MusicToggle = new MusicToggle();
_local3.x = 8;
_local3.y = (Preloader.GAME_HEIGHT - 24);
parent.addChild(_local3);
var _local4:SoundToggle = new SoundToggle();
_local4.x = 32;
_local4.y = (Preloader.GAME_HEIGHT - 24);
parent.addChild(_local4);
graphics.beginFill(13434879);
graphics.drawRect(0, 0, Preloader.GAME_WIDTH, Preloader.GAME_HEIGHT);
graphics.endFill();
var _local6:int;
while (_local6 < 5) {
_local5 = new Cloud();
_local5.x = SugarMath.randint(0, (Preloader.GAME_WIDTH - _local5.width));
_local5.y = ((Preloader.GAME_HEIGHT / 5) * _local6);
this.addChild(_local5);
_local6++;
};
var _local7:TitleScreen = new TitleScreen();
screenStack.push(_local7);
this.addChild(_local7);
var _local8:Timer = new Timer((1000 / STEP_RATE));
_local8.addEventListener(TimerEvent.TIMER, frameLoop);
_local8.start();
}
public function frameLoop(_arg1:TimerEvent):void{
var _local2:*;
screenStack[(screenStack.length - 1)].step();
var _local3:int;
while (_local3 < this.numChildren) {
_local2 = this.getChildAt(_local3);
if ((_local2 is NewtonObject)){
NewtonObject(_local2).step();
};
_local3++;
};
}
public static function popScreen():void{
screenStack[(screenStack.length - 2)].visible = true;
theMain.removeChild(screenStack.pop());
screenStack[(screenStack.length - 1)].update();
}
public static function pushScreen(_arg1:Sprite):void{
if (((!((_arg1 is SpeechPopup))) && (!((_arg1 is SummaryScreen))))){
screenStack[(screenStack.length - 1)].visible = false;
};
screenStack.push(_arg1);
theMain.addChild(_arg1);
if ((_arg1 is LevelSelectScreen)){
LevelSelectScreen(_arg1).update();
};
}
}
}//package
Section 80
//MochiAd (MochiAd)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.6");
}
public static function showClickAwayAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
var sendHostProgress:Boolean;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var clip:Object;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
var depth:Number = options.depth;
delete options.depth;
var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array = _arg2.split(".");
var _local4:Number = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local7:Number = ((100 * _local6) / _local5);
var _local8:Number = ((100 * _local3) / chk.ad_msec);
var _local9:Object = this._mochiad_bar._inside;
var _local10:Number = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
options.ad_progress(_local10);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local7});
if (_local7 == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local11 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local11 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local7 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var mc = _arg1;
var f:Function = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 81
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.system.*;
import flash.net.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
if (Security.sandboxType == "localWithFile"){
return (null);
};
var _local3:MochiBot = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
var _local4 = "http://core.mochibot.com/my/core.swf";
var _local5:URLVariables = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
var _local6:String = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
var _local7:URLRequest = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
var _local8:Loader = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 82
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import mochi.as3.*;
import flash.utils.*;
public dynamic class Preloader extends MovieClip {
private var loadText:TextField;
public static const GAME_WIDTH:int = 500;
public static const GAME_HEIGHT:int = 500;
public function Preloader(){
stage.stageWidth = GAME_WIDTH;
stage.stageHeight = GAME_HEIGHT;
stage.scaleMode = StageScaleMode.NO_SCALE;
MochiAd.showPreGameAd({clip:root, id:"60f7199bdd383df2", res:"500x500", background:16767706, color:16750230, outline:16726329, no_bg:false, ad_started:adStarted, ad_finished:init});
}
private function init():void{
addEventListener(Event.ENTER_FRAME, checkFrame);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);
loadText = new TextField();
loadText.textColor = 0xFFFFFF;
loadText.text = "Loading...";
loadText.y = (GAME_HEIGHT / 2);
loadText.x = ((GAME_WIDTH - loadText.width) / 2);
this.addChild(loadText);
}
public function onConnectError(_arg1:String):void{
}
private function checkProgress(_arg1:ProgressEvent):void{
loadText.text = (("Loading... " + int(((_arg1.bytesLoaded / _arg1.bytesTotal) * 100))) + "%");
}
private function checkFrame(_arg1:Event):void{
if (currentFrame == totalFrames){
removeEventListener(Event.ENTER_FRAME, checkFrame);
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
startup();
};
}
private function startup():void{
this.removeChild(loadText);
loadText = null;
stop();
MochiServices.connect("60f7199bdd383df2", root, onConnectError);
var _local1:Class = (getDefinitionByName("Main") as Class);
addChild((new (_local1) as DisplayObject));
}
public function adStarted():void{
}
}
}//package