Frame 1
Main.main(this);
stop();
Symbol 20 MovieClip [tile] Frame 1
stop();
Symbol 20 MovieClip [tile] Frame 2
stop();
Symbol 20 MovieClip [tile] Frame 3
stop();
Symbol 20 MovieClip [tile] Frame 4
stop();
Symbol 20 MovieClip [tile] Frame 5
stop();
Symbol 20480 MovieClip [__Packages.GameStats] Frame 0
#initclip
if (!GameStats) {
//(_global.GameStats = function () {
super();
this._x = 5;
this._y = SnakeGame.screen.height_px - 20;
this.createTextField("num_clients_tf", this.getNextHighestDepth(), 0, 0, 15, 20);
this.num_clients_tf.autoSize = true;
this.num_clients_tf.html = true;
}) extends MovieClip
var _local1 = (_global.GameStats /* register */).prototype;
_local1.setNumClients = function (clients) {
var _local3 = new TextFormat();
_local3.align = "center";
_local3.font = "Arial";
_local3.size = 11;
_local3.color = 0;
this.num_clients = clients;
if (this.num_clients == 1) {
this.num_clients_tf.htmlText = "<b>1</b> snake";
} else {
this.num_clients_tf.htmlText = ("<b>" + this.num_clients) + "</b> snakes";
}
this.num_clients_tf.setTextFormat(_local3);
};
ASSetPropFlags(_local1, null, 1);
(_global.GameStats /* register */).symbolName = "__Packages.GameStats";
(_global.GameStats /* register */).symbolOwner = GameStats;
(_global.GameStats /* register */).symbolLinked = Object.registerClass(GameStats.symbolName, GameStats.symbolOwner);
}
#endinitclip
Symbol 20481 MovieClip [__Packages.NotificationManager] Frame 0
class NotificationManager
{
function NotificationManager () {
}
function add_notification(msg) {
var _local3 = Main.top_mc.attachMovie(Notification.symbolName, "notif", Main.top_mc.getNextHighestDepth(), {message:msg});
}
//ASSetPropFlags(_local1, null, 1);
}
Symbol 20482 MovieClip [__Packages.MochiAd] Frame 0
class MochiAd
{
function MochiAd () {
}
static function getVersion() {
return("2.1");
}
static function showPreGameAd(options) {
var _local2 = {clip:_root, ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:16747008, background:16777161, outline:13994812, ad_started:function () {
this.clip.stop();
}, ad_finished:function () {
this.clip.play();
}};
options = _parseOptions(options, _local2);
var _local3 = options.clip;
var _local4 = 11000;
var _local5 = options.ad_timeout;
delete options.ad_timeout;
var _local6 = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
options.ad_finished();
return(undefined);
}
options.ad_started();
var _local7 = _local3._mochiad;
_local7.onUnload = function () {
options.ad_finished();
};
var _local8 = _getRes(options);
var _local9 = _local8[0];
var _local10 = _local8[1];
_local7._x = _local9 * 0.5;
_local7._y = _local10 * 0.5;
var chk = _local7.createEmptyMovieClip("_mochiad_wait", 3);
chk._x = _local9 * -0.5;
chk._y = _local10 * -0.5;
var _local11 = chk.createEmptyMovieClip("_mochiad_bar", 4);
_local11._x = 10;
_local11._y = _local10 - 20;
var _local12 = options.color;
delete options.color;
var _local13 = options.background;
delete options.background;
var _local14 = options.outline;
delete options.outline;
var _local15 = _local11.createEmptyMovieClip("_outline", 1);
_local15.beginFill(_local13);
_local15.moveTo(0, 0);
_local15.lineTo(_local9 - 20, 0);
_local15.lineTo(_local9 - 20, 10);
_local15.lineTo(0, 10);
_local15.lineTo(0, 0);
_local15.endFill();
var _local16 = _local11.createEmptyMovieClip("_inside", 2);
_local16.beginFill(_local12);
_local16.moveTo(0, 0);
_local16.lineTo(_local9 - 20, 0);
_local16.lineTo(_local9 - 20, 10);
_local16.lineTo(0, 10);
_local16.lineTo(0, 0);
_local16.endFill();
_local16._xscale = 0;
var _local17 = _local11.createEmptyMovieClip("_outline", 3);
_local17.lineStyle(0, _local14, 100);
_local17.moveTo(0, 0);
_local17.lineTo(_local9 - 20, 0);
_local17.lineTo(_local9 - 20, 10);
_local17.lineTo(0, 10);
_local17.lineTo(0, 0);
chk.ad_msec = _local4;
chk.ad_timeout = _local5;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = _local6;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
_local7.lc.adLoaded = function (width, height) {
};
_local7.lc.adjustProgress = function (msec) {
var _local3 = this.mc._mochiad_wait;
_local3.server_control = true;
_local3.started = getTimer();
_local3.ad_msec = msec;
};
chk.onEnterFrame = function () {
var _local2 = this._parent._parent;
var _local3 = this._parent._mochiad_ctr;
var _local4 = getTimer() - this.started;
var _local5 = false;
var _local6 = _local2.getBytesTotal();
var _local7 = _local2.getBytesLoaded();
var _local8 = (100 * _local7) / _local6;
var _local9 = (100 * _local4) / chk.ad_msec;
var _local10 = this._mochiad_bar._inside;
var _local11 = Math.min(100, Math.min(_local8 || 0, _local9));
_local11 = Math.max(this.last_pcnt, _local11);
this.last_pcnt = _local11;
_local10._xscale = _local11;
if (!chk.showing) {
var _local12 = _local3.getBytesTotal();
if ((_local12 > 0) || (typeof(_local12) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
_local5 = true;
}
}
if (_local4 > chk.ad_msec) {
_local5 = true;
}
if ((_local6 > 0) && ((_local7 >= _local6) && (_local5))) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
}
}
};
}
static function showInterLevelAd(options) {
var _local2 = {clip:_root, ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function () {
this.clip.stop();
}, ad_finished:function () {
this.clip.play();
}};
options = _parseOptions(options, _local2);
var _local3 = options.clip;
var _local4 = 11000;
var _local5 = options.ad_timeout;
delete options.ad_timeout;
var _local6 = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
options.ad_finished();
return(undefined);
}
options.ad_started();
var _local7 = _local3._mochiad;
_local7.onUnload = function () {
options.ad_finished();
};
var _local8 = _getRes(options);
var _local9 = _local8[0];
var _local10 = _local8[1];
_local7._x = _local9 * 0.5;
_local7._y = _local10 * 0.5;
var chk = _local7.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_msec = _local4;
chk.ad_timeout = _local5;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = _local6;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
_local7.lc.adLoaded = function (width, height) {
};
_local7.lc.adjustProgress = function (msec) {
var _local3 = this.mc._mochiad_wait;
_local3.server_control = true;
_local3.started = getTimer();
_local3.ad_msec = msec - 250;
};
chk.onEnterFrame = function () {
var _local2 = this._parent._mochiad_ctr;
var _local3 = getTimer() - this.started;
var _local4 = false;
if (!chk.showing) {
var _local5 = _local2.getBytesTotal();
if ((_local5 > 0) || (typeof(_local5) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local3 > chk.ad_timeout) {
_local4 = true;
}
}
if (_local3 > chk.ad_msec) {
_local4 = true;
}
if (_local4) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
}
}
};
}
static function showTimedAd(options) {
showInterLevelAd(options);
}
static function showPreloaderAd(options) {
showPreGameAd(options);
}
static function _allowDomains(server) {
var _local3 = server.split("/")[2].split(":")[0];
if (System.security) {
if (System.security.allowDomain) {
System.security.allowDomain("*");
System.security.allowDomain(_local3);
}
if (System.security.allowInsecureDomain) {
System.security.allowInsecureDomain("*");
System.security.allowInsecureDomain(_local3);
}
}
return(_local3);
}
static function _loadCommunicator(options) {
var _local3 = {clip:_root, com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = _parseOptions(options, _local3);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = getVersion();
var _local4 = options.clip;
var _local5 = "_mochiad_com_" + options.id;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local4[_local5]) {
return(_local4[_local5].lc);
}
var _local6 = options.com_server + options.id;
_allowDomains(_local6);
delete options.id;
delete options.com_server;
var _local7 = options.depth;
delete options.depth;
var _local8 = _local4.createEmptyMovieClip(_local5, _local7);
var _local9 = _local8.createEmptyMovieClip("_mochiad_com", 1);
for (var k in options) {
_local9[k] = options[k];
}
var _local10 = new LocalConnection();
var _local11 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local10.mc = _local8;
_local10.name = _local11;
_local10.allowDomain = function (d) {
return(true);
};
_local10.allowInsecureDomain = _local10.allowDomain;
_local10.connect(_local11);
_local8.lc = _local10;
_local9.lc = _local11;
_local10._id = 0;
_local10._queue = [];
_local10.rpcResult = function (cb_arg) {
var _local3 = _global.parseInt(cb_arg);
var _local4 = this._callbacks[_local3];
if (!_local4) {
return(undefined);
}
delete this._callbacks[_local3];
var _local5 = [];
var _local6 = 2;
for ( ; _local6 < _local4.length ; _local6++) {
_local5.push(_local4[_local6]);
}
var _local7 = 1;
for ( ; _local7 < arguments.length ; _local7++) {
_local5.push(arguments[_local7]);
}
var _local8 = _local4[1];
var _local9 = _local4[0];
if (_local9 && (typeof(_local8) == "string")) {
_local8 = _local9[_local8];
}
if (_local8) {
_local8.apply(_local9, _local5);
}
};
_local10._didConnect = function (endpoint) {
this._endpoint = endpoint;
var _local3 = this._queue;
delete this._queue;
var _local4 = this.doSend;
var _local5 = 0;
for ( ; _local5 < _local3.length ; _local5++) {
var _local6 = _local3[_local5];
_local4.apply(this, _local6);
}
};
_local10.doSend = function (args, cbobj, cbfn) {
if (this._endpoint == null) {
var _local5 = [];
var _local6 = 0;
for ( ; _local6 < arguments.length ; _local6++) {
_local5.push(arguments[_local6]);
}
this._queue.push(_local5);
return(undefined);
}
this._id = this._id + 1;
var _local7 = this._id;
if ((cbfn === undefined) || (cbfn === null)) {
cbfn = cbobj;
}
this._callbacks[_local7] = [cbobj, cbfn];
var _local8 = new LocalConnection();
var _local9 = _local8.send(this._endpoint, "rpc", _local7, args);
};
_local10._callbacks = {};
_local10._callbacks[0] = [_local10, "_didConnect"];
_local9.st = getTimer();
_local9.loadMovie(_local6 + ".swf", "POST");
return(_local10);
}
static function fetchHighScores(options, callbackObj, callbackMethod) {
var _local5 = _loadCommunicator({id:options.id});
if (!_local5) {
return(false);
}
var _local6 = ["fetchHighScores", options];
_local5.doSend(["fetchHighScores", options], callbackObj, callbackMethod);
return(true);
}
static function sendHighScore(options, callbackObj, callbackMethod) {
var _local5 = _loadCommunicator({id:options.id});
if (!_local5) {
return(false);
}
var _local6 = ["sendHighScore", options];
_local5.doSend(["sendHighScore", options], callbackObj, callbackMethod);
return(true);
}
static function load(options) {
var _local3 = {clip:_root, server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = _parseOptions(options, _local3);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = getVersion();
var _local4 = options.clip;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local4._mochiad_loaded) {
return(null);
}
var _local5 = options.depth;
delete options.depth;
var _local6 = _local4.createEmptyMovieClip("_mochiad", _local5);
var _local7 = _getRes(options);
options.res = (_local7[0] + "x") + _local7[1];
options.server = options.server + options.id;
delete options.id;
_local4._mochiad_loaded = true;
var _local8 = _local6.createEmptyMovieClip("_mochiad_ctr", 1);
for (var k in options) {
_local8[k] = options[k];
}
var _local9 = _local8.server;
delete _local8.server;
var _local10 = _allowDomains(_local9);
_local6.onEnterFrame = function () {
if (this._mochiad_ctr._url != this._url) {
this.onEnterFrame = function () {
if (!this._mochiad_ctr) {
delete this.onEnterFrame;
MochiAd.unload(this._parent);
}
};
}
};
var _local11 = new LocalConnection();
var _local12 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local11.mc = _local6;
_local11.name = _local12;
_local11.hostname = _local10;
_local11.allowDomain = function (d) {
return(true);
};
_local11.allowInsecureDomain = _local11.allowDomain;
_local11.connect(_local12);
_local6.lc = _local11;
_local8.lc = _local12;
_local8.st = getTimer();
_local8.loadMovie(_local9 + ".swf", "POST");
return(_local6);
}
static function unload(clip) {
if (typeof(clip) == "undefined") {
clip = _root;
}
if (clip.clip && (clip.clip._mochiad)) {
clip = clip.clip;
}
if (!clip._mochiad) {
return(false);
}
clip._mochiad.removeMovieClip();
delete clip._mochiad_loaded;
delete clip._mochiad;
return(true);
}
static function _isNetworkAvailable() {
if (System.security) {
var _local2 = System.security;
if (_local2.sandboxType == "localWithFile") {
return(false);
}
}
return(true);
}
static function _getRes(options) {
var _local3 = options.clip.getBounds();
var _local4 = 0;
var _local5 = 0;
if (typeof(options.res) != "undefined") {
var _local6 = options.res.split("x");
_local4 = _global.parseFloat(_local6[0]);
_local5 = _global.parseFloat(_local6[1]);
} else {
_local4 = _local3.xMax - _local3.xMin;
_local5 = _local3.yMax - _local3.yMin;
}
if ((_local4 == 0) || (_local5 == 0)) {
_local4 = Stage.width;
_local5 = Stage.height;
}
return([_local4, _local5]);
}
static function _parseOptions(options, defaults) {
var _local4 = {};
for (var k in defaults) {
_local4[k] = defaults[k];
}
if (options) {
for (var k in options) {
_local4[k] = options[k];
}
}
if (_root.mochiad_options) {
var _local5 = _root.mochiad_options.split("&");
var _local6 = 0;
for ( ; _local6 < _local5.length ; _local6++) {
var _local7 = _local5[_local6].split("=");
_local4[_global.unescape(_local7[0])] = _global.unescape(_local7[1]);
}
}
return(_local4);
}
//ASSetPropFlags(_local1, null, 1);
}
Symbol 20483 MovieClip [__Packages.Map] Frame 0
class Map
{
var map;
function Map () {
}
function set_size(in_x, in_y) {
width = in_x;
height = in_y;
reset_map();
}
function reset_map() {
map = new Array();
var _local2 = 0;
for ( ; _local2 < width ; _local2++) {
map[_local2] = new Array();
var _local3 = 0;
for ( ; _local3 < height ; _local3++) {
map[_local2][_local3] = Tiles.EMPTY;
}
}
}
function get_coordinates(in_x, in_y) {
in_x = Helpers.mod(in_x, width);
in_y = Helpers.mod(in_y, height);
return({x:in_x, y:in_y});
}
function add_tile(in_abs_x, in_abs_y, in_tile_type) {
map[in_abs_x][in_abs_y] = in_tile_type;
}
function delete_tile(in_abs_x, in_abs_y, in_tile_type) {
if (in_tile_type == undefined) {
map[in_abs_x][in_abs_y] = Tiles.EMPTY;
} else if (map[in_abs_x][in_abs_y] == in_tile_type) {
map[in_abs_x][in_abs_y] = Tiles.EMPTY;
}
}
function delete_block(top_left_x, top_left_y, in_tile_type) {
var _local5 = 0;
for ( ; _local5 < SnakeGame.screen.width ; _local5++) {
var _local6 = top_left_x + _local5;
var _local7 = 0;
for ( ; _local7 < SnakeGame.screen.height ; _local7++) {
var _local8 = top_left_y + _local7;
delete_tile(_local6, _local8, in_tile_type);
}
}
}
//ASSetPropFlags(_local1, null, 1);
var width = 0;
var height = 0;
}
Symbol 20484 MovieClip [__Packages.Notification] Frame 0
#initclip
if (!Notification) {
//(_global.Notification = function () {
super();
this.notif_mc = this.createEmptyMovieClip("notif_mc", this.getNextHighestDepth());
this.notif_mc.width = Notification.BOX_WIDTH;
this.notif_mc.height = Notification.BOX_HEIGHT;
this.notif_mc._x = Notification.BOX_XOFFSET;
this.notif_mc._y = Notification.BOX_YOFFSET;
var _local3 = new TextFormat();
_local3.align = "left";
_local3.font = "Arial";
_local3.size = 18;
_local3.bold = true;
_local3.color = 0;
this.notif_mc.createTextField("notif_text", this.notif_mc.getNextHighestDepth(), 0, 0, this.notif_mc.width, this.notif_mc.height);
this.notif_mc.notif_text._x = 0;
this.notif_mc.notif_text._y = 0;
this.notif_mc.notif_text.antiAliasType = "advanced";
this.notif_mc.notif_text.setTextFormat(_local3);
this.notif_mc.notif_text.text = this.message;
this.notif_mc.beginFill(16777215, 50);
this.notif_mc.lineStyle(0, 0, 100);
this.notif_mc.moveTo(0, 0);
this.notif_mc.lineTo(this.notif_mc.notif_text.textWidth, 0);
this.notif_mc.lineTo(this.notif_mc.notif_text.textWidth, this.notif_mc.notif_text.textHeight);
this.notif_mc.lineTo(0, this.notif_mc.notif_text.textHeight);
this.notif_mc.lineTo(0, 0);
this.clear_interval = _global.setInterval(Delegate.create(this, this.clearMC), Notification.DISPLAY_TIME);
}) extends MovieClip
var _local1 = (_global.Notification /* register */).prototype;
_local1.clearMC = function () {
_global.clearInterval(this.clear_interval);
this.notif_mc.removeMovieClip();
this.removeMovieClip();
this.clear_callback();
};
ASSetPropFlags(_local1, null, 1);
(_global.Notification /* register */).symbolName = "__Packages.Notification";
(_global.Notification /* register */).symbolOwner = Notification;
(_global.Notification /* register */).symbolLinked = Object.registerClass(Notification.symbolName, Notification.symbolOwner);
(_global.Notification /* register */).DISPLAY_TIME = 4000;
(_global.Notification /* register */).BOX_WIDTH = 120;
(_global.Notification /* register */).BOX_HEIGHT = 20;
(_global.Notification /* register */).BOX_XOFFSET = 5;
(_global.Notification /* register */).BOX_YOFFSET = 5;
}
#endinitclip
Symbol 20485 MovieClip [__Packages.KeyBuffer] Frame 0
class KeyBuffer
{
var len, buf;
function KeyBuffer () {
len = DEFAULT_LEN;
buf = new Array();
}
function push(c) {
if ((buf.length + 1) > len) {
return(undefined);
}
buf.push(c);
}
function pop() {
return(buf.pop());
}
//ASSetPropFlags(_local1, null, 1);
static var DEFAULT_LEN = 3;
}
Symbol 20486 MovieClip [__Packages.Tile] Frame 0
class Tile
{
function Tile (in_name, in_symbol, is_walkable) {
name = in_name;
library_symbol = in_symbol;
}
//ASSetPropFlags(_local1, null, 1);
var name = "empty";
var is_walkable = true;
var size = 10;
var library_symbol = "empty";
}
Symbol 20487 MovieClip [__Packages.PresetScreens] Frame 0
class PresetScreens
{
var game_over_MC, direction_tip_MC;
function PresetScreens () {
}
function show_game_over() {
hide_direction_tip();
game_over_MC = Main.top_mc.createEmptyMovieClip("game_over", Main.top_mc.getNextHighestDepth());
SnakeGame.screen.map_mc._alpha = 75;
game_over_MC.width = 150;
game_over_MC.height = 60;
game_over_MC._x = (SnakeGame.screen.width_px / 2) - (game_over_MC.width / 2);
game_over_MC._y = (SnakeGame.screen.height_px / 2) - (game_over_MC.height / 2);
game_over_MC.beginFill(16777215, 75);
game_over_MC.lineStyle(0, 0, 100);
game_over_MC.moveTo(0, 0);
game_over_MC.lineTo(game_over_MC.width, 0);
game_over_MC.lineTo(game_over_MC.width, game_over_MC.height);
game_over_MC.lineTo(0, game_over_MC.height);
game_over_MC.lineTo(0, 0);
var _local2 = new TextFormat();
_local2.align = "center";
_local2.font = "Arial";
_local2.size = 18;
_local2.bold = true;
_local2.color = 0;
game_over_MC.createTextField("game_over_header", game_over_MC.getNextHighestDepth(), 0, 0, game_over_MC.width, 50);
game_over_MC.game_over_header._x = 0;
game_over_MC.game_over_header._y = 0;
game_over_MC.game_over_header.text = "Game Over";
game_over_MC.game_over_header.antiAliasType = "advanced";
game_over_MC.game_over_header.setTextFormat(_local2);
game_over_MC.createTextField("game_over_body", game_over_MC.getNextHighestDepth(), 0, 0, game_over_MC.width, 60);
game_over_MC.game_over_body._x = 0;
game_over_MC.game_over_body._y = (game_over_MC.height / 3) + 5;
game_over_MC.game_over_body.html = true;
game_over_MC.game_over_body.htmlText = "<b>Click here</b> or <b>press any key</b> to play again.";
game_over_MC.game_over_body.antiAliasType = "advanced";
game_over_MC.game_over_body.multiline = true;
game_over_MC.game_over_body.wordWrap = true;
var _local3 = new TextFormat();
_local3.align = "center";
_local3.font = "Arial";
_local3.size = 12;
_local3.color = 0;
game_over_MC.game_over_body.setTextFormat(_local3);
game_over_MC.onRelease = function () {
if (Main.app.is_connected) {
Main.app.restart();
} else {
Main.app.destroy();
Main.start_game();
}
};
}
function hide_game_over() {
Main.top_mc.game_over.removeMovieClip();
SnakeGame.screen.map_mc._alpha = 100;
}
function show_direction_tip() {
direction_tip_MC = Main.top_mc.createEmptyMovieClip("direction_tip", Main.top_mc.getNextHighestDepth());
direction_tip_MC.width = 170;
direction_tip_MC.height = 20;
direction_tip_MC._x = (SnakeGame.screen.width_px / 2) - (direction_tip_MC.width / 2);
direction_tip_MC._y = ((SnakeGame.screen.height_px / 2) - (direction_tip_MC.height / 2)) - 40;
Helpers.set_border(direction_tip_MC, 0, 0, 16777215);
var _local2 = new TextFormat();
_local2.align = "center";
_local2.font = "Arial";
_local2.size = 12;
_local2.color = 0;
direction_tip_MC.createTextField("direction_tip_body", direction_tip_MC.getNextHighestDepth(), 0, 0, direction_tip_MC.width, 50);
var _local3 = direction_tip_MC.direction_tip_body;
_local3._x = 0;
_local3._y = 0;
_local3.antiAliasType = "advanced";
_local3.html = true;
_local3.htmlText = "Press an <b>arrow key</b> to begin.";
_local3.setTextFormat(_local2);
}
function hide_direction_tip() {
if (direction_tip_MC != undefined) {
direction_tip_MC.removeMovieClip();
}
}
//ASSetPropFlags(_local1, null, 1);
}
Symbol 20488 MovieClip [__Packages.Screen] Frame 0
class Screen
{
var map_mc;
function Screen () {
initialize_screen();
}
function initialize_screen() {
width_px = Stage.width;
height_px = Stage.height;
width = width_px / SnakeGame.tiles.size;
height = height_px / SnakeGame.tiles.size;
map_mc = Main.top_mc.createEmptyMovieClip("screen_container", Main.top_mc.getNextHighestDepth());
var _local2 = 0;
for ( ; _local2 < width ; _local2++) {
last_screen[_local2] = new Array();
var _local3 = 0;
for ( ; _local3 < height ; _local3++) {
last_screen[_local2][_local3] = Tiles.EMPTY;
var _local4 = (_local2 + "_") + _local3;
map_mc.attachMovie("tile", _local4, map_mc.getNextHighestDepth());
map_mc[_local4]._x = _local2 * SnakeGame.tiles.size;
map_mc[_local4]._y = _local3 * SnakeGame.tiles.size;
map_mc[_local4].gotoAndStop(Tiles.EMPTY + 1);
}
}
map_mc._x = 0;
map_mc._y = 0;
}
function update_full() {
var _local2 = SnakeGame.snake.getPosition();
var _local3 = _local2.x - (width / 2);
var _local4 = _local2.y - (height / 2);
var _local5 = 0;
for ( ; _local5 < width ; _local5++) {
var _local6 = _local5 + _local3;
var _local7 = 0;
for ( ; _local7 < height ; _local7++) {
var _local8 = (_local5 + "_") + _local7;
var _local9 = SnakeGame.map.map[_local6][_local7 + _local4];
if (_local9 == undefined) {
_local9 = 0;
}
if (last_screen[_local5][_local7] != _local9) {
map_mc[_local8].gotoAndStop(_local9 + 1);
last_screen[_local5][_local7] = _local9;
}
}
}
if (show_direction_tip == true) {
SnakeGame.preset_screens.show_direction_tip();
show_direction_tip = false;
}
}
function show() {
map_mc._visible = true;
}
function hide() {
map_mc._visible = false;
}
//ASSetPropFlags(_local1, null, 1);
var width = 0;
var height = 0;
var width_px = 0;
var height_px = 0;
var last_screen = new Array();
var show_direction_tip = true;
}
Symbol 20489 MovieClip [__Packages.Snake] Frame 0
class Snake
{
var dir_buffer, direction, length;
function Snake () {
dir_buffer = new KeyBuffer();
direction = undefined;
length = 1;
}
function set_random_direction() {
var _local2 = [NORTH, EAST, SOUTH, WEST];
var _local3 = Math.floor(Math.random() * 3);
direction = _local2[_local3];
SnakeGame.connection.sendDirection(direction2string(direction));
}
function push_move(dir) {
dir_buffer.push(dir);
move();
}
function grow(amount) {
length = length + amount;
}
function is_opposite_direction(opp) {
return(((direction + 2) % 4) == opp);
}
function get_opposite(dir) {
return((dir + 2) % 4);
}
function reset() {
direction = undefined;
length = 1;
}
function move() {
var _local2 = direction;
var _local3 = get_opposite(direction);
do {
var _local4 = dir_buffer.pop();
} while ((_local4 != undefined) && ((Number(_local4) == direction) || ((length > 1) && (Number(_local4) == _local3))));
if (_local4 != undefined) {
direction = Number(_local4);
}
switch (direction) {
case NORTH :
setPosition(position.x, position.y - 1);
break;
case SOUTH :
setPosition(position.x, position.y + 1);
break;
case WEST :
setPosition(position.x - 1, position.y);
break;
case EAST :
setPosition(position.x + 1, position.y);
break;
default :
return(undefined);
}
if (_local2 != direction) {
SnakeGame.connection.sendDirection(direction2string(direction));
}
}
function direction2string(dir) {
switch (dir) {
case NORTH :
return("n");
case SOUTH :
return("s");
case EAST :
return("e");
case WEST :
return("w");
}
return("");
}
function setPosition(x, y) {
position.x = x;
position.y = y;
}
function getPosition() {
return(position);
}
//ASSetPropFlags(_local1, null, 1);
var position = {x:0, y:0};
static var NORTH = 0;
static var EAST = 1;
static var SOUTH = 2;
static var WEST = 3;
}
Symbol 20490 MovieClip [__Packages.Delegate] Frame 0
class Delegate
{
function Delegate () {
}
static function create(target, handler) {
var _local4 = function () {
var _local2 = arguments.callee;
var _local3 = arguments.concat(_local2.initArgs);
return(_local2.handler.apply(_local2.target, _local3));
};
_local4.target = target;
_local4.handler = handler;
_local4.initArgs = arguments.slice(2);
return(_local4);
}
//ASSetPropFlags(_local1, null, 1);
}
Symbol 20491 MovieClip [__Packages.Helpers] Frame 0
class Helpers
{
function Helpers () {
}
static function trim(str) {
var _local3 = {code_9:true, code_10:true, code_13:true};
while (_local3["code_" + str.charCodeAt(0)] == true) {
str = str.substring(1, str.length);
}
while (_local3["code_" + str.charCodeAt(str.length - 1)] == true) {
str = str.substring(0, str.length - 1);
}
return(str);
}
static function mod(a, b) {
var _local4 = a % b;
if (_local4 < 0) {
_local4 = _local4 + b;
}
return(_local4);
}
static function set_border(in_MC, border_color, border_width, fill_color) {
if (typeof(fill_color) == "number") {
in_MC.beginFill(fill_color, 100);
}
if (border_color == undefined) {
in_MC.lineStyle(0, 0, 100);
} else {
in_MC.lineStyle(border_width, border_color, 100);
}
in_MC.moveTo(0, 0);
in_MC.lineTo(in_MC.width, 0);
in_MC.lineTo(in_MC.width, in_MC.height);
in_MC.lineTo(0, in_MC.height);
in_MC.lineTo(0, 0);
}
static function get_url_parameters() {
var _local2 = _root._url;
var _local3 = _local2.lastIndexOf("?");
var _local4 = _local2.substr(_local3 + 1, _local2.length - 1);
var _local5 = _local4.split("&");
var _local6 = new Array();
var _local7 = new Array();
var _local8 = 0;
for ( ; _local8 < _local5.length ; _local8++) {
_local6 = _local5[_local8].split("=");
_local7[_local6[0]] = _local6[1];
}
return(_local7);
}
//ASSetPropFlags(_local1, null, 1);
}
Symbol 20492 MovieClip [__Packages.Tiles] Frame 0
class Tiles
{
var Tile_0, Tile_1, Tile_2, Tile_3, Tile_4;
function Tiles () {
initialize_tiles();
}
function initialize_tiles() {
Tile_0 = new Tile("empty", "empty", true);
Tile_1 = new Tile("snake", "snake_tile", false);
Tile_2 = new Tile("food", "food_tile", true);
Tile_3 = new Tile("wall", "wall_tile", false);
Tile_4 = new Tile("enemy", "enemy_tile", false);
}
//ASSetPropFlags(_local1, null, 1);
static var EMPTY = 0;
static var SNAKE = 1;
static var FOOD = 2;
static var WALL = 3;
static var ENEMY = 4;
var size = 10;
var number_of = 5;
}
Symbol 20493 MovieClip [__Packages.SnakeConnection] Frame 0
class SnakeConnection
{
var socket, gamehost;
function SnakeConnection (host) {
System.security.loadPolicyFile(("xmlsocket://" + host) + ":843");
socket = new XMLSocket();
socket.onConnect = Delegate.create(this, onConnect);
socket.onData = Delegate.create(this, onData);
socket.onClose = Delegate.create(this, onClose);
gamehost = host;
}
function connect() {
socket.connect(gamehost, PORT);
}
function disconnect() {
socket.close();
}
function sendDirection(dir) {
socket.send(dir + newline);
}
function sendReset() {
socket.send("r\n");
}
function send_username(in_name) {
socket.send("u" + in_name);
}
function parse_and_add_report(topleft_x, topleft_y, msg, tile_type) {
var _local6 = msg.length;
var _local7 = 0;
for ( ; _local7 < _local6 ; _local7 = _local7 + 2) {
var _local8 = Helpers.mod((topleft_x + msg.charCodeAt(_local7)) - PACKET_VALUE_OFFSET, SnakeGame.map.width);
var _local9 = Helpers.mod((topleft_y + msg.charCodeAt(_local7 + 1)) - PACKET_VALUE_OFFSET, SnakeGame.map.height);
SnakeGame.map.add_tile(_local8, _local9, tile_type);
}
}
function parse_and_remove_report(topleft_x, topleft_y, msg, tile_type) {
var _local6 = msg.length;
var _local7 = 0;
for ( ; _local7 < _local6 ; _local7 = _local7 + 2) {
var _local8 = Helpers.mod((topleft_x + msg.charCodeAt(_local7)) - PACKET_VALUE_OFFSET, SnakeGame.map.width);
var _local9 = Helpers.mod((topleft_y + msg.charCodeAt(_local7 + 1)) - PACKET_VALUE_OFFSET, SnakeGame.map.height);
SnakeGame.map.delete_tile(_local8, _local9, tile_type);
}
}
function parse_and_remove_absolute_report(msg, type) {
var _local4 = msg.split(";");
var _local5 = 0;
for ( ; _local5 < _local4.length ; _local5++) {
var _local6 = _local4[_local5].split(",");
var _local7 = _global.parseInt(_local6[0], ASCII_RADIX);
var _local8 = _global.parseInt(_local6[1], ASCII_RADIX);
SnakeGame.map.delete_tile(_local7, _local8, type);
}
}
function onData(msg) {
msg = Helpers.trim(msg);
var _local3 = msg.charAt(0);
switch (_local3) {
case "d" :
Main.app.game_over();
SnakeGame.notifications.add_notification("You committed suicide.", 13369344);
SnakeGame.points_display.addPoints("death");
break;
case "l" :
var _local4 = msg.substr(1);
SnakeGame.notifications.add_notification(("You were killed by <b>" + _local4) + "</b>.", 13369344);
Main.app.game_over();
SnakeGame.points_display.addPoints("death");
break;
case "g" :
SnakeGame.snake.grow(1);
SnakeGame.points_display.addPoints("food");
break;
case "j" :
var _local5 = msg.substr(1);
SnakeGame.notifications.add_notification(("<b>" + _local5) + "</b> joined.", 4473924);
break;
case "i" :
var _local6 = msg.substr(1);
SnakeGame.notifications.add_notification(("<b>" + _local6) + "</b> left.", 4473924);
break;
case "a" :
SnakeGame.notifications.add_notification(("<b>" + msg.substr(1)) + "</b> committed suicide.", 13369344);
break;
case "c" :
var _local7 = _global.parseInt(msg.substr(1), ASCII_RADIX);
SnakeGame.game_stats.setNumClients(_local7);
break;
case "s" :
case "e" :
var _local8 = msg.indexOf(";");
var _local9 = msg.substr(1, _local8).split(",");
var _local10 = _global.parseInt(_local9[0], ASCII_RADIX);
var _local11 = _global.parseInt(_local9[1], ASCII_RADIX);
if (_local3 == "s") {
var _local12 = Tiles.SNAKE;
} else {
var _local12 = Tiles.ENEMY;
}
parse_and_add_report(_local10, _local11, msg.substr(_local8 + 1), _local12);
break;
case "r" :
parse_and_remove_absolute_report(msg.substr(1), Tiles.SNAKE);
break;
case "m" :
parse_and_remove_absolute_report(msg.substr(1), Tiles.ENEMY);
break;
case "o" :
case "f" :
if (_local3 == "o") {
var _local13 = Tiles.WALL;
} else {
var _local13 = Tiles.FOOD;
}
var _local14 = msg.indexOf(";");
var _local15 = msg.substr(1, _local14).split(",");
var _local16 = _global.parseInt(_local15[0], ASCII_RADIX);
var _local17 = _global.parseInt(_local15[1], ASCII_RADIX);
SnakeGame.map.delete_block(_local16, _local17, _local13);
parse_and_add_report(_local16, _local17, msg.substr(_local14 + 1), _local13);
break;
case "p" :
var _local18 = msg.substr(1).split(",");
SnakeGame.snake.setPosition(_global.parseInt(_local18[0], ASCII_RADIX), _global.parseInt(_local18[1], ASCII_RADIX));
Main.app.game_iteration();
break;
case "t" :
Main.app.game_iteration();
break;
case "b" :
var _local19 = msg.substr(1).split(",");
SnakeGame.map.set_size(_global.parseInt(_local19[0], ASCII_RADIX), _global.parseInt(_local19[1], ASCII_RADIX));
break;
case "h" :
var _local20 = msg.substr(1).split(";");
var _local21 = _global.parseInt(_local20[0], ASCII_RADIX);
var _local22 = _global.parseInt(_local20[1], ASCII_RADIX);
var _local23 = [];
var _local24 = 2;
for ( ; _local24 < _local20.length ; _local24++) {
var _local25 = _local20[_local24].split(",");
_local23.push({client_id:_local25[0], score:_global.parseInt(_local25[1], ASCII_RADIX)});
}
var _local26 = 0;
for ( ; _local26 < _local23.length ; _local26++) {
}
SnakeGame.end_round_display.set_winners(_local23);
SnakeGame.end_round_display.set_rank(_local21);
SnakeGame.end_round_display.set_wait_time(_local22);
Main.app.hide();
SnakeGame.end_round_display.show();
break;
case "n" :
var _local27 = _global.parseInt(msg.substr(1), ASCII_RADIX);
SnakeGame.timer_display.set_time(_local27);
SnakeGame.end_round_display.destroy();
Main.app.restart();
Main.app.show();
break;
case "u" :
var _local28 = msg.charAt(1);
var _local29 = _global.parseInt(msg.substr(2), ASCII_RADIX);
if (_local28 == "g") {
SnakeGame.timer_display.set_time(_local29);
} else if (_local28 == "i") {
SnakeGame.end_round_display.set_wait_time(_local29);
Main.app.hide();
SnakeGame.end_round_display.show(true);
}
break;
case "k" :
var _local30 = msg.substr(1);
SnakeGame.notifications.add_notification(("You killed <b>" + _local30) + "</b>!", 255);
SnakeGame.points_display.addPoints("kill");
break;
case "q" :
var _local31 = msg.substr(1).split(";");
var _local32 = _local31[0];
var _local33 = _local31[1];
SnakeGame.notifications.add_notification(((("<b>" + _local32) + "</b> killed <b>") + _local33) + "</b>.", 4473924);
}
}
function onConnect(success) {
if (success) {
Main.app.is_connected = true;
Main.app.resetHostIndex();
Main.app.need_to_send_username = true;
} else {
Main.app.connectToNextHost();
}
}
function onClose() {
Main.app.is_connected = false;
Main.app.hide();
Main.app.destroy();
SnakeGame.intro_screen.show_reconnect();
}
//ASSetPropFlags(_local1, null, 1);
static var PORT = 10123;
static var PACKET_VALUE_OFFSET = 14;
static var ASCII_RADIX = 36;
}
Symbol 20494 MovieClip [__Packages.TimerDisplay] Frame 0
class TimerDisplay
{
var time_remaining, container_mc, update_interval;
function TimerDisplay () {
time_remaining = 0;
container_mc = Main.top_mc.createEmptyMovieClip("timer_container_mc", Main.top_mc.getNextHighestDepth());
container_mc._x = SnakeGame.screen.width_px - 65;
container_mc._y = SnakeGame.screen.height_px - 33;
container_mc._visible = false;
initialize_textfields();
}
function initialize_textfields() {
var _local2 = new TextFormat();
_local2.align = "right";
_local2.font = "Arial";
container_mc.createTextField("time_label_tf", container_mc.getNextHighestDepth(), 0, 0, 58, 15);
var _local3 = container_mc.time_label_tf;
_local3._x = 0;
_local3._y = 0;
_local3.text = "Time Left:";
_local2.color = 4473924 /* 0x444444 */;
_local2.size = 10;
_local2.bold = false;
_local3.setTextFormat(_local2);
container_mc.createTextField("time_tf", container_mc.getNextHighestDepth(), 0, 0, 58, 15);
var _local4 = container_mc.time_tf;
_local4._x = 0;
_local4._y = 13;
_local4.text = "";
_local2.color = 0;
_local2.size = 11;
_local2.bold = true;
_local4.setNewTextFormat(_local2);
}
function show() {
container_mc._visible = true;
}
function hide() {
container_mc._visible = false;
}
function start() {
update_interval = _global.setInterval(Delegate.create(this, update), UPDATE_TIME);
}
function stop() {
_global.clearInterval(update_interval);
}
function set_time(in_seconds) {
time_remaining = in_seconds;
}
function update() {
if (time_remaining < 0) {
container_mc.time_tf.text = "";
} else {
var _local2 = Math.floor(time_remaining / 60);
var _local3 = time_remaining % 60;
container_mc.time_tf.text = ((_local2 + "m ") + _local3) + "s";
time_remaining = time_remaining - (1000 / UPDATE_TIME);
}
}
function destroy() {
stop();
container_mc.removeMovieClip();
}
//ASSetPropFlags(_local1, null, 1);
static var UPDATE_TIME = 1000;
}
Symbol 20495 MovieClip [__Packages.EndRoundDisplay] Frame 0
class EndRoundDisplay
{
var winners_ranked, my_rank, wait_time, container_mc, update_interval;
function EndRoundDisplay () {
}
function set_winners(in_ranked) {
winners_ranked = in_ranked;
}
function set_rank(in_rank) {
my_rank = in_rank;
}
function set_wait_time(in_time) {
wait_time = in_time - 2;
}
function show(is_wait_screen) {
container_mc = Main.top_mc.createEmptyMovieClip("endround_container_mc", Main.top_mc.getNextHighestDepth());
container_mc._x = 0;
container_mc._y = 0;
container_mc.width = SnakeGame.screen.width_px;
container_mc.height = SnakeGame.screen.height_px;
if (is_wait_screen == true) {
show_wait();
show_wait_time(true);
} else {
show_winners();
show_individual_stats();
show_wait_time();
}
}
function show_wait() {
var _local2 = new TextFormat();
_local2.font = "Arial";
container_mc.createTextField("wait_header_tf", container_mc.getNextHighestDepth(), 0, 0, container_mc.width, 100);
var _local3 = container_mc.wait_header_tf;
_local3._x = 0;
_local3._y = (SnakeGame.screen.height_px / 2) - 50;
_local3.antiAliasType = "advanced";
_local3.wordWrap = true;
_local3.text = "You joined the game during our intermission period.";
_local2.align = "center";
_local2.color = 4473924 /* 0x444444 */;
_local2.size = 25;
_local2.bold = false;
_local3.setTextFormat(_local2);
}
function show_winners() {
var _local2 = new TextFormat();
_local2.align = "left";
_local2.font = "Arial";
container_mc.createTextField("winners_label_tf", container_mc.getNextHighestDepth(), 0, 0, container_mc.width, 40);
var _local3 = container_mc.winners_label_tf;
_local3._x = 0;
_local3._y = 10;
_local3.antiAliasType = "advanced";
_local3.text = "The Winners Are:";
_local2.align = "center";
_local2.color = 0;
_local2.size = 35;
_local2.bold = true;
_local3.setTextFormat(_local2);
var _local4 = container_mc.createEmptyMovieClip("winners_table", container_mc.getNextHighestDepth());
_local4.width = 350;
_local4.height = 130;
_local4._x = (SnakeGame.screen.width_px / 2) - (_local4.width / 2);
_local4._y = _local3._y + 50;
Helpers.set_border(_local4, 10027008, 4, 13369344);
container_mc.createTextField("winners_name", container_mc.getNextHighestDepth(), 0, 0, 100, 15);
var _local5 = container_mc.winners_name;
_local5._x = 60;
_local5._y = _local3._y + 55;
_local5.autoSize = true;
_local5.text = "Rank Name Score";
_local2.align = "left";
_local2.color = 16777215 /* 0xFFFFFF */;
_local2.size = 19;
_local2.bold = true;
_local5.setTextFormat(_local2);
_local4.lineStyle(2, 16777215, 100);
_local4.moveTo(7, 35);
_local4.lineTo(_local4.width - 7, 35);
var _local6 = 20;
var _local7 = 0;
for ( ; _local7 < winners_ranked.length ; _local7++) {
var _local8 = "w_name_" + _local7;
var _local9 = "w_score_" + _local7;
container_mc.createTextField(_local8, container_mc.getNextHighestDepth(), 0, 0, 100, 15);
var _local10 = container_mc[_local8];
_local10._x = _local5._x + 20;
_local10._y = ((_local7 * _local6) + _local3._y) + 92;
_local10.autoSize = true;
_local10.html = true;
_local10.htmlText = (("<b>" + (_local7 + 1)) + "</b> ") + winners_ranked[_local7].client_id;
_local2.align = "left";
_local2.color = 16777215 /* 0xFFFFFF */;
_local2.size = 17;
_local2.bold = null;
_local10.setTextFormat(_local2);
container_mc.createTextField(_local9, container_mc.getNextHighestDepth(), 0, 0, 100, 15);
var _local11 = container_mc[_local9];
_local11._x = _local10._x + 260;
_local11._y = _local10._y;
_local11.autoSize = true;
_local2.size = 16;
_local11.text = winners_ranked[_local7].score;
_local11.setTextFormat(_local2);
}
}
function show_individual_stats() {
var _local2 = new TextFormat();
_local2.font = "Arial";
container_mc.createTextField("individual_stats_header", container_mc.getNextHighestDepth(), 0, 0, container_mc.width, 25);
var _local3 = container_mc.individual_stats_header;
_local3._x = 0;
_local3._y = (container_mc.winners_table._y + container_mc.winners_table.height) + 5;
_local3.antiAliasType = "advanced";
_local3.text = "Your statistics:";
_local2.align = "center";
_local2.color = 0;
_local2.size = 20;
_local2.bold = true;
_local3.setTextFormat(_local2);
var _local4 = container_mc.createEmptyMovieClip("individual_stats_table", container_mc.getNextHighestDepth());
_local4.width = 350;
_local4.height = 57;
_local4._x = (SnakeGame.screen.width_px / 2) - (_local4.width / 2);
_local4._y = _local3._y + 30;
Helpers.set_border(_local4, 3368448, 4, 3381504);
_local4.createTextField("individual_header", _local4.getNextHighestDepth(), 0, 0, 100, 15);
var _local5 = _local4.individual_header;
_local5._x = 10;
_local5._y = 3;
_local5.autoSize = true;
_local5.text = "Rank Deaths Kills Food Score";
_local2.align = "left";
_local2.color = 16777215 /* 0xFFFFFF */;
_local2.size = 16;
_local2.bold = true;
_local5.setTextFormat(_local2);
_local4.lineStyle(2, 16777215, 100);
_local4.moveTo(7, 28);
_local4.lineTo(_local4.width - 7, 28);
create_individual_stats_tf("rank", 20, ("<b>" + my_rank) + "</b>", 17);
create_individual_stats_tf("deaths", 90, SnakeGame.points_display.deaths);
create_individual_stats_tf("kills", 160, SnakeGame.points_display.kills);
create_individual_stats_tf("food", 220, SnakeGame.points_display.food);
create_individual_stats_tf("score", 305, SnakeGame.points_display.points);
}
function create_individual_stats_tf(in_name, in_x, in_text, text_size) {
var _local6 = new TextFormat();
_local6.font = "Arial";
container_mc.individual_stats_table.createTextField(in_name, container_mc.individual_stats_table.getNextHighestDepth(), 0, 0, 15, 25);
var _local7 = container_mc.individual_stats_table[in_name];
_local7._x = in_x;
_local7._y = container_mc.individual_stats_table.individual_header._y + 28;
_local7.antiAliasType = "advanced";
_local7.autoSize = true;
_local7.html = true;
_local7.htmlText = in_text;
_local6.align = "left";
_local6.color = 16777215 /* 0xFFFFFF */;
if (typeof(text_size) == "number") {
_local6.size = text_size;
} else {
_local6.size = 16;
}
_local6.bold = null;
_local7.setTextFormat(_local6);
}
function show_wait_time(is_wait_screen) {
var _local3 = new TextFormat();
_local3.font = "Arial";
container_mc.createTextField("wait_time", container_mc.getNextHighestDepth(), 0, 0, container_mc.width, 25);
var _local4 = container_mc.wait_time;
_local4._x = 0;
_local4.antiAliasType = "advanced";
_local4.text = "";
_local3.align = "center";
if (is_wait_screen == true) {
_local4._height = 40;
_local4.wordWrap = true;
_local4._y = (SnakeGame.screen.height_px / 2) + 20;
_local3.color = 10027008 /* 0x990000 */;
_local3.size = 29;
} else {
_local4._y = SnakeGame.screen.height_px - 30;
_local3.color = 4473924 /* 0x444444 */;
_local3.size = 18;
}
_local4.setNewTextFormat(_local3);
update_interval = _global.setInterval(Delegate.create(this, update_wait_time), UPDATE_TIME);
}
function update_wait_time() {
if (wait_time < 0) {
container_mc.wait_time._height = 200;
container_mc.wait_time.htmlText = "Get ready! The next round is starting!";
} else {
var _local2 = Math.floor(wait_time / 60);
var _local3 = wait_time % 60;
if (_local2 > 0) {
container_mc.wait_time.htmlText = ((("The next round starts in " + _local2) + "m ") + _local3) + "s!";
} else {
container_mc.wait_time.htmlText = ("The next round starts in " + _local3) + "s!";
}
wait_time = wait_time - (1000 / UPDATE_TIME);
}
}
function stop_wait_time() {
_global.clearInterval(update_interval);
}
function hide() {
container_mc._visible = false;
}
function destroy() {
stop_wait_time();
container_mc.removeMovieClip();
}
//ASSetPropFlags(_local1, null, 1);
static var UPDATE_TIME = 1000;
}
Symbol 20496 MovieClip [__Packages.SnakeGame] Frame 0
class SnakeGame
{
static var tiles, map, screen, snake, notifications, timer_display, end_round_display, preset_screens, intro_screen, game_stats, points_display, host_index, available_hosts, connection;
var is_connected, web_servers, snake_servers, is_snake_fallback_mode, need_to_send_username;
function SnakeGame () {
is_connected = false;
web_servers = ["www.multisnake.com", "www2.multisnake.com", "www3.multisnake.com"];
snake_servers = ["noserver01.multisnake.com", "noserver02.multisnake.com", "noserver03.multisnake.com", "noserver04.multisnake.com", "noserver05.multisnake.com"];
is_snake_fallback_mode = false;
tiles = new Tiles();
map = new Map();
screen = new Screen();
snake = new Snake();
notifications = new ScrollingNotifications();
timer_display = new TimerDisplay();
end_round_display = new EndRoundDisplay();
preset_screens = new PresetScreens();
intro_screen = new IntroScreen();
game_stats = Main.top_mc.attachMovie(GameStats.symbolName, "gamestats", Main.top_mc.getNextHighestDepth());
game_stats._visible = false;
points_display = Main.top_mc.attachMovie(PointsDisplay.symbolName, "points_display", Main.top_mc.getNextHighestDepth());
if (Main.dev_mode == true) {
onHostsReturned("localhost");
} else {
load_server_manager(web_servers.shift());
}
intro_screen.show_intro();
}
function load_server_manager(in_server) {
if (typeof(in_server) != "string") {
}
System.security.loadPolicyFile(("http://" + in_server) + "/crossdomain.xml");
var _local3 = new LoadVars();
_local3.onData = Delegate.create(this, onHostsReturned);
_local3.load(("http://" + in_server) + "/server_manager/get_server.php");
}
function onHostsReturned(hosts_str) {
if (hosts_str == undefined) {
if (web_servers.length > 0) {
load_server_manager(web_servers.shift());
return(undefined);
}
hosts_str = "NULL";
}
if (hosts_str == "NULL") {
}
host_index = 0;
available_hosts = hosts_str.split(",");
connectToNextHost();
}
function connectToNextHost() {
if ((host_index >= available_hosts.length) || (available_hosts[0] == "NULL")) {
if (is_snake_fallback_mode == false) {
is_snake_fallback_mode = true;
available_hosts = snake_servers;
host_index = 0;
connectToNextHost();
} else {
intro_screen.show_failed_connect_text();
}
} else {
var _local2 = available_hosts[host_index];
host_index++;
connection = new SnakeConnection(_local2);
connection.connect();
}
}
function resetHostIndex() {
host_index = 0;
}
function initialize() {
intro_screen.destroy();
timer_display.show();
timer_display.start();
points_display.show();
var _local2 = new Object();
_local2.onKeyDown = Delegate.create(this, onKeyDown_check);
Key.addListener(_local2);
restart();
}
function onKeyDown_check() {
var _local2 = Key.getCode();
if (!is_introscreen) {
if (is_gameover) {
restart();
} else {
if (preset_screens.direction_tip_MC != undefined) {
preset_screens.hide_direction_tip();
}
switch (_local2) {
case Key.LEFT :
snake.push_move(Snake.WEST);
break;
case Key.RIGHT :
snake.push_move(Snake.EAST);
break;
case Key.UP :
snake.push_move(Snake.NORTH);
break;
case Key.DOWN :
snake.push_move(Snake.SOUTH);
}
}
}
}
function game_iteration() {
screen.update_full();
}
function game_over() {
is_gameover = true;
preset_screens.show_game_over();
}
function restart() {
if (need_to_send_username) {
connection.send_username(username);
need_to_send_username = false;
}
connection.sendReset();
preset_screens.hide_game_over();
points_display.clearPoints();
snake.reset();
game_stats._visible = true;
is_gameover = false;
screen.show_direction_tip = true;
}
function show() {
Main.top_mc.white.removeMovieClip();
points_display.show();
}
function hide() {
if (preset_screens.direction_tip_MC != undefined) {
preset_screens.hide_direction_tip();
}
points_display.hide();
var _local2 = Main.top_mc.createEmptyMovieClip("white", Main.top_mc.getNextHighestDepth());
_local2.width = screen.width_px;
_local2.height = screen.height_px;
Helpers.set_border(_local2, 16777215, 0, 16777215);
}
function destroy() {
show();
points_display.removeMovieClip();
screen.map_mc.removeMovieClip();
notifications.destroy();
timer_display.destroy();
preset_screens.hide_game_over();
intro_screen.destroy();
preset_screens.hide_direction_tip(true);
end_round_display.destroy();
game_stats.removeMovieClip();
Main.top_mc.removeMovieClip();
}
//ASSetPropFlags(_local1, null, 1);
var is_gameover = true;
var is_introscreen = true;
var username = "Guest";
}
Symbol 20497 MovieClip [__Packages.IntroScreen] Frame 0
class IntroScreen
{
var intro_MC, pb_MC, pb_setinterval_id;
function IntroScreen () {
pb_interval_time = Math.floor(pb_max_connect_time / pb_length_max);
}
function show_intro() {
initialize();
show_intro_logos();
show_instruction_link();
show_connecting_to();
}
function show_reconnect() {
initialize();
show_intro_logos();
hide_connecting_to();
intro_set_h1_text("Disconnected from server (timeout).");
var _local2 = function () {
var _local2 = Main.app.username;
Main.app.destroy();
Main.start_game();
Main.app.username = _local2;
};
show_intro_button("Reconnect to server!", Delegate.create(this, _local2));
}
function initialize() {
Main.app.is_introscreen = true;
SnakeGame.screen.map_mc._visible = false;
if (typeof(Main.top_mc.intro) != "movieclip") {
Main.top_mc.createEmptyMovieClip("intro", Main.top_mc.getNextHighestDepth());
intro_MC = Main.top_mc.intro;
intro_MC.width = SnakeGame.screen.width_px;
intro_MC.height = SnakeGame.screen.height_px;
intro_MC._x = 0;
intro_MC._y = 0;
}
}
function show_intro_logos() {
if (typeof(intro_MC.intro_logo) != "movieclip") {
intro_MC.attachMovie("intro_logo", "intro_logo", intro_MC.getNextHighestDepth());
}
if (typeof(intro_MC.product_of) != "movieclip") {
intro_MC.attachMovie("product_supplelabs", "product_of", intro_MC.getNextHighestDepth());
}
var _local2 = intro_MC.intro_logo;
_local2.width = 373;
_local2.height = 100;
_local2._y = 60;
_local2._x = (SnakeGame.screen.width_px / 2) - (_local2.width / 2);
_local2.onRelease = function () {
getURL ("http://www.multisnake.com", "_self");
};
var _local3 = intro_MC.product_of;
_local3.width = 138;
_local3.height = 16;
_local3._x = (SnakeGame.screen.width_px - _local3.width) - 10;
_local3._y = (SnakeGame.screen.height_px - _local3.height) - 2;
_local3.onRelease = function () {
getURL ("http://www.supplelabs.com", "_blank");
};
}
function show_instruction_link() {
var _local2 = new TextFormat();
_local2.align = "left";
_local2.font = "Arial";
intro_MC.createTextField("instruction_link", intro_MC.getNextHighestDepth(), 0, 0, SnakeGame.screen.width_px, 22);
var _local3 = intro_MC.instruction_link;
_local3._y = SnakeGame.screen.height_px - 43;
_local3.html = true;
_local3.htmlText = "Don't know how to play? <a href=\"http://www.multisnake.com/#instructions\"><b>Click here for instructions!</b></a>";
_local2.align = "center";
_local2.color = 4473924 /* 0x444444 */;
_local2.size = 14;
_local2.bold = null;
_local3.setTextFormat(_local2);
}
function show_connecting_to() {
intro_set_h1_text("Please wait. Connecting to server...");
reset_progress_bar();
}
function hide_connecting_to() {
intro_MC.intro_connecting_to.removeTextField();
pb_MC.removeMovieClip();
}
function intro_set_h1_text(in_text, in_color) {
if (typeof(intro_MC.intro_connecting_to) != "object") {
intro_MC.createTextField("intro_connecting_to", intro_MC.getNextHighestDepth(), 0, 0, intro_MC.width, 30);
}
var _local4 = intro_MC.intro_connecting_to;
_local4._x = 0;
_local4._y = (intro_MC.intro_logo._y + intro_MC.intro_logo.height) + 25;
_local4.antiAliasType = "advanced";
_local4.text = in_text;
var _local5 = new TextFormat();
_local5.align = "center";
_local5.font = "Arial";
_local5.size = 20;
_local5.bold = true;
if (in_color == undefined) {
_local5.color = 0;
} else {
_local5.color = in_color;
}
_local4.setTextFormat(_local5);
}
function hide_h1_text() {
intro_MC.intro_connecting_to.removeTextField();
}
function show_intro_body_text(in_text, in_color) {
if (typeof(intro_MC.intro_body) != "object") {
intro_MC.createEmptyMovieClip("intro_body", intro_MC.getNextHighestDepth());
}
var _local4 = intro_MC.intro_body;
pb_MC._visible = false;
_local4.width = 330;
_local4.height = 60;
_local4._x = (SnakeGame.screen.width_px / 2) - (_local4.width / 2);
_local4._y = intro_MC.intro_connecting_to._y + 35;
_local4.createTextField("intro_body_tf", _local4.getNextHighestDepth(), 0, 0, _local4.width, 60);
var _local5 = intro_MC.intro_body.intro_body_tf;
_local5._x = 0;
_local5._y = 0;
_local5.html = true;
_local5.antiAliasType = "advanced";
_local5.multiline = true;
_local5.wordWrap = true;
_local5.htmlText = in_text;
var _local6 = new TextFormat();
_local6.align = "center";
_local6.font = "Arial";
_local6.size = 15;
if (in_color == undefined) {
_local6.color = 0;
} else {
_local6.color = in_color;
}
_local5.setTextFormat(_local6);
}
function show_intro_button(in_text, in_action) {
if (typeof(intro_MC.intro_button) != "movieclip") {
intro_MC.createEmptyMovieClip("intro_button", intro_MC.getNextHighestDepth());
}
var _local4 = intro_MC.intro_button;
pb_MC._visible = false;
_local4.width = 250;
_local4.height = 40;
_local4._x = (SnakeGame.screen.width_px / 2) - (_local4.width / 2);
_local4._y = intro_MC.intro_connecting_to._y + 40;
Helpers.set_border(_local4, 10027008, 4, 13369344);
_local4.createTextField("intro_button_tf", _local4.getNextHighestDepth(), 0, 0, _local4.width, _local4.height);
var _local5 = intro_MC.intro_button.intro_button_tf;
_local5._x = 0;
_local5._y = 6;
_local5.antiAliasType = "advanced";
_local5.text = in_text;
var _local6 = new TextFormat();
_local6.align = "center";
_local6.font = "Arial";
_local6.size = 19;
_local6.bold = true;
_local6.color = 16777215 /* 0xFFFFFF */;
_local5.setTextFormat(_local6);
_local4.onRelease = in_action;
}
function show_username_text() {
intro_MC.createTextField("intro_username_tf", intro_MC.getNextHighestDepth(), 0, 0, 170, 60);
var _local2 = intro_MC.intro_username_tf;
_local2._x = 72;
_local2._y = (intro_MC.intro_logo._y + intro_MC.intro_logo.height) + 24;
_local2.html = true;
_local2.antiAliasType = "advanced";
_local2.selectable = false;
_local2.htmlText = "<b>Enter a nickname:</b>";
var _local3 = new TextFormat();
_local3.align = "center";
_local3.font = "Arial";
_local3.size = 18;
_local3.color = 0;
_local2.setTextFormat(_local3);
intro_MC.createTextField("intro_username_input_tf", intro_MC.getNextHighestDepth(), 0, 0, 110, 10);
var _local4 = intro_MC.intro_username_input_tf;
_local4._x = _local2._x + 180;
_local4._y = (intro_MC.intro_logo._y + intro_MC.intro_logo.height) + 25;
_local4.type = "input";
_local4.border = true;
_local4._height = 23;
_local4.restrict = "A-Za-z0-9_";
_local4.maxChars = 12;
_local4.tabEnabled = true;
_local4.antiAliasType = "advanced";
_local4.text = Main.app.username;
var _local5 = new TextFormat();
_local5.font = "Arial";
_local5.size = 18;
_local5.color = 0;
_local4.setTextFormat(_local5);
_local4.setNewTextFormat(_local5);
var keyListener = new Object();
keyListener.onKeyDown = function () {
if (Key.isDown(Key.ENTER)) {
Key.removeListener(keyListener);
this.intro_click_to_play_action();
}
};
keyListener.onKeyDown = Delegate.create(this, keyListener.onKeyDown);
_local4.onSetFocus = function () {
Key.removeListener(keyListener);
Key.addListener(keyListener);
};
_local4.onKillFocus = function () {
Key.removeListener(keyListener);
};
}
function increment_progress_bar() {
var _local2 = "intro_pb_" + pb_length;
pb_MC.attachMovie(SnakeGame.tiles.Tile_1.library_symbol, _local2, pb_MC.getNextHighestDepth());
pb_MC[_local2]._x = SnakeGame.tiles.size * pb_length;
pb_MC[_local2]._y = 0;
pb_length = pb_length + 1;
if ((Main.app.is_connected == true) || (pb_length > pb_length_max)) {
_global.clearInterval(pb_setinterval_id);
if (Main.app.is_connected == true) {
intro_set_h1_text("");
show_username_text();
show_intro_button("Click here to play!", Delegate.create(this, intro_click_to_play_action));
} else {
reset_progress_bar();
}
}
}
function reset_progress_bar() {
if (typeof(intro_MC.intro_progress_bar) == "movieclip") {
intro_MC.intro_progress_bar.removeMovieClip();
}
pb_MC = intro_MC.createEmptyMovieClip("intro_progress_bar", intro_MC.getNextHighestDepth());
pb_MC.width = SnakeGame.tiles.size * 10;
pb_MC.height = SnakeGame.tiles.size;
pb_MC._x = 45;
pb_MC._y = intro_MC.intro_connecting_to._y + 45;
pb_length = 0;
pb_setinterval_id = _global.setInterval(Delegate.create(this, increment_progress_bar), pb_interval_time);
}
function intro_click_to_play_action() {
Main.app.username = intro_MC.intro_username_input_tf.text;
Main.app.initialize();
}
function show_failed_connect_text() {
_global.clearInterval(pb_setinterval_id);
intro_set_h1_text("Failed to connect to server.", 13369344);
show_intro_body_text("There seems to be a problem with either your computer or our servers. <b>Please refresh this page to try again</b>.");
}
function destroy() {
Main.top_mc.intro.removeMovieClip();
SnakeGame.screen.map_mc._visible = true;
Main.app.is_introscreen = false;
}
//ASSetPropFlags(_local1, null, 1);
var pb_length = 0;
var pb_length_max = 30;
var pb_max_connect_time = 15000;
var pb_interval_time = 300;
}
Symbol 20498 MovieClip [__Packages.PointsDisplay] Frame 0
#initclip
if (!PointsDisplay) {
//(_global.PointsDisplay = function () {
super();
this._x = SnakeGame.screen.width_px - 65;
this._y = 5;
var _local3 = new TextFormat();
_local3.align = "left";
_local3.font = "Arial";
_local3.size = 18;
_local3.bold = true;
_local3.color = 0;
this.createTextField("points_label", this.getNextHighestDepth(), 0, 0, 58, 15);
this.points_label._x = 0;
this.points_label._y = 0;
this.points_label.text = "Your Points:";
_local3.color = 4473924 /* 0x444444 */;
_local3.size = 10;
_local3.bold = false;
this.points_label.setTextFormat(_local3);
this.createTextField("points_text", this.getNextHighestDepth(), 0, 0, 0, 0);
this.points_text._x = -5;
this.points_text._y = 15;
this.points_text._width = 70;
this.points_text._height = 18;
_local3.align = "center";
_local3.color = 0;
_local3.size = 11;
_local3.bold = true;
this.points_text.setNewTextFormat(_local3);
this.clearPoints();
this.hide();
}) extends MovieClip
var _local1 = (_global.PointsDisplay /* register */).prototype;
_local1.hide = function () {
this._visible = false;
};
_local1.show = function () {
this._visible = true;
};
_local1.clearPoints = function () {
this.points = 0;
this.deaths = 0;
this.kills = 0;
this.food = 0;
this.updateDisplay();
};
_local1.addPoints = function (type) {
switch (type) {
case "death" :
this.deaths = this.deaths + 1;
this.points = this.points + -5;
break;
case "kill" :
this.kills = this.kills + 1;
this.points = this.points + 5;
break;
case "food" :
this.food = this.food + 1;
this.points = this.points + 1;
}
this.updateDisplay();
};
_local1.updateDisplay = function () {
this.points_text.text = this.points + " points";
};
ASSetPropFlags(_local1, null, 1);
(_global.PointsDisplay /* register */).symbolName = "__Packages.PointsDisplay";
(_global.PointsDisplay /* register */).symbolOwner = PointsDisplay;
(_global.PointsDisplay /* register */).symbolLinked = Object.registerClass(PointsDisplay.symbolName, PointsDisplay.symbolOwner);
}
#endinitclip
Symbol 20499 MovieClip [__Packages.ScrollingNotifications] Frame 0
class ScrollingNotifications
{
var container_mc, scroll_interval;
function ScrollingNotifications () {
container_mc = Main.top_mc.createEmptyMovieClip("container_mc", Main.top_mc.getNextHighestDepth());
container_mc._x = XOFFSET;
container_mc._y = YOFFSET;
scroll_interval = _global.setInterval(Delegate.create(this, remove_top), SCROLL_TIME);
}
function add_notification(in_text, in_color) {
var _local4 = "sn_" + msg_count;
container_mc.createTextField(_local4, container_mc.getNextHighestDepth(), 0, 0, 100, TEXT_HEIGHT_PX);
var _local5 = container_mc[_local4];
_local5._x = 0;
_local5._y = msg_count * TEXT_HEIGHT_PX;
_local5.autoSize = true;
_local5.html = true;
_local5.htmlText = in_text;
var _local6 = new TextFormat();
_local6.align = "left";
_local6.font = "Arial";
_local6.size = 11;
if (in_color == undefined) {
in_color = 0;
}
_local6.color = in_color;
_local5.setTextFormat(_local6);
if (msg_ids.length >= MAX_LINES) {
remove_top();
}
msg_ids.push(_local4);
msg_count++;
}
function remove_top() {
var _local2 = msg_ids.shift();
if ((typeof(_local2) == "string") && (_local2.substring(0, 3) == "sn_")) {
container_mc[_local2].removeTextField();
container_mc._y = container_mc._y - TEXT_HEIGHT_PX;
}
}
function destroy() {
_global.clearInterval(scroll_interval);
container_mc.removeMovieClip();
}
//ASSetPropFlags(_local1, null, 1);
static var XOFFSET = 5;
static var YOFFSET = 5;
static var MAX_LINES = 3;
static var SCROLL_TIME = 5000;
var msg_count = 0;
var msg_ids = new Array();
static var TEXT_HEIGHT_PX = 15;
}
Symbol 20500 MovieClip [__Packages.Main] Frame 0
class Main
{
static var app, top_mc;
function Main () {
}
static function start_game() {
app = new SnakeGame();
}
static function main(mc) {
top_mc = mc;
var _local3 = Helpers.get_url_parameters();
if (_local3.dev != undefined) {
dev_mode = true;
start_game();
} else {
__com_mochibot__("43b27830", mc, 10301, true);
MochiAd.showPreGameAd({id:"2b13ab508dfddc31", res:"440x320", ad_finished:start_game});
}
}
static function __com_mochibot__(swfid, mc, lv, trk) {
var _local13 = "__mochibot__";
var _local14 = "mochibot.com";
var _local7 = (_global ? (_global) : (_level0._root));
if (_local7[_local13 + swfid]) {
return(_local7[_local13 + swfid]);
}
var _local8 = System.security;
var _local6 = mc._root.getSWFVersion;
var _local9 = (_local6 ? (mc.getSWFVersion()) : ((_global ? 6 : 5)));
if (!_local8) {
_local8 = {};
}
var _local10 = _local8.sandboxType;
if (_local10 == "localWithFile") {
return(null);
}
_local6 = _local8.allowDomain;
if (_local6) {
_local8.allowDomain(_local14);
}
_local6 = _local8.allowInsecureDomain;
if (_local6) {
_local8.allowInsecureDomain(_local14);
}
var _local11 = (((((((((((("http://" + _local14) + "/my/core.swf?mv=7&fv=") + _local9) + "&v=") + _global.escape(getVersion())) + "&swfid=") + _global.escape(swfid)) + "&l=") + lv) + "&f=") + mc) + (_local10 ? ("&sb=" + _local10) : "")) + (trk ? "&t=1" : "");
lv = ((_local9 > 6) ? (mc.getNextHighestDepth()) : ((_local7[_local13 + "level"] ? (_local7[_local13 + "level"] + 1) : (lv))));
_local7[_local13 + "level"] = lv;
if (_local9 == 5) {
var _local12 = "_level" + lv;
} else {
var _local12 = mc.createEmptyMovieClip(_local13 + swfid, lv);
_local12.loadMovie(_local11);
}
return(_local12);
}
//ASSetPropFlags(_local1, null, 1);
static var dev_mode = false;
}