Section 1
//MochiScores (mochi.MochiScores)
package mochi {
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 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;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.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 _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
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{
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
Section 2
//MochiServices (mochi.MochiServices)
package mochi {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _sendChannel:LocalConnection;
private static var _rcvChannelName:String;
private static var _gatewayURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _startTime:Number;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__mochiservices";
private static var _rcvChannel:LocalConnection;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
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++;
};
};
}
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);
};
};
};
};
};
}
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);
}
public static function get id():String{
return (_id);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function getVersion():String{
return ("1.31");
}
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();
_rcvChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
return (_local2);
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
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 onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
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()});
_rcvChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = 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");
};
_rcvChannel.connect(_rcvChannelName);
trace("connected!");
_connecting = false;
_connected = true;
_listenChannel.close();
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...");
}
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 (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) {
};
};
};
};
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
_rcvChannelName = _arg1;
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
MochiServices.allowDomains(_gatewayURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
_timer = new Timer(1000, 0);
_startTime = getTimer();
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_gatewayURL);
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_rcvChannel = new LocalConnection();
_rcvChannel.allowDomain("*", "localhost");
_rcvChannel.allowInsecureDomain("*", "localhost");
_rcvChannel.client = _clip;
_clip._nextcallbackID = 0;
_clip._callbacks = {};
listen();
return (_clip);
}
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 mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = 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 ((getTimer() - _startTime) > 10000){
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_timer.stop();
};
}
}
}//package mochi
Section 3
//bord_22 (ScaryCircle_fla.bord_22)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class bord_22 extends MovieClip {
public var splash:MovieClip;
}
}//package ScaryCircle_fla
Section 4
//grey_28 (ScaryCircle_fla.grey_28)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class grey_28 extends MovieClip {
public var order:MovieClip;
}
}//package ScaryCircle_fla
Section 5
//gubbe_52 (ScaryCircle_fla.gubbe_52)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class gubbe_52 extends MovieClip {
public function gubbe_52(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package ScaryCircle_fla
Section 6
//l_39 (ScaryCircle_fla.l_39)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class l_39 extends MovieClip {
public var flame_mc:MovieClip;
}
}//package ScaryCircle_fla
Section 7
//l_4 (ScaryCircle_fla.l_4)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class l_4 extends MovieClip {
public var flame_mc:MovieClip;
}
}//package ScaryCircle_fla
Section 8
//ljus_2 (ScaryCircle_fla.ljus_2)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class ljus_2 extends MovieClip {
public var ljustake_mc:MovieClip;
public var flameHit_mc:MovieClip;
public var inreLjus_mc:MovieClip;
}
}//package ScaryCircle_fla
Section 9
//ljus_37 (ScaryCircle_fla.ljus_37)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class ljus_37 extends MovieClip {
public var ljustake_mc:MovieClip;
public var flameHit_mc:MovieClip;
public var inreLjus_mc:MovieClip;
}
}//package ScaryCircle_fla
Section 10
//orange_29 (ScaryCircle_fla.orange_29)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class orange_29 extends MovieClip {
public var order:MovieClip;
}
}//package ScaryCircle_fla
Section 11
//purple_25 (ScaryCircle_fla.purple_25)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class purple_25 extends MovieClip {
public var order:MovieClip;
}
}//package ScaryCircle_fla
Section 12
//red_27 (ScaryCircle_fla.red_27)
package ScaryCircle_fla {
import flash.display.*;
public dynamic class red_27 extends MovieClip {
public var order:MovieClip;
}
}//package ScaryCircle_fla
Section 13
//Bkg (Bkg)
package {
import flash.display.*;
public dynamic class Bkg extends MovieClip {
}
}//package
Section 14
//btn (btn)
package {
import flash.media.*;
public dynamic class btn extends Sound {
}
}//package
Section 15
//Chef (Chef)
package {
import flash.display.*;
public dynamic class Chef extends MovieClip {
}
}//package
Section 16
//Circle (Circle)
package {
import flash.display.*;
public class Circle extends MovieClip {
public var purpleSmoke:MovieClip;
public var greyCenter:MovieClip;
var rad:Number;// = 0
public var orangeCenter:MovieClip;
public var orange:MovieClip;
public var purpleCenter:MovieClip;
public var greyTable:MovieClip;
public var redSmoke:MovieClip;
public var purpleTable:MovieClip;
public var red:MovieClip;
public var redCenter:MovieClip;
public var redTable:MovieClip;
public var greySmoke:MovieClip;
public var purple:MovieClip;
var stageref;
public var orangeTable:MovieClip;
public var orangeSmoke:MovieClip;
public var grey:MovieClip;
public var black:MovieClip;
public function Circle(_arg1){
rad = 0;
super();
stageref = _arg1;
this.x = 250;
this.y = 240;
}
public function update(){
rad = Math.atan2((this.y - stageref.mouseY), (this.x - stageref.mouseX));
this.rotation = ((rad * 180) / Math.PI);
}
}
}//package
Section 17
//eat (eat)
package {
import flash.media.*;
public dynamic class eat extends Sound {
}
}//package
Section 18
//food (food)
package {
import flash.media.*;
public dynamic class food extends Sound {
}
}//package
Section 19
//Gui (Gui)
package {
import flash.display.*;
import flash.text.*;
public dynamic class Gui extends MovieClip {
public var level_tf:TextField;
public var fail_tf:TextField;
public var score_tf:TextField;
public var win_tf:TextField;
}
}//package
Section 20
//Instructions (Instructions)
package {
import flash.display.*;
public dynamic class Instructions extends MovieClip {
public var closeBtn:SimpleButton;
}
}//package
Section 21
//levelup (levelup)
package {
import flash.media.*;
public dynamic class levelup extends Sound {
}
}//package
Section 22
//LevelUp_ani (LevelUp_ani)
package {
import flash.display.*;
public dynamic class LevelUp_ani extends MovieClip {
}
}//package
Section 23
//Main (Main)
package {
import flash.display.*;
import flash.events.*;
import mochi.*;
import flash.net.*;
public dynamic class Main extends MovieClip {
private var failCounter:int;// = 0
private var levelUp_ani:LevelUp_ani;
public var sound:SoundHandler;
private var pickupIterator:int;// = 0
private var gui:Gui;
private var bkg:Bkg;
private var winLimit:int;// = 20
private var redOrder:int;// = 1
private var failLimit:int;// = 25
private var speed:Number;// = 3
private var amountOfTypes:int;// = 2
private var level:int;// = 1
private var spawnTimer:int;// = 0
private var winCounter:int;// = 0
private var pickups:Array;
private var score:int;// = 0
private var spawnInterval:int;// = 40
private var instructions:Instructions;
private var greyOrder:int;// = 1
private var spelgrimAnimation:SpelgrimAnimation;
private var chef:Chef;
private var orangeOrder:int;// = 1
private var circle:Circle;
private var purpleOrder:int;// = 1
private var isPaused:Boolean;// = false
public function Main(){
var _local1:int;
var _local2:String;
spelgrimAnimation = new SpelgrimAnimation();
chef = new Chef();
instructions = new Instructions();
gui = new Gui();
pickups = new Array();
isPaused = false;
orangeOrder = 1;
greyOrder = 1;
purpleOrder = 1;
redOrder = 1;
spawnTimer = 0;
pickupIterator = 0;
failCounter = 0;
winCounter = 0;
spawnInterval = 40;
amountOfTypes = 2;
failLimit = 25;
winLimit = 20;
level = 1;
speed = 3;
score = 0;
levelUp_ani = new LevelUp_ani();
bkg = new Bkg();
sound = new SoundHandler();
super();
MochiServices.connect("bfb643577dbf9827", this);
_local1 = 0;
while (_local1 < levelUp_ani.numChildren) {
levelUp_ani.getChildAt(_local1).cacheAsBitmap = true;
_local1++;
};
_local2 = "LOGO";
switch (_local2){
case "BOTH":
spelgrimAnimation.stop();
MochiAd.showPreGameAd({clip:root, id:"bfb643577dbf9827", res:"640x480", background:0, color:0xCCCCCC, outline:0xFF6600, no_bg:true, ad_finished:this.adFinished});
MochiBot.track(this, "c568e16e");
break;
case "AD":
MochiAd.showPreGameAd({clip:root, id:"bfb643577dbf9827", res:"640x480", background:0, color:0xCCCCCC, outline:0xFF6600, no_bg:true});
MochiBot.track(this, "c568e16e");
break;
case "LOGO":
spelgrimAnimation.stop();
adFinished();
break;
default:
setupMainMenu();
break;
};
}
private function startBtnClick(_arg1:MouseEvent){
sound.startSound("btn", 0.8, 0);
removeMainMenu();
init();
}
private function init(){
score = 0;
circle = new Circle(this);
addChild(circle);
circle.cacheAsBitmap = true;
addChild(gui);
isPaused = false;
circle.orangeSmoke.gotoAndStop(1);
circle.greySmoke.gotoAndStop(1);
circle.purpleSmoke.gotoAndStop(1);
circle.redSmoke.gotoAndStop(1);
addChild(chef);
chef.x = 250;
chef.y = 240;
addEventListener(Event.ENTER_FRAME, EnterFrame, false, 0, true);
orangeOrder = newOrder();
circle.orange.order.gotoAndStop(orangeOrder);
greyOrder = newOrder();
circle.grey.order.gotoAndStop(greyOrder);
purpleOrder = newOrder();
circle.purple.order.gotoAndStop(purpleOrder);
redOrder = newOrder();
circle.red.order.gotoAndStop(redOrder);
}
private function checkCollision(_arg1:Pickup, _arg2){
if (circle.orange.hitTestPoint(_arg1.x, _arg1.y, true)){
if (orangeOrder == _arg1.getType()){
orangeOrder = newOrder();
circle.orange.order.gotoAndStop(orangeOrder);
circle.orangeTable.splash.alpha = (circle.orangeTable.splash.alpha + 0.02);
increWin();
if (circle.orangeCenter.hitTestPoint(_arg1.x, _arg1.y, true)){
score = (score + (10 * level));
} else {
score = (score + (5 * level));
};
circle.orangeSmoke.gotoAndPlay(2);
} else {
increFail(1);
};
removeChild(pickups[_arg2]);
pickups.splice(_arg2, 1);
};
if (circle.grey.hitTestPoint(_arg1.x, _arg1.y, true)){
if (greyOrder == _arg1.getType()){
greyOrder = newOrder();
circle.grey.order.gotoAndStop(greyOrder);
circle.greyTable.splash.alpha = (circle.greyTable.splash.alpha + 0.02);
increWin();
if (circle.greyCenter.hitTestPoint(_arg1.x, _arg1.y, true)){
score = (score + (10 * level));
} else {
score = (score + (5 * level));
};
circle.greySmoke.gotoAndPlay(2);
} else {
increFail(1);
};
removeChild(pickups[_arg2]);
pickups.splice(_arg2, 1);
};
if (circle.purple.hitTestPoint(_arg1.x, _arg1.y, true)){
if (purpleOrder == _arg1.getType()){
purpleOrder = newOrder();
circle.purple.order.gotoAndStop(purpleOrder);
circle.purpleTable.splash.alpha = (circle.purpleTable.splash.alpha + 0.02);
increWin();
if (circle.purpleCenter.hitTestPoint(_arg1.x, _arg1.y, true)){
score = (score + (10 * level));
} else {
score = (score + (5 * level));
};
circle.purpleSmoke.gotoAndPlay(2);
} else {
increFail(1);
};
removeChild(pickups[_arg2]);
pickups.splice(_arg2, 1);
};
if (circle.red.hitTestPoint(_arg1.x, _arg1.y, true)){
if (redOrder == _arg1.getType()){
redOrder = newOrder();
circle.red.order.gotoAndStop(redOrder);
circle.redTable.splash.alpha = (circle.redTable.splash.alpha + 0.02);
increWin();
if (circle.redCenter.hitTestPoint(_arg1.x, _arg1.y, true)){
score = (score + (10 * level));
} else {
score = (score + (5 * level));
};
circle.redSmoke.gotoAndPlay(2);
} else {
increFail(1);
};
removeChild(pickups[_arg2]);
pickups.splice(_arg2, 1);
};
if (circle.black.hitTestPoint(_arg1.x, _arg1.y, true)){
if ((((((((orangeOrder == _arg1.getType())) || ((greyOrder == _arg1.getType())))) || ((purpleOrder == _arg1.getType())))) || ((redOrder == _arg1.getType())))){
increFail(1);
};
removeChild(pickups[_arg2]);
pickups.splice(_arg2, 1);
};
}
private function fail(){
isPaused = true;
MochiScores.showLeaderboard({boardID:"57a8e250a1efff0a", score:score, onClose:this.reset});
}
private function removeInstructions(){
removeChild(instructions);
instructions.closeBtn.removeEventListener(MouseEvent.CLICK, removeInstructionsClick);
}
private function levelUp(){
sound.startSound("levelup", 0.2, 0);
spawnTimer = 0;
pickupIterator = 0;
failCounter = 0;
winCounter = 0;
if (amountOfTypes < 4){
amountOfTypes++;
};
level++;
speed = (3 + (level * 0.25));
if (level < 6){
spawnInterval = (spawnInterval - level);
};
if (level < 13){
failLimit = (15 - level);
} else {
failLimit = 1;
};
winLimit = (20 + level);
isPaused = true;
addChild(levelUp_ani);
levelUp_ani.cacheAsBitmap = true;
levelUp_ani.gotoAndPlay(1);
levelUp_ani.addEventListener(Event.ENTER_FRAME, checkAnimation, false, 0, true);
}
private function removeMainMenu(){
MainMenu(getChildByName("mainMenu")).startBtn.removeEventListener(MouseEvent.CLICK, startBtnClick);
MainMenu(getChildByName("mainMenu")).instructionsBtn.removeEventListener(MouseEvent.CLICK, instructionsBtnClick);
MainMenu(getChildByName("mainMenu")).moreBtn.removeEventListener(MouseEvent.CLICK, callLink);
MainMenu(getChildByName("mainMenu")).logo.removeEventListener(MouseEvent.CLICK, callLink);
removeChild(getChildByName("mainMenu"));
}
private function checkAnimation(_arg1:Event){
if (_arg1.currentTarget.currentFrame == _arg1.currentTarget.totalFrames){
isPaused = false;
_arg1.currentTarget.removeEventListener(Event.ENTER_FRAME, checkAnimation);
removeChild(MovieClip(_arg1.currentTarget));
};
}
private function increFail(_arg1:int){
failCounter = (failCounter + _arg1);
sound.startSound("miss", 0.2, 0);
if (failCounter >= failLimit){
fail();
};
}
private function callLink(_arg1:MouseEvent):void{
var url:String;
var request:URLRequest;
var evt = _arg1;
sound.startSound("btn", 0.8, 0);
url = "http://www.spelgrim.com";
request = new URLRequest(url);
try {
navigateToURL(request, "_blank");
} catch(e:Error) {
trace("Error occurred!");
};
}
private function instructionsBtnClick(_arg1:MouseEvent){
sound.startSound("btn", 0.8, 0);
addInstructions();
}
private function increWin(){
winCounter++;
sound.startSound("eat", 0.2, 0);
if (winCounter >= winLimit){
levelUp();
};
}
private function newOrder():int{
return (Math.ceil((Math.random() * amountOfTypes)));
}
private function setupMainMenu(){
isPaused = false;
sound.startMusic("theme", 1, 0);
addChild(new MainMenu()).name = "mainMenu";
MainMenu(getChildByName("mainMenu")).startBtn.addEventListener(MouseEvent.CLICK, startBtnClick, false, 0, true);
MainMenu(getChildByName("mainMenu")).instructionsBtn.addEventListener(MouseEvent.CLICK, instructionsBtnClick, false, 0, true);
MainMenu(getChildByName("mainMenu")).moreBtn.addEventListener(MouseEvent.CLICK, callLink, false, 0, true);
MainMenu(getChildByName("mainMenu")).logo.addEventListener(MouseEvent.CLICK, callLink, false, 0, true);
}
private function EnterFrame(_arg1:Event){
if (!isPaused){
spawnTimer++;
if (spawnTimer > spawnInterval){
sound.startSound("food", 0.6, 0);
spawnTimer = 0;
pickups.push(new Pickup(this, speed, newDish()));
addChild(pickups[(pickups.length - 1)]);
chef.rotation = (pickups[(pickups.length - 1)].rotation + 30);
};
circle.update();
pickupIterator = 0;
while (pickupIterator < pickups.length) {
pickups[pickupIterator].update();
checkCollision(pickups[pickupIterator], pickupIterator);
pickupIterator++;
};
updateGui();
};
if (circle.orangeSmoke.currentFrame == 1){
circle.orangeSmoke.gotoAndStop(1);
};
if (circle.greySmoke.currentFrame == 1){
circle.greySmoke.gotoAndStop(1);
};
if (circle.purpleSmoke.currentFrame == 1){
circle.purpleSmoke.gotoAndStop(1);
};
if (circle.redSmoke.currentFrame == 1){
circle.redSmoke.gotoAndStop(1);
};
}
private function adFinished(){
addChild(spelgrimAnimation);
spelgrimAnimation.play();
spelgrimAnimation.x = 315;
spelgrimAnimation.y = 185;
spelgrimAnimation.scaleX = 0.6;
spelgrimAnimation.scaleY = 0.6;
spelgrimAnimation.addEventListener(Event.ENTER_FRAME, checkLogo, false, 0, true);
spelgrimAnimation.addEventListener(MouseEvent.CLICK, callLink);
}
private function newDish():int{
switch (Math.ceil((Math.random() * 4))){
case 1:
return (orangeOrder);
case 2:
return (greyOrder);
case 3:
return (purpleOrder);
case 4:
return (redOrder);
default:
return (1);
};
}
private function updateGui(){
gui.win_tf.text = ((("Win: " + winCounter.toString()) + "/") + winLimit.toString());
gui.fail_tf.text = ((("Fail: " + failCounter.toString()) + "/") + failLimit.toString());
gui.score_tf.text = ("Score: " + score.toString());
gui.level_tf.text = ("Level: " + level.toString());
}
private function reset(){
score = 0;
spawnInterval = 40;
amountOfTypes = 2;
failLimit = 25;
winLimit = 20;
level = 1;
speed = 3;
winCounter = 0;
failCounter = 0;
removeChild(circle);
removeChild(gui);
removeChild(chef);
removeEventListener(Event.ENTER_FRAME, EnterFrame);
setupMainMenu();
}
private function checkLogo(_arg1:Event){
if (spelgrimAnimation.currentFrame == spelgrimAnimation.totalFrames){
spelgrimAnimation.removeEventListener(Event.ENTER_FRAME, checkLogo);
spelgrimAnimation.removeEventListener(MouseEvent.CLICK, callLink);
removeChild(spelgrimAnimation);
addChild(bkg);
setupMainMenu();
};
}
private function removeInstructionsClick(_arg1:MouseEvent){
sound.startSound("btn", 0.8, 0);
removeInstructions();
}
private function addInstructions(){
addChild(instructions);
instructions.closeBtn.addEventListener(MouseEvent.CLICK, removeInstructionsClick, false, 0, true);
}
}
}//package
Section 24
//MainMenu (MainMenu)
package {
import flash.display.*;
public dynamic class MainMenu extends MovieClip {
public var instructionsBtn:SimpleButton;
public var startBtn:SimpleButton;
public var logo:SimpleButton;
public var moreBtn:SimpleButton;
}
}//package
Section 25
//miss (miss)
package {
import flash.media.*;
public dynamic class miss extends Sound {
}
}//package
Section 26
//MochiAd (MochiAd)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.5");
}
public static function showClickAwayAd(_arg1:Object):void{
var DEFAULTS:Object;
var clip:Object;
var ad_timeout:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var sendHostProgress:Boolean;
var options = _arg1;
DEFAULTS = {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;
ad_timeout = 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();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_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);
};
sendHostProgress = false;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
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;
_local2 = _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 DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var options = _arg1;
DEFAULTS = {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;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = (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;
_local2 = 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 _local1:Object;
var _local2:Number;
var _local3:Boolean;
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
_local1 = this.parent._mochiad_ctr;
_local2 = (getTimer() - this.started);
_local3 = false;
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 _local3:Object;
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
_local3 = {};
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 idx:Number;
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);
};
idx = 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 DEFAULTS:Object;
var clip:Object;
var depth:Number;
var mc:MovieClip;
var wh:Array;
var lv:URLVariables;
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;
DEFAULTS = {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."));
};
depth = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
wh = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
lv = 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;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 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;
_local4 = 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 _local3:Object;
var _local4:Number;
var _local5:Number;
var _local6:Array;
_local3 = _arg2.getBounds(_arg2.root);
_local4 = 0;
_local5 = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function 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;
var _local4:Number;
_local3 = _arg2.split(".");
_local4 = 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;
var _local5:Number;
_local4 = _arg2.split(".");
_local5 = 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 DEFAULTS:Object;
var clip:Object;
var ad_msec:Number;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var wh:Array;
var w:Number;
var h:Number;
var chk:MovieClip;
var bar:MovieClip;
var bar_color:Number;
var bar_background:Number;
var bar_outline:Number;
var backing_mc:MovieClip;
var backing:Object;
var inside_mc:MovieClip;
var inside:Object;
var outline_mc:MovieClip;
var outline:Object;
var complete:Boolean;
var unloaded:Boolean;
var f:Function;
var sendHostProgress:Boolean;
var r:MovieClip;
var options = _arg1;
DEFAULTS = {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();
setTimeout(options.ad_finished, 100);
return;
};
clip = options.clip;
ad_msec = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
var fn:Function;
MochiAd._cleanup(mc);
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
wh = MochiAd._getRes(options, clip);
w = wh[0];
h = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
bar = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
bar_color = options.color;
delete options.color;
bar_background = options.background;
delete options.background;
bar_outline = options.outline;
delete options.outline;
backing_mc = createEmptyMovieClip(bar, "_outline", 1);
backing = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
inside_mc = createEmptyMovieClip(bar, "_inside", 2);
inside = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
outline_mc = createEmptyMovieClip(bar, "_outline", 3);
outline = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number;
_local1 = (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;
f = 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;
_local2 = 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 _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Boolean;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
_local1 = this.parent.parent.root;
_local2 = this.parent._mochiad_ctr;
_local3 = (getTimer() - this.started);
_local4 = false;
_local5 = _local1.loaderInfo.bytesTotal;
_local6 = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
_local7 = ((100 * _local6) / _local5);
_local8 = ((100 * _local3) / chk.ad_msec);
_local9 = this._mochiad_bar._inside;
_local10 = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
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 f:Function;
var mc = _arg1;
f = 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 27
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("core.mochibot.com");
Security.allowInsecureDomain("core.mochibot.com");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 28
//Pickup (Pickup)
package {
import flash.display.*;
public class Pickup extends MovieClip {
private var rad:Number;// = 0
private var speed:Number;// = 3
private var type:int;// = 1
private var stageref;
public function Pickup(_arg1, _arg2, _arg3){
rad = 0;
speed = 3;
type = 1;
super();
stageref = _arg1;
this.alpha = 0;
this.x = 250;
this.y = 250;
speed = _arg2;
type = _arg3;
this.gotoAndStop(type);
rad = (Math.random() * (2 * Math.PI));
this.rotation = ((rad * 180) / Math.PI);
}
public function getType():int{
return (type);
}
public function inverseRad(){
rad = (rad + Math.PI);
}
public function update(){
if (this.alpha < 1){
this.alpha = (this.alpha + 0.05);
};
this.x = (this.x + (Math.cos(rad) * speed));
this.y = (this.y + (Math.sin(rad) * speed));
}
}
}//package
Section 29
//SoundHandler (SoundHandler)
package {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class SoundHandler extends Sprite {
private var soundVolume:Number;// = 1
private var masterVolume:Number;// = 1
private var sounds:Array;
private var musicEnabled:Boolean;// = true
private var channel_loop:Array;
private var channel_effect:SoundChannel;
private var effectEnabled:Boolean;// = true
private var transform_music:SoundTransform;
private var musicVolume:Number;// = 1
private var transform_loop:Array;
private var sounds_loop:Array;
private var transform_effect:SoundTransform;
private var channel_music:SoundChannel;
private var loopingSong:String;
static var trackLength:Number = 0;
public function SoundHandler(){
sounds = new Array();
masterVolume = 1;
musicVolume = 1;
soundVolume = 1;
channel_music = new SoundChannel();
channel_effect = new SoundChannel();
transform_music = new SoundTransform((1 * masterVolume), 0);
transform_effect = new SoundTransform((1 * masterVolume), 0);
channel_loop = new Array();
sounds_loop = new Array();
transform_loop = new Array();
musicEnabled = true;
effectEnabled = true;
super();
}
public function changeMasterVolume(_arg1):void{
masterVolume = _arg1;
refreshVolumes();
}
public function startMusic(_arg1:String, _arg2:Number, _arg3:Number){
var classRef:Class;
var snd:Sound;
var song = _arg1;
var vol = _arg2;
var pan = _arg3;
loopingSong = song;
try {
if (loopingSong == ""){
channel_music.stop();
} else {
classRef = (getDefinitionByName(loopingSong) as Class);
snd = new (classRef);
channel_music.stop();
channel_music = snd.play();
transform_music = new SoundTransform(((vol * masterVolume) * musicVolume), pan);
channel_music.soundTransform = transform_music;
channel_music.addEventListener(Event.SOUND_COMPLETE, restartMusic, false, 0, true);
};
} catch(e:Error) {
};
}
public function getToggleMusic():Boolean{
return (musicEnabled);
}
public function startLoop(_arg1:String, _arg2:Number, _arg3:Number){
var index:int;
var i:*;
var classRef:Class;
var snd:Sound;
var song = _arg1;
var vol = _arg2;
var pan = _arg3;
trace(("loopStarting - vol: " + vol));
channel_loop.push(new SoundChannel());
sounds_loop.push(song);
transform_loop.push(new SoundTransform((vol * masterVolume), pan));
index = (channel_loop.length - 1);
channel_loop[index].soundTransform = transform_loop[index];
for (i in sounds_loop) {
try {
classRef = (getDefinitionByName(sounds_loop[index]) as Class);
snd = new (classRef);
channel_loop[index].stop();
channel_loop[index] = snd.play();
transform_loop[index] = new SoundTransform(((vol * masterVolume) * soundVolume), pan);
channel_loop[index].soundTransform = transform_loop[index];
channel_loop[index].addEventListener(Event.SOUND_COMPLETE, restartLoop, false, 0, true);
} catch(e:Error) {
};
};
}
public function toggleMusic(_arg1:MouseEvent){
musicEnabled = !(musicEnabled);
if (musicEnabled){
_arg1.currentTarget.gotoAndStop(1);
transform_music = new SoundTransform(1, 0);
} else {
_arg1.currentTarget.gotoAndStop(2);
transform_music = new SoundTransform(0, 0);
};
channel_music.soundTransform = transform_music;
}
public function toggleEffect(_arg1:MouseEvent){
effectEnabled = !(effectEnabled);
if (effectEnabled){
_arg1.currentTarget.gotoAndStop(1);
transform_effect = new SoundTransform(1, 0);
} else {
_arg1.currentTarget.gotoAndStop(2);
transform_effect = new SoundTransform(0, 0);
};
channel_effect.soundTransform = transform_effect;
}
public function stopMusic():void{
loopingSong = "";
try {
channel_music.stop();
} catch(e:Error) {
};
}
private function refreshVolumes(){
transform_music = new SoundTransform((masterVolume * musicVolume), 0);
channel_music.soundTransform = transform_music;
transform_effect = new SoundTransform((masterVolume * soundVolume), 0);
channel_effect.soundTransform = transform_effect;
}
public function changeSoundVolume(_arg1):void{
soundVolume = _arg1;
refreshVolumes();
}
private function restartMusic(_arg1:Event){
var classRef:Class;
var snd:Sound;
var evt = _arg1;
channel_music.removeEventListener(Event.SOUND_COMPLETE, restartMusic);
try {
classRef = (getDefinitionByName(loopingSong) as Class);
snd = new (classRef);
channel_music = snd.play();
channel_music.soundTransform = transform_music;
channel_music.addEventListener(Event.SOUND_COMPLETE, restartMusic, false, 0, true);
} catch(e:Error) {
};
}
private function restartLoop(_arg1:Event){
var i:*;
var index:int;
var classRef:Class;
var snd:Sound;
var evt = _arg1;
for (i in channel_loop) {
if (evt.currentTarget == channel_loop[i]){
index = i;
};
};
channel_loop[index].removeEventListener(Event.SOUND_COMPLETE, restartLoop);
try {
classRef = (getDefinitionByName(sounds_loop[index]) as Class);
snd = new (classRef);
channel_loop[index].stop();
channel_loop[index] = snd.play();
channel_loop[index].soundTransform = transform_loop[index];
channel_loop[index].addEventListener(Event.SOUND_COMPLETE, restartLoop, false, 0, true);
} catch(e:Error) {
};
}
public function changeLoop(_arg1:String, _arg2:Number, _arg3:Number){
var i:*;
var index:int;
var song = _arg1;
var vol = _arg2;
var pan = _arg3;
for (i in sounds_loop) {
if (song == sounds_loop[i]){
index = i;
};
};
transform_loop[index] = new SoundTransform(((vol * masterVolume) * soundVolume), pan);
try {
channel_loop[index].soundTransform = transform_loop[index];
channel_loop[index].addEventListener(Event.SOUND_COMPLETE, restartLoop, false, 0, true);
} catch(e:Error) {
};
}
private function ioErrorHandler(_arg1:Event):void{
trace(("ioErrorHandler: " + _arg1));
}
public function getToggleEffect():Boolean{
return (effectEnabled);
}
public function stopLoop(_arg1:String){
var _local2:*;
var _local3:int;
for (_local2 in sounds_loop) {
if (_arg1 == sounds_loop[_local2]){
_local3 = _local2;
};
};
channel_loop[_local3].stop();
channel_loop.splice(_local3, 1);
sounds_loop.splice(_local3, 1);
transform_loop.splice(_local3, 1);
}
public function changeMusicVolume(_arg1):void{
musicVolume = _arg1;
refreshVolumes();
}
public function startSound(_arg1:String, _arg2:Number, _arg3:Number){
var classRef:Class;
var snd:Sound;
var song = _arg1;
var vol = _arg2;
var pan = _arg3;
try {
classRef = (getDefinitionByName(song) as Class);
snd = new (classRef);
channel_effect = snd.play();
transform_effect = new SoundTransform(((vol * masterVolume) * soundVolume), pan);
channel_effect.soundTransform = transform_effect;
} catch(e:Error) {
};
}
}
}//package
Section 30
//SpelgrimAnimation (SpelgrimAnimation)
package {
import flash.display.*;
public dynamic class SpelgrimAnimation extends MovieClip {
public var gubbe_mc:MovieClip;
public function SpelgrimAnimation(){
addFrameScript(175, frame176, 229, frame230);
}
function frame176(){
}
function frame230(){
}
}
}//package
Section 31
//theme (theme)
package {
import flash.media.*;
public dynamic class theme extends Sound {
}
}//package