Section 1
//Achievement (achievements.Achievement)
package achievements {
public class Achievement {
private var mSubmitted:Boolean;// = false
private var mDescription:String;// = ""
private var mName:String;// = ""
private var mCompleted:Boolean;// = false
public function Achievement(name:String, description:String){
mName = "";
mDescription = "";
mCompleted = false;
mSubmitted = false;
super();
mName = name;
mDescription = description;
}
public function IsComplete():Boolean{
return (mCompleted);
}
public function MarkAsSubmitted():void{
mSubmitted = true;
}
public function MarkAsCompleted():void{
mCompleted = true;
}
public function IsSubmitted():Boolean{
return (mSubmitted);
}
public function Name():String{
return (mName);
}
public function Description():String{
return (mDescription);
}
}
}//package achievements
Section 2
//Achievements (achievements.Achievements)
package achievements {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import security.*;
import flash.net.*;
public class Achievements {
private static var sLittlegreyID:int = -1;
private static var sAchievementsDisplay:MovieClip;
private static var sGameHighscoreID:int = -1;
private static var sNotifyFunction:Function = null;
private static var sDYOGServerLocation:String = "http://localhost/";
private static var sAvatarPrefix:int = -1;
private static var sLittlegreyServerLocation:String = "http://www.littlegrey.net/";
private static var sUserKey:String = "";
private static var sConsole:TextField;
private static var sUsername:String = "";
private static var sAchievements:Array;
private static var sNotifyFunctionCaller:Object = null;
public function Achievements(){
super();
}
public static function SubmitScore(gameHighscoreID:int, score:int):void{
var key:String;
var scoreLoader:URLLoader;
var submitScoreURL:String;
sGameHighscoreID = gameHighscoreID;
if ((((sLittlegreyID > 0)) && (DomainCheck.CanSubmitHighscores()))){
key = SHA1Hash.SHA1((((String(sGameHighscoreID) + String(score)) + MemoryCrypto.getString("highscore_password")) + String(sLittlegreyID)));
scoreLoader = new URLLoader();
scoreLoader.addEventListener(Event.COMPLETE, onSubmitScoreComplete, false, 0, true);
scoreLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitScoreError, false, 0, true);
scoreLoader.addEventListener(IOErrorEvent.IO_ERROR, onSubmitScoreError, false, 0, true);
submitScoreURL = ((((((((sDYOGServerLocation + "high_scores/exclusive/auto_submit_score.php?user_id=") + sLittlegreyID) + "&game_id=") + sGameHighscoreID) + "&score=") + score) + "&key=") + key);
scoreLoader.load(new URLRequest(submitScoreURL));
consoleMessage(("Submitting highscore: " + submitScoreURL));
};
}
public static function CompletedAchievement(achievementID:int):void{
var alreadyCompleted:Boolean;
var key:String;
var achievementLoader:URLLoader;
var submitAchievementURL:String;
consoleMessage(("Completed achievement " + achievementID));
if (sAchievements[achievementID] == null){
trace(("***** ERROR: Unknown achievement id: " + achievementID));
return;
};
alreadyCompleted = sAchievements[achievementID].IsComplete();
sAchievements[achievementID].MarkAsCompleted();
trace(("Achievement completed: " + achievementID));
if (((!(alreadyCompleted)) && (!((sNotifyFunction == null))))){
sNotifyFunction.call(sNotifyFunctionCaller, sAchievements[achievementID].Name());
};
if (((((!(alreadyCompleted)) && ((sLittlegreyID > 0)))) && (DomainCheck.CanSubmitHighscores()))){
key = SHA1Hash.SHA1(((String(achievementID) + MemoryCrypto.getString("highscore_password")) + String(sLittlegreyID)));
achievementLoader = new URLLoader();
achievementLoader.addEventListener(Event.COMPLETE, onSubmitAchievementComplete, false, 0, true);
achievementLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitAchievementError, false, 0, true);
achievementLoader.addEventListener(IOErrorEvent.IO_ERROR, onSubmitAchievementError, false, 0, true);
submitAchievementURL = ((((((sDYOGServerLocation + "high_scores/exclusive/auto_submit_achievement.php?user_id=") + sLittlegreyID) + "&achievement=") + achievementID) + "&key=") + key);
achievementLoader.load(new URLRequest(submitAchievementURL));
consoleMessage(("Transmitting achievement: " + submitAchievementURL));
};
}
public static function LoadUserFromQueryString(parameters:Object):void{
var keyStr:String;
var valueStr:String;
for (keyStr in parameters) {
valueStr = String(parameters[keyStr]);
if (keyStr == "user_key"){
sUserKey = valueStr;
};
};
LoadUserFromKey(sUserKey);
}
private static function submitScoreError(message:String):void{
trace(("***** Submit Score Response Error: " + message));
consoleMessage(("***** Submit Score Response Error: " + message));
}
public static function errorOnGetUserProfile(message:String){
trace(message);
consoleMessage(message);
}
private static function onSubmitAchievementError(event:Event):void{
event.target.removeEventListener(Event.COMPLETE, onSubmitAchievementComplete);
event.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitAchievementError);
event.target.removeEventListener(IOErrorEvent.IO_ERROR, onSubmitAchievementError);
submitAchievementError(event);
}
private static function submitAchievementError(message:String):void{
trace(("***** Submit Achievement Response Error: " + message));
consoleMessage(("***** Submit Achievement Response Error: " + message));
}
private static function onSubmitScoreComplete(event:Event):void{
var scoreSubmitted:Boolean;
var responseXML:XML;
var allAchievementsSubmitted:Boolean;
var achievement:Achievement;
var gameID:int;
event.target.removeEventListener(Event.COMPLETE, onSubmitScoreComplete);
event.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitScoreError);
event.target.removeEventListener(IOErrorEvent.IO_ERROR, onSubmitScoreError);
scoreSubmitted = false;
responseXML = new XML(event.target.data);
if (responseXML.length() == 0){
submitAchievementError("xml is malformed.");
return;
};
if (responseXML.game_id != undefined){
gameID = responseXML.game_id;
if (gameID == sGameHighscoreID){
trace("Successfully submitted highscore.");
consoleMessage("Successfully submitted highscore.");
scoreSubmitted = true;
} else {
submitAchievementError("unknown game id");
};
} else {
submitScoreError("no game id");
return;
};
allAchievementsSubmitted = true;
for each (achievement in Achievements.sAchievements) {
if (((achievement.IsComplete()) && (!(achievement.IsSubmitted())))){
allAchievementsSubmitted = false;
};
};
if (((allAchievementsSubmitted) && (scoreSubmitted))){
sAchievementsDisplay["mcSubmitButton"].visible = false;
sAchievementsDisplay["txAutoSubmitText"].text = (("Congratulations " + sUsername) + "! Your score and achievements have automatically been submitted.");
sAchievementsDisplay["txAutoSubmitText"].visible = true;
};
}
public static function SetAchievement(id:int, name:String, description:String):void{
if (sAchievements == null){
sAchievements = new Array();
};
if (sAchievements[id] == null){
sAchievements[id] = new Achievement(name, description);
};
}
public static function Initialize(gLittlegreyServerLocation:String, gDYOGServerLocation:String):void{
sLittlegreyServerLocation = gLittlegreyServerLocation;
sDYOGServerLocation = gDYOGServerLocation;
}
public static function SetNotifyFunction(func:Function, caller:Object):void{
sNotifyFunction = func;
sNotifyFunctionCaller = caller;
}
private static function onUserProfileLoadXMLError(event:Event):void{
event.target.removeEventListener(Event.COMPLETE, onUserProfileLoadXMLComplete);
event.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onUserProfileLoadXMLError);
event.target.removeEventListener(IOErrorEvent.IO_ERROR, onUserProfileLoadXMLError);
errorOnGetUserProfile(event);
}
public static function GetAchievementsString():String{
var achievementsString:String;
var first:Boolean;
var id:*;
var achievement:Achievement;
achievementsString = "";
first = true;
for (id in sAchievements) {
achievement = sAchievements[id];
if (achievement.IsComplete()){
if (!first){
achievementsString = (achievementsString + "-");
};
achievementsString = (achievementsString + id.toString());
first = false;
};
};
return (achievementsString);
}
private static function onSubmitScoreError(event:Event):void{
event.target.removeEventListener(Event.COMPLETE, onSubmitScoreComplete);
event.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitScoreError);
event.target.removeEventListener(IOErrorEvent.IO_ERROR, onSubmitScoreError);
submitScoreError(event);
}
public static function Display(display:MovieClip):void{
sAchievementsDisplay = display;
if (sAchievementsDisplay != null){
sAchievementsDisplay.Display();
};
}
private static function onUserProfileLoadXMLComplete(event:Event):void{
var profileXML:XML;
var userNode:*;
var message:String;
var event = event;
event.target.removeEventListener(Event.COMPLETE, onUserProfileLoadXMLComplete);
event.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onUserProfileLoadXMLError);
event.target.removeEventListener(IOErrorEvent.IO_ERROR, onUserProfileLoadXMLError);
profileXML = new XML(event.target.data);
if (profileXML.length() == 0){
errorOnGetUserProfile("***** User profile xml is malformed.");
return;
};
userNode = profileXML.user.(@key == String(sUserKey));
if (userNode.length() != 0){
sLittlegreyID = userNode.id;
sUsername = userNode.username;
sAvatarPrefix = userNode.avatar_prefix;
message = (((("Loaded profile data for " + sUsername) + " (id:") + sLittlegreyID) + ")");
trace(message);
consoleMessage(message);
} else {
errorOnGetUserProfile("***** Could not locate user id in user profile xml");
return;
};
}
public static function LoadUserFromKey(userKey:String):void{
var profileLoader:URLLoader;
var getProfileURL:String;
consoleMessage(("Loading user from key: " + userKey));
if (userKey != ""){
sUserKey = userKey;
profileLoader = new URLLoader();
profileLoader.addEventListener(Event.COMPLETE, onUserProfileLoadXMLComplete, false, 0, true);
profileLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onUserProfileLoadXMLError, false, 0, true);
profileLoader.addEventListener(IOErrorEvent.IO_ERROR, onUserProfileLoadXMLError, false, 0, true);
getProfileURL = ((sLittlegreyServerLocation + "get_user_profile_data_from_key.php?key[]=") + sUserKey);
getProfileURL = (getProfileURL + "&remove=1");
profileLoader.load(new URLRequest(getProfileURL));
} else {
sLittlegreyID = -1;
sUsername = "";
sAvatarPrefix = -1;
};
}
public static function SetConsole(console:TextField):void{
sConsole = console;
}
public static function consoleMessage(message:String):void{
if (sConsole != null){
sConsole.htmlText = (sConsole.htmlText + message);
};
}
private static function onSubmitAchievementComplete(event:Event):void{
var responseXML:XML;
var achievementID:int;
event.target.removeEventListener(Event.COMPLETE, onSubmitAchievementComplete);
event.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitAchievementError);
event.target.removeEventListener(IOErrorEvent.IO_ERROR, onSubmitAchievementError);
responseXML = new XML(event.target.data);
if (responseXML.length() == 0){
submitAchievementError("xml is malformed.");
return;
};
if (responseXML.id != undefined){
achievementID = responseXML.id;
if (sAchievements[achievementID] != null){
sAchievements[achievementID].MarkAsSubmitted();
trace(("Successfully submitted achievement " + achievementID));
consoleMessage(("Successfully submitted achievement " + achievementID));
} else {
submitAchievementError("unknown achievement id");
};
} else {
submitAchievementError("no achievement id");
return;
};
}
public static function GetAchievements():Array{
return (sAchievements);
}
public static function FakeLoad(id:int, username:String, avatarPrefix:int):void{
sLittlegreyID = id;
sUsername = username;
sAvatarPrefix = avatarPrefix;
consoleMessage((((("Loaded fake user: " + username) + " (") + id) + ")"));
}
}
}//package achievements
Section 3
//AchievementsDisplay (achievements.AchievementsDisplay)
package achievements {
import flash.display.*;
public dynamic class AchievementsDisplay extends MovieClip {
public function AchievementsDisplay(){
super();
}
public function Display():void{
var i:uint;
var sortedAchievements:Array;
var id:*;
var o:*;
var obj:Object;
var achievement:Achievement;
i = 1;
sortedAchievements = new Array();
for (id in Achievements.GetAchievements()) {
obj = new Object();
obj.ach = Achievements.GetAchievements()[id];
obj.id = id;
sortedAchievements.push(obj);
};
sortedAchievements.sortOn("id");
for each (o in sortedAchievements) {
achievement = o.ach;
this[("tfName" + i)].text = (achievement.Name() + ":");
this[("tfDescription" + i)].text = achievement.Description();
if (achievement.IsComplete()){
this[("mcIncomplete" + i)].visible = false;
this[("mcEarned" + i)].visible = true;
this[("mcIcon" + i)].alpha = 1;
this[("mcIcon" + i)].gotoAndStop(2);
} else {
this[("mcIncomplete" + i)].visible = true;
this[("mcEarned" + i)].visible = false;
this[("mcIcon" + i)].alpha = 0.8;
};
i++;
};
this["txAutoSubmitText"].visible = false;
}
}
}//package achievements
Section 4
//AdServer (adserver.AdServer)
package adserver {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class AdServer {
private static var sPendingDisplayAd:Boolean = false;
private static var sCurrentAd:Number = -1;
private static var sEnabled:Boolean = false;
private static var sDomain:String;
private static var sInitialized:Boolean = false;
private static var sAdContainer:MovieClip = null;
private static var sGameName:String;
private static var sXML:XML;
private static var sAds:Array;
public function AdServer(){
super();
}
private static function loadSWFComplete(event:Event):void{
var info:LoaderInfo;
var i:Number;
info = (event.target as LoaderInfo);
if (info){
info.loader.removeEventListener(Event.COMPLETE, loadSWFComplete);
i = 0;
while (i < sAdContainer["msAdArea"].numChildren) {
sAdContainer["msAdArea"].removeChildAt(i);
i++;
};
sAdContainer["msAdArea"].addChild(info.content);
sAdContainer.visible = true;
};
}
public static function Enable(enabled:Boolean):void{
sEnabled = enabled;
}
public static function AdClicked():void{
var url:URLRequest;
if (sAds[sCurrentAd] != null){
url = new URLRequest(sAds[sCurrentAd].URL());
navigateToURL(url, "_blank");
};
}
public static function DisplayAd(adContainer:MovieClip):void{
if (!sEnabled){
adContainer.visible = false;
return;
};
sAdContainer = adContainer;
sAdContainer.visible = false;
if (!sInitialized){
Initialize(sAdContainer);
sPendingDisplayAd = true;
return;
};
if ((((sAds == null)) || ((sAds.length == 0)))){
adContainer.visible = false;
return;
};
sCurrentAd++;
if (sCurrentAd >= sAds.length){
sCurrentAd = 0;
};
trace(("Displaying ad #" + sCurrentAd));
trace(("Image: " + sAds[sCurrentAd].ImageURL()));
loadSWF(sAds[sCurrentAd].ImageURL());
sAdContainer["msText"].text = sAds[sCurrentAd].BelowText();
}
static function onloadXMLComplete(event:Event):void{
var gameNode:*;
var siteNode:*;
var ad:XML;
var adURL:String;
var adImage:String;
var belowText:String;
var event = event;
sInitialized = true;
sXML = new XML(event.target.data);
if (sXML.length() == 0){
trace("***** ERROR: Could not load adspec xml");
sAdContainer.visible = false;
return;
};
gameNode = sXML.game.(@name == sGameName);
if (gameNode.length() == 0){
trace("Using default ad...");
gameNode = sXML.default_ad;
if (gameNode.length() == 0){
trace("***** ERROR: Could not load game xml node");
sAdContainer.visible = false;
return;
};
};
siteNode = sXML.game.site.(@domain == sDomain);
if (siteNode.length() > 0){
gameNode = siteNode;
};
trace("Iterating through game nodes...");
for each (ad in gameNode.children()) {
if (ad.name() == "ad"){
adURL = ad.url;
adImage = ad.image;
belowText = ad.text;
if (!(((((((((adURL == null)) || ((adImage == null)))) || ((belowText == null)))) || ((adURL == "")))) || ((adImage == "")))){
sAds.push(new Advertisement(adURL, adImage, belowText));
};
};
};
if (sPendingDisplayAd){
sPendingDisplayAd = false;
DisplayAd(sAdContainer);
};
}
public static function Initialize(adContainer:MovieClip):void{
var lc:LocalConnection;
var loader:URLLoader;
if (!sEnabled){
adContainer.visible = false;
return;
};
trace("Initializing ad server...");
lc = new LocalConnection();
sDomain = lc.domain;
sAdContainer = adContainer;
sAds = new Array();
sCurrentAd = 0;
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onloadXMLComplete);
loader.load(new URLRequest("http://gameads.digyourowngrave.com/468x60/adspec_v2.xml"));
}
private static function loadSWF(url:String){
var urlRequest:URLRequest;
var loader:Loader;
urlRequest = new URLRequest(url);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadSWFComplete);
loader.load(urlRequest);
}
public static function SetGameName(gameName:String):void{
sGameName = gameName;
}
}
}//package adserver
Section 5
//Advertisement (adserver.Advertisement)
package adserver {
import adserver.*;
class Advertisement {
private var mImageURL:String;// = ""
private var mURL:String;// = ""
private var mBelowText:String;// = ""
function Advertisement(url:String, image:String, belowText:String){
mURL = "";
mImageURL = "";
mBelowText = "";
super();
mURL = url;
mImageURL = image;
mBelowText = belowText;
}
public function URL():String{
return (mURL);
}
public function ImageURL():String{
return (mImageURL);
}
public function BelowText():String{
return (mBelowText);
}
}
}//package adserver
Section 6
//MainTimeline (arachnophilia_fla.MainTimeline)
package arachnophilia_fla {
import game.*;
import flash.events.*;
import flash.text.*;
import flash.display.*;
import audio.*;
import flash.media.*;
import achievements.*;
import security.*;
import performance.*;
import adserver.*;
import mochi.*;
import flash.ui.*;
import loader.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class MainTimeline extends MovieClip {
public var gsMuteMusic:MuteMusicButton;
public var tfVersion:TextField;
public var gSkipSplashes:Boolean;
public var gMochiID:String;
public var gAllowAllDomains:Boolean;
public var gShowAds:Boolean;
public var gGameMode:uint;
public var mcFlashVersionWarning:VersionWarning;
public var gHighscoreDomains:Array;
public var gVersion:String;
public var gMultiplayer:Boolean;
public var v1:Number;
public var v4:Number;
public var v2:Number;
public var v3:Number;
public var rV3:Number;
public var rV4:Number;
public var userVersion:String;
public var gAdExemptDomains:Array;
public var rV2:Number;
public var btnCredits:SimpleButton;
public var gsDYOGButton:InvisibleDYOGButton;
public var rV1:Number;
public var requireUpdate:Boolean;
public var sgUpdateFlashButton:SimpleButton;
public var gMinFlashVersion:String;
public var gsSoundAnchorMusic:MovieClip;
public var strippedMenu:ContextMenu;
public var gsGame:Game;
public var sgSponsorButton:SimpleButton;
public var gsMuteSfx:MuteSfxButton;
public var gGameName:String;
public var btnGameMode1:SimpleButton;
public var btnGameMode2:SimpleButton;
public var submitBtn;
public var gsLoadingBar:LoadingBar;
public var gFakeLoading:Boolean;
public var gDYOGServerLocation:String;
public var gsSoundAnchorSfx:MovieClip;
public var tfYourVersion:TextField;
public var btnBack:SimpleButton;
public var gMoreGamesURL:String;
public var tfRequiredVersion:TextField;
public var gGamePostURL:String;
public var gHighscoreSubmissionURL:String;
public var gPrerollAdExemptDomains:Array;
public var gHighscoreGameID:Number;
public var gShowStats:Boolean;
public var gAllowedDomains:Array;
public var gGameURL:String;
public var gSponsorURL:String;
public var sgHighscoresButton:SimpleButton;
public var sgMoreGamesButton:SimpleButton;
public var gBlockLocalhost:Boolean;
public var sgExclusivePlayButton:SimpleButton;
public var gLittlegreyServerLocation:String;
public function MainTimeline(){
super();
addFrameScript(0, frame1, 1, frame2, 4, frame5, 244, frame245, 246, frame247, 247, frame248, 248, frame249, 249, frame250);
}
public function SubmitScoreAndAchievements(event:MouseEvent):void{
var achievementsString:String;
var postKeyString:String;
var score:Number;
var highscoreKey:String;
var submitScoreURL:String;
var url:URLRequest;
achievementsString = Achievements.GetAchievementsString();
postKeyString = (gHighscoreGameID.toString() + achievementsString);
score = Math.floor(root.gsGame.GetScore());
highscoreKey = SHA1(((score.toString() + MemoryCrypto.getString("highscore_password")) + postKeyString));
if (!DomainCheck.CanSubmitHighscores()){
highscoreKey = SHA1(((score.toString() + MemoryCrypto.getString("baddomain_highscore_password")) + postKeyString));
};
submitScoreURL = (((((((gDYOGServerLocation + "high_scores/exclusive/submit_score/") + gHighscoreGameID) + "/") + score) + "/") + highscoreKey) + "/");
if (achievementsString != ""){
submitScoreURL = (submitScoreURL + (achievementsString + "/"));
};
url = new URLRequest(submitScoreURL);
navigateToURL(url, "_blank");
}
public function PlayOnDYOG(event:Event):void{
var url:URLRequest;
url = new URLRequest(gGameURL);
navigateToURL(url, "_blank");
}
public function doLoad():void{
var loadedPercent:Number;
if (gFakeLoading){
gsLoadingBar.mLoadedSoFar++;
} else {
gsLoadingBar.mLoadedSoFar = loaderInfo.bytesLoaded;
};
if (gsLoadingBar.mLoadedSoFar >= gsLoadingBar.mLoadRequired){
trace("Finished loading.");
gsLoadingBar.Finished();
root.gotoAndPlay(1, "DYOGSplash");
} else {
loadedPercent = Math.ceil(((gsLoadingBar.mLoadedSoFar / gsLoadingBar.mLoadRequired) * 100));
if (loadedPercent > 100){
loadedPercent = 100;
};
gsLoadingBar["msLoadbar"].scaleX = (loadedPercent / 100);
gsLoadingBar["msPercentLoaded"].text = (Math.ceil(loadedPercent) + "%");
gsLoadingBar["msLoadingText"].text = (("Loading '" + gGameName) + "'...");
};
}
public function MoreGames(event:MouseEvent):void{
var url:URLRequest;
url = new URLRequest(gMoreGamesURL);
navigateToURL(url, "_blank");
}
public function UpdateFlashPlayer(event:Event):void{
var url:URLRequest;
url = new URLRequest("http://www.adobe.com/support/flashplayer/downloads.html");
navigateToURL(url, "");
}
function frame2(){
stop();
strippedMenu = new ContextMenu();
strippedMenu.hideBuiltInItems();
root.contextMenu = strippedMenu;
if (gFakeLoading){
gsLoadingBar.mLoadRequired = 120;
} else {
gsLoadingBar.mLoadRequired = loaderInfo.bytesTotal;
};
if ((((root.gHideDYOGLoader == true)) && (!(gFakeLoading)))){
if (loaderInfo.bytesLoaded >= loaderInfo.bytesTotal){
gsLoadingBar.visible = false;
};
};
}
function frame5(){
root.gsDYOGButton.addEventListener(MouseEvent.MOUSE_UP, ClickedSplashScreen);
root.gsDYOGButton.useHandCursor = true;
root.gsDYOGButton.buttonMode = true;
if (gSkipSplashes){
if (gMultiplayer){
root.gotoAndPlay("multiplayer", "MainMenu");
} else {
root.gotoAndPlay("singleplayer", "MainMenu");
};
} else {
trace("Playing DYOG splashscreen...");
};
}
function frame1(){
gVersion = "1.2";
gSkipSplashes = false;
gFakeLoading = false;
gGameName = "Arachnophilia";
gMinFlashVersion = "9.0.124.0";
gGameURL = "http://www.digyourowngrave.com/arachnophilia-spider-web-game/";
gGamePostURL = "http://www.digyourowngrave.com/2008/arachnophilia-the-spider-web-game/";
gMoreGamesURL = "http://www.digyourowngrave.com/category/games/";
gSponsorURL = "http://www.digyourowngrave.com/";
gHighscoreSubmissionURL = "http://www.digyourowngrave.com/high_scores/exclusive/submit_score";
gHighscoreGameID = 172;
MemoryCrypto.setString("highscore_password", "troisdixchix");
MemoryCrypto.setString("baddomain_highscore_password", "baddomain");
gAllowAllDomains = true;
gBlockLocalhost = true;
gAllowedDomains = new Array("digyourowngrave.com");
gHighscoreDomains = new Array("digyourowngrave.com");
gShowAds = true;
gAdExemptDomains = new Array("digyourowngrave.com");
gPrerollAdExemptDomains = new Array("littlegrey.net", "digyourowngrave.com", "armorgames.com", "addictinggames.com", "kongregate.com");
gShowStats = false;
gMultiplayer = false;
gGameMode = 1;
gLittlegreyServerLocation = "http://www.littlegrey.net/";
gDYOGServerLocation = "http://www.digyourowngrave.com/";
gMochiID = "96d25c2641a6f32e";
if (root.gPrerollAdExemptDomains != null){
DomainCheck.SetAdExemptDomains(root.gPrerollAdExemptDomains);
};
if (((((!((root.gMochiID == null))) && (!((root.gMochiID == ""))))) && (!(DomainCheck.IsAdExempt())))){
root.gHideDYOGLoader = true;
MochiAd.showPreGameAd({clip:root, id:gMochiID, res:"640x480", background:0, color:5658782, outline:0xFFFFFF, no_bg:true});
};
}
public function PlayButtonDownSound(event:MouseEvent):void{
AudioEngine.PlaySound("sfxButtonDown", AudioEngine.SFX_CHANNEL);
}
public function ClickedAd(event:MouseEvent):void{
AdServer.AdClicked();
}
public function ReplayGame(event:MouseEvent):void{
root.gsGame.Restart();
}
public function ShowCredits(event:MouseEvent):void{
root.gotoAndPlay("credits", "MainMenu");
}
public function MainMenu(event:MouseEvent):void{
root.gotoAndPlay("singleplayer", "MainMenu");
}
public function ViewHighscores(event:MouseEvent):void{
var url:URLRequest;
url = new URLRequest(gGamePostURL);
navigateToURL(url, "_blank");
}
public function GotToSponsorSite(event:MouseEvent):void{
var url:URLRequest;
url = new URLRequest(gSponsorURL);
navigateToURL(url, "_blank");
}
public function BackButton(event:MouseEvent):void{
root.gotoAndPlay(root.gBackPoint, "MainMenu");
}
public function SHA1(msg){
var rotate_left:*;
var lsb_hex:*;
var cvt_hex:*;
var Utf8Encode:*;
var blockstart:*;
var i:*;
var j:*;
var W:*;
var H0:*;
var H1:*;
var H2:*;
var H3:*;
var H4:*;
var A:*;
var B:*;
var C:*;
var D:*;
var E:*;
var temp:*;
var msg_len:*;
var word_array:*;
var msg = msg;
rotate_left = function (n, s){
var t4:*;
t4 = ((n << s) | (n >>> (32 - s)));
return (t4);
};
lsb_hex = function (val){
var str:*;
var i:*;
var vh:*;
var vl:*;
str = "";
i = 0;
while (i <= 6) {
vh = ((val >>> ((i * 4) + 4)) & 15);
vl = ((val >>> (i * 4)) & 15);
str = (str + (vh.toString(16) + vl.toString(16)));
i = (i + 2);
};
return (str);
};
cvt_hex = function (val){
var str:*;
var i:*;
var v:*;
str = "";
i = 7;
while (i >= 0) {
v = ((val >>> (i * 4)) & 15);
str = (str + v.toString(16));
i--;
};
return (str);
};
Utf8Encode = function (string){
var utftext:*;
var n:*;
var c:*;
utftext = "";
n = 0;
while (n < string.length) {
c = string.charCodeAt(n);
if (c < 128){
utftext = (utftext + String.fromCharCode(c));
} else {
if ((((c > 127)) && ((c < 0x0800)))){
utftext = (utftext + String.fromCharCode(((c >> 6) | 192)));
utftext = (utftext + String.fromCharCode(((c & 63) | 128)));
} else {
utftext = (utftext + String.fromCharCode(((c >> 12) | 224)));
utftext = (utftext + String.fromCharCode((((c >> 6) & 63) | 128)));
utftext = (utftext + String.fromCharCode(((c & 63) | 128)));
};
};
n++;
};
return (utftext);
};
W = new Array(80);
H0 = 1732584193;
H1 = 4023233417;
H2 = 2562383102;
H3 = 271733878;
H4 = 3285377520;
msg = Utf8Encode(msg);
msg_len = msg.length;
word_array = new Array();
i = 0;
while (i < (msg_len - 3)) {
j = ((((msg.charCodeAt(i) << 24) | (msg.charCodeAt((i + 1)) << 16)) | (msg.charCodeAt((i + 2)) << 8)) | msg.charCodeAt((i + 3)));
word_array.push(j);
i = (i + 4);
};
switch ((msg_len % 4)){
case 0:
i = 2147483648;
break;
case 1:
i = ((msg.charCodeAt((msg_len - 1)) << 24) | 0x800000);
break;
case 2:
i = (((msg.charCodeAt((msg_len - 2)) << 24) | (msg.charCodeAt((msg_len - 1)) << 16)) | 0x8000);
break;
case 3:
i = ((((msg.charCodeAt((msg_len - 3)) << 24) | (msg.charCodeAt((msg_len - 2)) << 16)) | (msg.charCodeAt((msg_len - 1)) << 8)) | 128);
break;
};
word_array.push(i);
while ((word_array.length % 16) != 14) {
word_array.push(0);
};
word_array.push((msg_len >>> 29));
word_array.push(((msg_len << 3) & 4294967295));
blockstart = 0;
while (blockstart < word_array.length) {
i = 0;
while (i < 16) {
W[i] = word_array[(blockstart + i)];
i = (i + 1);
};
i = 16;
while (i <= 79) {
W[i] = rotate_left((((W[(i - 3)] ^ W[(i - 8)]) ^ W[(i - 14)]) ^ W[(i - 16)]), 1);
i = (i + 1);
};
A = H0;
B = H1;
C = H2;
D = H3;
E = H4;
i = 0;
while (i <= 19) {
temp = (((((rotate_left(A, 5) + ((B & C) | (~(B) & D))) + E) + W[i]) + 1518500249) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i = (i + 1);
};
i = 20;
while (i <= 39) {
temp = (((((rotate_left(A, 5) + ((B ^ C) ^ D)) + E) + W[i]) + 1859775393) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i = (i + 1);
};
i = 40;
while (i <= 59) {
temp = (((((rotate_left(A, 5) + (((B & C) | (B & D)) | (C & D))) + E) + W[i]) + 2400959708) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i = (i + 1);
};
i = 60;
while (i <= 79) {
temp = (((((rotate_left(A, 5) + ((B ^ C) ^ D)) + E) + W[i]) + 3395469782) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i = (i + 1);
};
H0 = ((H0 + A) & 4294967295);
H1 = ((H1 + B) & 4294967295);
H2 = ((H2 + C) & 4294967295);
H3 = ((H3 + D) & 4294967295);
H4 = ((H4 + E) & 4294967295);
blockstart = (blockstart + 16);
};
temp = ((((cvt_hex(H0) + cvt_hex(H1)) + cvt_hex(H2)) + cvt_hex(H3)) + cvt_hex(H4));
return (temp.toLowerCase());
}
public function SubmitScore(event:MouseEvent):void{
var score:Number;
var highscoreKey:String;
var submitScoreURL:String;
var url:URLRequest;
score = Math.floor(root.gsGame.GetScore());
highscoreKey = SHA1(((score.toString() + MemoryCrypto.getString("highscore_password")) + gHighscoreGameID));
if (!DomainCheck.CanSubmitHighscores()){
highscoreKey = SHA1(((score.toString() + MemoryCrypto.getString("baddomain_highscore_password")) + gHighscoreGameID));
};
submitScoreURL = (((((((gDYOGServerLocation + "high_scores/exclusive/submit_score/") + gHighscoreGameID) + "/") + score) + "/") + highscoreKey) + "/");
url = new URLRequest(submitScoreURL);
navigateToURL(url, "_blank");
}
public function PlayGameMode1(event:MouseEvent):void{
root.gGameMode = 1;
root.gotoAndPlay(1, "Game");
}
public function ClickedSplashScreen(event:MouseEvent):void{
var url:URLRequest;
url = new URLRequest("http://www.digyourowngrave.com/");
navigateToURL(url, "_blank");
}
public function PlayGameMode2(event:MouseEvent):void{
root.gGameMode = 2;
root.gotoAndPlay(1, "Game");
}
public function PlayGame(event:MouseEvent):void{
root.gotoAndPlay(1, "Game");
}
function frame248(){
stop();
}
function frame249(){
if (root.btnBack != null){
root.btnBack.addEventListener(MouseEvent.MOUSE_UP, BackButton, false, 0, true);
root.btnBack.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.btnBack.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.btnBack.useHandCursor = true;
};
stop();
}
function frame245(){
root.tfVersion.text = ("Version " + gVersion);
if (((((!((root.gMinFlashVersion == null))) && (!((root.gMinFlashVersion == ""))))) && (!((root.mcFlashVersionWarning == null))))){
userVersion = Capabilities.version;
v1 = Number(userVersion.split(" ")[1].split(",")[0]);
v2 = Number(userVersion.split(" ")[1].split(",")[1]);
v3 = Number(userVersion.split(" ")[1].split(",")[2]);
v4 = Number(userVersion.split(" ")[1].split(",")[3]);
rV1 = Number(root.gMinFlashVersion.split(".")[0]);
rV2 = Number(root.gMinFlashVersion.split(".")[1]);
rV3 = Number(root.gMinFlashVersion.split(".")[2]);
rV4 = Number(root.gMinFlashVersion.split(".")[3]);
requireUpdate = false;
if (v1 < rV1){
requireUpdate = true;
} else {
if (v1 == rV1){
if (v2 < rV2){
requireUpdate = true;
} else {
if (v2 == rV2){
if (v3 < rV3){
requireUpdate = true;
} else {
if (v3 == rV3){
if (v4 < rV4){
requireUpdate = true;
};
};
};
};
};
};
};
if (requireUpdate){
root.mcFlashVersionWarning.visible = true;
root.mcFlashVersionWarning["tfRequiredVersion"].text = root.gMinFlashVersion;
root.mcFlashVersionWarning["tfYourVersion"].text = Capabilities.version.split(" ")[1].split(",").join(".");
root.mcFlashVersionWarning["btnUpdateFlash"].addEventListener(MouseEvent.MOUSE_UP, UpdateFlashPlayer, false, 0, true);
root.mcFlashVersionWarning["btnUpdateFlash"].addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.mcFlashVersionWarning["btnUpdateFlash"].addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.mcFlashVersionWarning["btnUpdateFlash"].useHandCursor = true;
} else {
root.mcFlashVersionWarning.visible = false;
};
};
root.gBackPoint = "singleplayer";
DomainCheck.AllowAllDomains(gAllowAllDomains);
DomainCheck.BlockLocalhost(gBlockLocalhost);
DomainCheck.SetAllowedDomains(gAllowedDomains);
if (!DomainCheck.isCurrentDomainAllowed()){
root.gotoAndStop("locked", "MainMenu");
};
Achievements.Initialize(gLittlegreyServerLocation, gDYOGServerLocation);
if (root["tfConsole"] != null){
Achievements.SetConsole(root["tfConsole"]);
};
Achievements.LoadUserFromQueryString(LoaderInfo(root.loaderInfo).parameters);
if (root.sgPlayButton != null){
root.sgPlayButton.addEventListener(MouseEvent.MOUSE_UP, PlayGame, false, 0, true);
root.sgPlayButton.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.sgPlayButton.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.sgPlayButton.useHandCursor = true;
};
if (root.btnGameMode1 != null){
root.btnGameMode1.addEventListener(MouseEvent.MOUSE_UP, PlayGameMode1, false, 0, true);
root.btnGameMode1.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.btnGameMode1.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.btnGameMode1.useHandCursor = true;
};
if (root.btnGameMode2 != null){
root.btnGameMode2.addEventListener(MouseEvent.MOUSE_UP, PlayGameMode2, false, 0, true);
root.btnGameMode2.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.btnGameMode2.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.btnGameMode2.useHandCursor = true;
};
if (root.sgHighscoresButton != null){
root.sgHighscoresButton.addEventListener(MouseEvent.MOUSE_UP, ViewHighscores, false, 0, true);
root.sgHighscoresButton.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.sgHighscoresButton.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.sgHighscoresButton.useHandCursor = true;
};
if (root.sgMoreGamesButton != null){
root.sgMoreGamesButton.addEventListener(MouseEvent.MOUSE_UP, MoreGames, false, 0, true);
root.sgMoreGamesButton.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.sgMoreGamesButton.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.sgMoreGamesButton.useHandCursor = true;
};
if (root.sgSponsorButton != null){
root.sgSponsorButton.addEventListener(MouseEvent.MOUSE_UP, GotToSponsorSite, false, 0, true);
root.sgSponsorButton.useHandCursor = true;
};
if (root.btnCredits != null){
root.btnCredits.addEventListener(MouseEvent.MOUSE_UP, ShowCredits, false, 0, true);
root.btnCredits.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.btnCredits.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.btnCredits.useHandCursor = true;
};
stop();
}
function frame247(){
root.sgExclusivePlayButton.addEventListener(MouseEvent.MOUSE_UP, PlayOnDYOG, false, 0, true);
root.sgExclusivePlayButton.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.sgExclusivePlayButton.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.sgExclusivePlayButton.useHandCursor = true;
}
function frame250(){
DomainCheck.AllowAllDomains(gAllowAllDomains);
DomainCheck.BlockLocalhost(gBlockLocalhost);
DomainCheck.SetAllowedDomains(gAllowedDomains);
DomainCheck.SetHighscoreDomains(gHighscoreDomains);
DomainCheck.SetAdExemptDomains(gAdExemptDomains);
if (!DomainCheck.isCurrentDomainAllowed()){
root.gotoAndStop(3, "MainMenu");
};
Framerate.ShowFPS(gShowStats, root.gsGame["tfFPS"]);
MemoryUsage.InitMemoryUsageDisplay(gShowStats, root.gsGame["tfMemoryUsage"]);
AdServer.Enable(((gShowAds) && (!(DomainCheck.IsAdExempt()))));
AdServer.SetGameName(gGameName);
if (root.gMP != null){
root.gsGame.SetMultiplayerGame(root.gMP);
};
root.gsGame.InitializeGame();
if (root.gMP == null){
root.gsGame["msGameOverOverlay"]["msAdContainer"]["msInvisibleButton"].addEventListener(MouseEvent.MOUSE_UP, ClickedAd, false, 0, true);
root.gsGame["msGameOverOverlay"]["msAdContainer"]["msInvisibleButton"].useHandCursor = true;
root.gsGame["msGameOverOverlay"]["msAdContainer"]["msInvisibleButton"].buttonMode = true;
if (root.gsGame["msGameOverOverlay"]["msSubmitScoreButton"] != null){
root.gsGame["msGameOverOverlay"]["msSubmitScoreButton"].addEventListener(MouseEvent.MOUSE_UP, SubmitScore, false, 0, true);
root.gsGame["msGameOverOverlay"]["msSubmitScoreButton"].addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msSubmitScoreButton"].addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msSubmitScoreButton"].useHandCursor = true;
};
if (root.gsGame["msGameOverOverlay"]["mcAchievements"]["mcSubmitButton"] != null){
submitBtn = root.gsGame["msGameOverOverlay"]["mcAchievements"]["mcSubmitButton"];
submitBtn.addEventListener(MouseEvent.MOUSE_UP, SubmitScoreAndAchievements, false, 0, true);
submitBtn.addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
submitBtn.addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
submitBtn.useHandCursor = true;
};
if (root.gsGame["msGameOverOverlay"]["msReplayButton"] != null){
root.gsGame["msGameOverOverlay"]["msReplayButton"].addEventListener(MouseEvent.MOUSE_UP, ReplayGame, false, 0, true);
root.gsGame["msGameOverOverlay"]["msReplayButton"].addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msReplayButton"].addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msReplayButton"].useHandCursor = true;
};
if (root.gsGame["msGameOverOverlay"]["btnMainMenu"] != null){
root.gsGame["msGameOverOverlay"]["btnMainMenu"].addEventListener(MouseEvent.MOUSE_UP, MainMenu, false, 0, true);
root.gsGame["msGameOverOverlay"]["btnMainMenu"].addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["btnMainMenu"].addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["btnMainMenu"].useHandCursor = true;
};
root.gsGame["msGameOverOverlay"]["msViewHighscoresScoresButton"].addEventListener(MouseEvent.MOUSE_UP, ViewHighscores, false, 0, true);
root.gsGame["msGameOverOverlay"]["msViewHighscoresScoresButton"].addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msViewHighscoresScoresButton"].addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msViewHighscoresScoresButton"].useHandCursor = true;
root.gsGame["msGameOverOverlay"]["msMoreGamesButton"].addEventListener(MouseEvent.MOUSE_UP, MoreGames, false, 0, true);
root.gsGame["msGameOverOverlay"]["msMoreGamesButton"].addEventListener(MouseEvent.MOUSE_DOWN, PlayButtonDownSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msMoreGamesButton"].addEventListener(MouseEvent.MOUSE_OVER, PlayRolloverSound, false, 0, true);
root.gsGame["msGameOverOverlay"]["msMoreGamesButton"].useHandCursor = true;
root.gsGame["msGameOverOverlay"]["msSponsorButton"].addEventListener(MouseEvent.MOUSE_UP, GotToSponsorSite, false, 0, true);
root.gsGame["msGameOverOverlay"]["msSponsorButton"].useHandCursor = true;
};
stop();
}
public function PlayRolloverSound(event:MouseEvent):void{
AudioEngine.PlaySound("sfxButtonOver", AudioEngine.SFX_CHANNEL);
}
}
}//package arachnophilia_fla
Section 7
//PauseOverlay_75 (arachnophilia_fla.PauseOverlay_75)
package arachnophilia_fla {
import flash.display.*;
public dynamic class PauseOverlay_75 extends MovieClip {
public var msHelpButton:TutorialToggle;
public var gsSoundAnchorSfx:MovieClip;
public var gsSoundAnchorMusic:MovieClip;
public var msEndGameButton:SimpleButton;
public var msContinueButton:SimpleButton;
public function PauseOverlay_75(){
super();
}
}
}//package arachnophilia_fla
Section 8
//SoundLoader_4 (arachnophilia_fla.SoundLoader_4)
package arachnophilia_fla {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class SoundLoader_4 extends MovieClip {
public function SoundLoader_4(){
super();
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package arachnophilia_fla
Section 9
//AudioEngine (audio.AudioEngine)
package audio {
import flash.media.*;
import flash.utils.*;
public class AudioEngine {
private static var sFreeInstanceSlots:Array = new Array();
private static var sSoundTransforms:Array = new Array();
private static var sVolumes:Array = new Array();
public static var SFX_CHANNEL:Number = 0;
public static var MUSIC_CHANNEL:Number = 1;
private static var sSoundInstances:Array = new Array();
private static var sSoundObjects:Array = new Array();
public function AudioEngine(){
super();
}
public static function SoundComplete(channel:Number, id:Number):void{
sSoundInstances[channel][id] = null;
sFreeInstanceSlots[channel].push(id);
}
public static function PlaySound(name:String, channel:Number, looping:Boolean=false):SoundHandle{
var newSound:SoundHandle;
var theClass:Class;
var name = name;
var channel = channel;
var looping = looping;
CheckChannel(channel);
if (sSoundObjects[channel][name] == null){
theClass = Class(getDefinitionByName(name));
//unresolved jump
var _slot1 = e;
trace((("***** Audio file '" + name) + "' not found!"));
return (null);
sSoundObjects[channel][name] = new (theClass);
};
newSound = new SoundHandle(sSoundObjects[channel][name].play(0, (looping) ? 9999 : 0, sSoundTransforms[channel]), channel);
trackSound(channel, newSound);
return (newSound);
}
private static function trackSound(channel:Number, newSound:SoundHandle):void{
var index:Number;
index = -1;
if (sFreeInstanceSlots[channel].length == 0){
index = (sSoundInstances[channel].push(newSound) - 1);
} else {
index = sFreeInstanceSlots[channel].pop();
sSoundInstances[channel][index] = newSound;
};
newSound.SetID(index);
}
public static function GetVolume(channel:Number):Number{
CheckChannel(channel);
return (sVolumes[channel]);
}
public static function CheckChannel(channel:Number):void{
if (sVolumes[channel] != null){
return;
};
sVolumes[channel] = 1;
sSoundObjects[channel] = new Array();
sSoundInstances[channel] = new Array();
sFreeInstanceSlots[channel] = new Array();
sSoundTransforms[channel] = new SoundTransform();
}
public static function SetVolume(channel:Number, volume:Number):void{
var soundInstances:Array;
var i:Number;
CheckChannel(channel);
sVolumes[channel] = volume;
sSoundTransforms[channel].volume = volume;
soundInstances = sSoundInstances[channel];
i = 0;
while (i < soundInstances.length) {
if (soundInstances[i] != null){
soundInstances[i].ResetVolume();
};
i++;
};
}
}
}//package audio
Section 10
//MuteMusicButton (audio.MuteMusicButton)
package audio {
import flash.events.*;
import flash.display.*;
public dynamic class MuteMusicButton extends MovieClip {
private var mOn:Boolean;// = true
public function MuteMusicButton(){
mOn = true;
super();
addFrameScript(0, frame1, 1, frame2);
useHandCursor = true;
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, onPress, false, 0, true);
mOn = !((AudioEngine.GetVolume(AudioEngine.MUSIC_CHANNEL) == 0));
if (!mOn){
gotoAndStop("off");
};
}
public function IsMuted():Boolean{
return (!(mOn));
}
function frame1(){
stop();
}
function onPress(event:MouseEvent){
mOn = !(mOn);
if (mOn){
gotoAndStop("on");
AudioEngine.SetVolume(AudioEngine.MUSIC_CHANNEL, 1);
} else {
gotoAndStop("off");
AudioEngine.SetVolume(AudioEngine.MUSIC_CHANNEL, 0);
};
}
function frame2(){
stop();
}
}
}//package audio
Section 11
//MuteSfxButton (audio.MuteSfxButton)
package audio {
import flash.events.*;
import flash.display.*;
public dynamic class MuteSfxButton extends MovieClip {
private var mOn:Boolean;// = true
public function MuteSfxButton(){
mOn = true;
super();
addFrameScript(0, frame1, 1, frame2);
useHandCursor = true;
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, onPress, false, 0, true);
mOn = !((AudioEngine.GetVolume(AudioEngine.SFX_CHANNEL) == 0));
if (!mOn){
gotoAndStop("off");
};
}
public function IsMuted():Boolean{
return (!(mOn));
}
function frame1(){
stop();
}
function onPress(event:MouseEvent){
mOn = !(mOn);
if (mOn){
gotoAndStop("on");
AudioEngine.SetVolume(AudioEngine.SFX_CHANNEL, 1);
} else {
gotoAndStop("off");
AudioEngine.SetVolume(AudioEngine.SFX_CHANNEL, 0);
};
}
function frame2(){
stop();
}
}
}//package audio
Section 12
//SoundHandle (audio.SoundHandle)
package audio {
import flash.events.*;
import flash.media.*;
public class SoundHandle extends EventDispatcher {
private var mID:Number;// = -1
private var mChannel:SoundChannel;
private var mVolume:Number;// = 1
private var mSoundType:Number;
public function SoundHandle(channel:SoundChannel, soundType:Number){
mSoundType = AudioEngine.SFX_CHANNEL;
mID = -1;
mVolume = 1;
super();
mChannel = channel;
mSoundType = soundType;
mChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true);
}
public function SetPan(pan:Number):void{
var transform:SoundTransform;
transform = mChannel.soundTransform;
transform.pan = pan;
mChannel.soundTransform = transform;
}
public function SetVolume(volume:Number):void{
var transform:SoundTransform;
mVolume = volume;
transform = mChannel.soundTransform;
transform.volume = (mVolume * AudioEngine.GetVolume(mSoundType));
mChannel.soundTransform = transform;
}
private function soundCompleteHandler(event:Event):void{
soundComplete();
}
public function Stop():void{
mChannel.stop();
soundComplete();
}
public function SetID(id:Number):void{
mID = id;
}
private function soundComplete():void{
AudioEngine.SoundComplete(mSoundType, mID);
}
public function ResetVolume():void{
var transform:SoundTransform;
transform = mChannel.soundTransform;
transform.volume = (mVolume * AudioEngine.GetVolume(mSoundType));
mChannel.soundTransform = transform;
}
}
}//package audio
Section 13
//Action (framework.Action.Action)
package framework.Action {
import game.*;
public class Action {
public function Action(){
super();
}
public function act(actor:Actor, time:Number):Boolean{
}
public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
}
public function cancel(){
}
}
}//package framework.Action
Section 14
//Actor (framework.Action.Actor)
package framework.Action {
import game.*;
import framework.Geometry.*;
public interface Actor {
function act(*:Number);
function addAction(*:Action);
function getBody():Shape;
function actionUpdateGraphic(_arg1:LevelData, _arg2:Number);
function actorKey():String;
}
}//package framework.Action
Section 15
//Circle (framework.Geometry.Circle)
package framework.Geometry {
public class Circle extends Shape {
public var radius:Number;// = 0
public var center:Point;// = null
public function Circle(c:Point, r:Number){
center = null;
radius = 0;
super();
center = c;
radius = r;
}
override public function toString():String{
return ((((("[" + center.toString()) + "->") + radius) + "]"));
}
public function newCircle(center:Point, radius:Number):Circle{
return (new Circle(center, radius));
}
override public function intercepts(other:Shape):Boolean{
var circle:Circle;
var rectangle:Rectangle;
if ((other is Point)){
return (other.intercepts(this));
};
if ((other is Line)){
return (other.intercepts(this));
};
if ((other is Circle)){
circle = Circle(other);
return ((center.getDistance(circle.center) <= (radius + circle.radius)));
};
if ((other is Rectangle)){
rectangle = Rectangle(other);
if (rectangle.containsPoint(center)){
return (true);
};
return (((((((intercepts(rectangle.getTop())) || (intercepts(rectangle.getBottom())))) || (intercepts(rectangle.getLeft())))) || (intercepts(rectangle.getRight()))));
//unresolved jump
};
return (false);
}
override public function clone():Shape{
return (newCircle(center, radius));
}
override public function equals(other:Shape):Boolean{
var circle:Circle;
if (!(other is Circle)){
return (false);
};
circle = Circle(other);
return (((center.equals(circle.center)) && ((radius == circle.radius))));
}
}
}//package framework.Geometry
Section 16
//Line (framework.Geometry.Line)
package framework.Geometry {
public class Line extends Shape {
public var intercept:Number;// = 0
public var slope:Number;// = NAN
private var _angle:Number;// = NAN
public function Line(s:Number, i:Number){
slope = NaN;
intercept = 0;
_angle = NaN;
super();
slope = s;
intercept = i;
}
public function getIntersection(line:Line):Point{
var x:Number;
var y:Number;
var point:Point;
var dm:Number;
var segment:Segment;
if ((((slope == line.slope)) || (((isNaN(slope)) && (isNaN(line.slope)))))){
return (null);
};
if (isNaN(slope)){
x = intercept;
y = ((line.slope * x) + line.intercept);
point = newPoint(x, y);
} else {
if (isNaN(line.slope)){
x = line.intercept;
y = ((slope * x) + intercept);
point = newPoint(x, y);
} else {
dm = (slope - line.slope);
x = ((-1 * (intercept - line.intercept)) / dm);
y = ((slope * x) + intercept);
point = newPoint(x, y);
};
};
if ((line is Segment)){
segment = Segment(line);
if (!segment.containsPoint(point)){
return (null);
};
};
return (point);
}
override public function toString():String{
if (isNaN(slope)){
return (("x = " + intercept));
};
if (slope == 0){
return (("y = " + intercept));
};
return (((("y = " + slope) + " * x + ") + intercept));
}
public function newPoint(x:Number, y:Number):Point{
return (new Point(x, y));
}
override public function intercepts(other:Shape):Boolean{
var segment:Segment;
var line:Line;
var circle:Circle;
if ((other is Point)){
return (other.intercepts(this));
};
if ((other is Segment)){
segment = Segment(other);
return (!((getIntersection(segment) == null)));
};
if ((other is Line)){
line = Line(other);
if (equals(line)){
return (true);
};
return (!((getIntersection(line) == null)));
//unresolved jump
};
if ((other is Circle)){
circle = Circle(other);
return ((getDistance(circle.center) <= circle.radius));
};
if ((other is Rectangle)){
return (other.intercepts(this));
};
return (false);
}
public function getDistance(point:Point):Number{
var normalPoint:Point;
normalPoint = getNormalPoint(point);
return (point.getDistance(normalPoint));
}
public function getAngle():Number{
if (isNaN(_angle)){
if (isNaN(slope)){
_angle = (0.5 * Math.PI);
} else {
_angle = Math.atan(slope);
if (_angle < 0){
_angle = (_angle + Math.PI);
};
};
};
return (_angle);
}
public function getNormalPoint(point:Point):Point{
var s:Number;
var i:Number;
var line:Line;
if (isNaN(slope)){
return (newPoint(intercept, point.y));
};
if (slope == 0){
return (newPoint(point.x, intercept));
};
s = (-1 / slope);
i = (point.y - (s * point.x));
line = new Line(s, i);
return (getIntersection(line));
}
public function newLine(slope:Number, intercept:Number):Line{
return (new Line(slope, intercept));
}
public function getDistanceSquared(point:Point):Number{
var normalPoint:Point;
normalPoint = getNormalPoint(point);
return (point.getDistanceSquared(normalPoint));
}
override public function clone():Shape{
return (newLine(slope, intercept));
}
override public function equals(other:Shape):Boolean{
var l:Line;
if (!(other is Line)){
return (false);
};
l = Line(other);
return ((((((slope == l.slope)) || (((isNaN(slope)) && (isNaN(l.slope)))))) && ((intercept == l.intercept))));
}
public static function fromPoints(p1:Point, p2:Point):Line{
var slope:Number;
var intercept:Number;
slope = p1.getSlope(p2);
intercept = p1.getIntercept(slope);
return (new Line(slope, intercept));
}
}
}//package framework.Geometry
Section 17
//Point (framework.Geometry.Point)
package framework.Geometry {
public class Point extends Shape {
public var x:Number;// = 0
public var y:Number;// = 0
public static var threshold = 0.001;
public function Point(x1:Number, y1:Number){
x = 0;
y = 0;
super();
x = x1;
y = y1;
}
public function getAngle(other:Point):Number{
var angle:Number;
if ((x - other.x) == 0){
if (y < other.y){
return ((0.5 * Math.PI));
};
return ((Math.PI + (Math.PI * 0.5)));
//unresolved jump
};
if ((y - other.y) == 0){
if (x > other.x){
return (Math.PI);
};
return (0);
//unresolved jump
};
angle = Math.atan(getSlope(other));
if (angle < 0){
angle = (angle + Math.PI);
};
if (y > other.y){
angle = (angle + Math.PI);
};
return (angle);
}
public function interceptsLine(line:Line):Boolean{
if (isNaN(line.slope)){
return ((Math.abs((x - line.intercept)) < 0.001));
};
if (line.slope == 0){
return ((Math.abs((y - line.intercept)) < 0.001));
};
return ((Math.abs((y - ((line.slope * x) + line.intercept))) < 0.001));
}
public function (other:Point):Number{
return ((Math.abs((x - other.x)) + Math.abs((y - other.y))));
}
public function getDistance(other:Point):Number{
var dx:Number;
var dy:Number;
dx = (x - other.x);
dy = (y - other.y);
return (Math.sqrt(((dx * dx) + (dy * dy))));
}
override public function toString():String{
return ((((("(" + x) + ", ") + y) + ")"));
}
override public function intercepts(other:Shape):Boolean{
var segment:Segment;
var circle:Circle;
var rectangle:Rectangle;
if ((other is Point)){
return (equals(other));
};
if ((other is Segment)){
segment = Segment(other);
if (!interceptsLine(segment)){
return (false);
};
return (segment.containsPoint(this));
} else {
if ((other is Line)){
return (interceptsLine(Line(other)));
};
if ((other is Circle)){
circle = Circle(other);
return ((getDistance(circle.center) <= circle.radius));
};
if ((other is Rectangle)){
rectangle = Rectangle(other);
return (rectangle.containsPoint(this));
};
};
throw (new Error(("Can not check for interception with " + other)));
}
public function getSlope(other:Point):Number{
var dx:Number;
dx = (x - other.x);
if (dx == 0){
return (NaN);
};
return (((y - other.y) / dx));
}
public function newPoint(x:Number, y:Number):Point{
return (new Point(x, y));
}
public function moveTowards(distance:Number, target:Point):Point{
var diff_x:Number;
var diff_y:Number;
var dx:*;
var dy:*;
var slope:Number;
if (equals(target)){
return (target);
};
dx = (target.x - x);
dy = (target.y - y);
if (dx == 0){
diff_x = 0;
diff_y = distance;
} else {
if (dy == 0){
diff_x = distance;
diff_y = 0;
} else {
slope = (dy / dx);
diff_x = Math.sqrt(((distance * distance) / (1 + (slope * slope))));
diff_y = (Math.abs(slope) * diff_x);
};
};
if (target.x < x){
diff_x = (-1 * diff_x);
};
if (target.y < y){
diff_y = (-1 * diff_y);
};
return (newPoint((x + diff_x), (y + diff_y)));
}
public function getIntercept(slope:Number):Number{
if (slope == 0){
return (y);
};
if (isNaN(slope)){
return (x);
};
return ((y - (slope * x)));
}
public function getDistanceSquared(other:Point):Number{
var dx:Number;
var dy:Number;
dx = Math.abs((x - other.x));
dy = Math.abs((y - other.y));
return (((dx * dx) + (dy * dy)));
}
override public function clone():Shape{
return (newPoint(x, y));
}
override public function equals(other:Shape):Boolean{
var p:Point;
if (!(other is Point)){
return (false);
};
p = Point(other);
return ((((Math.abs((x - p.x)) < threshold)) && ((Math.abs((y - p.y)) < threshold))));
}
}
}//package framework.Geometry
Section 18
//Rectangle (framework.Geometry.Rectangle)
package framework.Geometry {
public class Rectangle extends Shape {
public var width:Number;// = 0
public var p1:Point;// = null
public var p2:Point;// = null
private var _bottom:Segment;// = null
private var _top:Segment;// = null
private var _right:Segment;// = null
private var _left:Segment;// = null
public var height:Number;// = 0
public function Rectangle(point1:Point, point2:Point){
p1 = null;
p2 = null;
height = 0;
width = 0;
_top = null;
_bottom = null;
_left = null;
_right = null;
super();
if (point1.x < point2.x){
p1 = point1;
p2 = point2;
} else {
if (point2.x < point1.x){
p1 = point2;
p2 = point1;
} else {
if (point1.y < point2.y){
p1 = point1;
p2 = point2;
} else {
p1 = point2;
p2 = point1;
};
};
};
height = Math.abs((p1.y - p2.y));
width = Math.abs((p1.x - p2.x));
}
public function newPoint(x, y):Point{
return (new Point(x, y));
}
public function newSegment(p1, p2):Segment{
return (new Segment(p1, p2));
}
public function getTop():Segment{
var y:*;
if (_top == null){
if (p1.y > p2.y){
y = p1.y;
} else {
y = p2.y;
};
_top = newSegment(newPoint(p1.x, y), newPoint(p2.x, y));
};
return (_top);
}
override public function clone():Shape{
return (newRectangle(p1, p2));
}
public function getBottom():Segment{
var y:*;
if (_bottom == null){
if (p1.y < p2.y){
y = p1.y;
} else {
y = p2.y;
};
_bottom = newSegment(newPoint(p1.x, y), newPoint(p2.x, y));
};
return (_bottom);
}
override public function toString():String{
return ((((("{Rectangle: " + p1.toString()) + ", ") + p2.toString()) + "}"));
}
public function getRight():Segment{
if (_right == null){
_right = newSegment(newPoint(p2.x, p1.y), newPoint(p2.x, p2.y));
};
return (_right);
}
public function newRectangle(p1:Point, p2:Point){
return (new Rectangle(p1, p2));
}
override public function intercepts(other:Shape):Boolean{
var val:*;
var segment:*;
var top:Number;
var bottom:Number;
var right:Number;
var left:Number;
var rectangle:*;
if ((other is Point)){
return (other.intercepts(this));
};
if ((other is Line)){
if ((other is Segment)){
segment = Segment(other);
if (((containsPoint(segment.p1)) || (containsPoint(segment.p2)))){
return (true);
};
if (p1.y > p2.y){
top = p1.y;
bottom = p2.y;
} else {
top = p2.y;
bottom = p1.y;
};
if ((((((p1.y > top)) && ((p2.y > top)))) || ((((p1.y < bottom)) && ((p2.y < bottom)))))){
return (false);
};
if (p1.x > p2.x){
right = p1.x;
left = p2.x;
} else {
right = p2.x;
left = p1.x;
};
if ((((((p1.x > right)) && ((p2.x > right)))) || ((((p1.x < left)) && ((p2.x < left)))))){
return (false);
};
};
val = ((((((getTop().intercepts(other)) || (getBottom().intercepts(other)))) || (getLeft().intercepts(other)))) || (getRight().intercepts(other)));
return (val);
} else {
if ((other is Circle)){
return (other.intercepts(this));
};
if ((other is Rectangle)){
rectangle = Rectangle(other);
return (((((((containsPoint(rectangle.p1)) || (containsPoint(rectangle.p2)))) || (rectangle.containsPoint(p1)))) || (rectangle.containsPoint(p2))));
};
};
return (false);
}
public function containsPoint(point:Point):Boolean{
if ((((p1.x <= point.x)) && ((point.x <= p2.x)))){
if (p1.y < p2.y){
if ((((p1.y <= point.y)) && ((point.y <= p2.y)))){
return (true);
};
return (false);
} else {
if ((((p2.y <= point.y)) && ((point.y <= p1.y)))){
return (true);
};
return (false);
};
//unresolved jump
};
return (false);
}
public function getLeft():Segment{
if (_left == null){
_left = newSegment(newPoint(p1.x, p1.y), newPoint(p1.x, p2.y));
};
return (_left);
}
override public function equals(other:Shape):Boolean{
var rectangle:*;
if (!(other is Rectangle)){
return (false);
};
rectangle = Rectangle(other);
return (((p1.equals(rectangle.p1)) && (p2.equals(rectangle.p2))));
}
static function fromSize(point:Point, height1:Number, width1:Number){
var point2:Point;
point2 = new Point((point.x + width1), (point.y + height1));
return (new Rectangle(point, point2));
}
}
}//package framework.Geometry
Section 19
//Segment (framework.Geometry.Segment)
package framework.Geometry {
public class Segment extends Line {
public var p1:Point;// = null
public var p2:Point;// = null
private var length:Number;// = NAN
public function Segment(point1:Point, point2:Point){
var s:Number;
var i:Number;
p1 = null;
p2 = null;
length = NaN;
s = point1.getSlope(point2);
i = point1.getIntercept(s);
super(s, i);
if (point1.x < point2.x){
p1 = point1;
p2 = point2;
} else {
if (point1.x > point2.x){
p1 = point2;
p2 = point1;
} else {
if (point1.y < point2.y){
p1 = point1;
p2 = point2;
} else {
p1 = point2;
p2 = point1;
};
};
};
}
public function getTopPoint():Point{
if (p1.y > p2.y){
return (p1);
};
return (p2);
}
override public function getIntersection(line:Line):Point{
var point:Point;
point = super.getIntersection(line);
if (point == null){
return (null);
};
if (containsPoint(point)){
return (point);
};
return (null);
}
public function newSegment(p1:Point, p2:Point):Segment{
return (new Segment(p1, p2));
}
public function getLength():Number{
if (isNaN(length)){
length = p1.getDistance(p2);
};
return (length);
}
override public function clone():Shape{
var segment:Segment;
segment = newSegment(p1.clone(), p2.clone());
if (!isNaN(length)){
segment.setLength(length);
};
return (segment);
}
public function getClosest(point:Point, squared:Boolean, snap:Boolean):Array{
var normalPoint:Point;
var d1:Number;
var d2:Number;
var distance:Number;
normalPoint = getNormalPoint(point);
if ((((normalPoint == null)) || (!(containsPoint(normalPoint))))){
if (squared){
d1 = point.getDistanceSquared(p1);
d2 = point.getDistanceSquared(p2);
} else {
d1 = point.getDistance(p1);
d2 = point.getDistance(p2);
};
if (d1 < d2){
return ([p1, d1]);
};
return ([p2, d2]);
} else {
if (squared){
if (snap){
distance = point.getDistanceSquared(p1);
if (distance < 0.001){
normalPoint = p1;
} else {
distance = point.getDistanceSquared(p2);
if (distance < 0.001){
normalPoint = p2;
} else {
distance = point.getDistanceSquared(normalPoint);
};
};
} else {
distance = point.getDistanceSquared(normalPoint);
};
return ([normalPoint, distance]);
//unresolved jump
};
if (snap){
distance = point.getDistance(p1);
if (distance < 0.001){
normalPoint = p1;
} else {
distance = point.getDistance(p2);
if (distance < 0.001){
normalPoint = p2;
} else {
distance = point.getDistance(normalPoint);
};
};
} else {
distance = point.getDistance(normalPoint);
};
};
return (!NULL!);
}
public function getOtherPoint(point:Point):Point{
if (point.equals(p1)){
return (p2);
};
if (point.equals(p2)){
return (p1);
};
return (null);
}
public function setLength(l:Number){
length = l;
}
override public function toString():String{
return ((((("[" + p1.toString()) + ", ") + p2.toString()) + "]"));
}
public function getD(point:Point, squared:Boolean):Number{
return (getClosest(point, squared, false)[1]);
}
public function hasEndPoint(point:Point):Boolean{
return (((point.equals(p1)) || (point.equals(p2))));
}
override public function intercepts(other:Shape):Boolean{
var segment:Segment;
var circle:Circle;
if ((other is Point)){
return (other.intercepts(this));
};
if ((other is Segment)){
segment = Segment(other);
if (getIntersection(segment) != null){
return (true);
};
if ((((slope == segment.slope)) || (((isNaN(slope)) && (isNaN(segment.slope)))))){
if (containsPoint(segment.p1)){
return (true);
};
if (containsPoint(segment.p2)){
return (true);
};
if (segment.containsPoint(p1)){
return (true);
};
if (segment.containsPoint(p2)){
return (true);
};
};
} else {
if ((other is Line)){
return (other.intercepts(this));
};
if ((other is Circle)){
circle = Circle(other);
return ((getDistance(circle.center) <= circle.radius));
};
if ((other is Rectangle)){
return (other.intercepts(this));
};
return (false);
};
}
override public function getDistance(point:Point):Number{
return (getD(point, false));
}
public function containsPoint(point:Point):Boolean{
if (((((p1.x - 0.001) <= point.x)) && ((point.x <= (p2.x + 0.001))))){
if (p1.y < p2.y){
return (((((p1.y - 0.001) <= point.y)) && ((point.y <= (p2.y + 0.001)))));
};
return (((((p2.y - 0.001) <= point.y)) && ((point.y <= (p1.y + 0.001)))));
//unresolved jump
};
return (false);
}
override public function getDistanceSquared(point:Point):Number{
return (getD(point, true));
}
override public function equals(other:Shape):Boolean{
var segment:Segment;
if (!(other is Segment)){
return (false);
};
segment = Segment(other);
return (((p1.equals(segment.p1)) && (p2.equals(segment.p2))));
}
}
}//package framework.Geometry
Section 20
//Shape (framework.Geometry.Shape)
package framework.Geometry {
public class Shape {
public function Shape(){
super();
}
public function newShape():Shape{
return (new Shape());
}
public function intercepts(other:Shape):Boolean{
return (equals(other));
}
public function getKey():String{
return (toString());
}
public function toString():String{
return ("");
}
public function clone():Shape{
return (newShape());
}
public function equals(other:Shape):Boolean{
return (false);
}
}
}//package framework.Geometry
Section 21
//SpaceGrid (framework.Geometry.SpaceGrid)
package framework.Geometry {
import framework.Utilities.*;
public class SpaceGrid extends Shape {
private var _number_parts:Number;
private var _part_ids:Array;
private var _shapes:HashTable;
private var _size:Number;
private var _parts:Array;
private var _part_length:Number;
private var _part_shapes:Array;
public function SpaceGrid(size:Number, number_parts:Number){
var i:*;
var j:*;
super();
if (((isNaN(size)) || (isNaN(number_parts)))){
throw (new Error("Please pass a size and number of parts to the SpaceGrid constructor."));
};
_size = size;
_shapes = new HashTable();
_number_parts = number_parts;
_part_length = (_size / _number_parts);
_parts = new Array();
_part_shapes = new Array();
_part_ids = new Array();
i = 0;
while (i < _number_parts) {
_parts[i] = new Array();
_part_shapes[i] = new Array();
j = 0;
while (j < _number_parts) {
_parts[i][j] = new Rectangle(new Point((_part_length * i), (_part_length * j)), new Point((_part_length * (i + 1)), (_part_length * (j + 1))));
_part_shapes[i][j] = new HashTable();
_part_ids[((i * _number_parts) + j)] = [i, j];
j++;
};
i++;
};
}
public function newSpaceGrid(size:Number, parts_length:Number):SpaceGrid{
return (new SpaceGrid(size, parts_length));
}
override public function equals(other:Shape):Boolean{
var space:*;
var shapes:Array;
var shape:Shape;
var i:Number;
if (!(other is SpaceGrid)){
return (false);
};
space = SpaceGrid(other);
shapes = getShapes();
i = 0;
while (i < shapes.length) {
shape = shapes[i];
if (!space.hasShape(shape)){
return (false);
};
if (!shape.equals(space.getShape(shape))){
return (false);
};
i++;
};
shapes = space.getShapes();
i = 0;
while (i < shapes.length) {
shape = shapes[i];
if (!hasShape(shape)){
return (false);
};
if (!shape.equals(getShape(shape))){
return (false);
};
i++;
};
return (true);
}
private function removePartShape(shape:Shape, part_id:Array){
if (hasPartShape(shape, part_id)){
_part_shapes[part_id[0]][part_id[1]].deleteKey(shape.getKey());
};
}
private function addPartShape(shape:Shape, part_id:Array){
if (inPart(shape, part_id)){
_part_shapes[part_id[0]][part_id[1]].setValue(shape.getKey(), shape);
};
}
public function inPart(shape:Shape, part_id:Array):Boolean{
if (shape.intercepts(getPart(part_id))){
return (true);
};
return (false);
}
public function getCloseShapes(shape:Shape):Array{
var part_ids:*;
var close_shapes:*;
var part_shapes:*;
var i:*;
var j:*;
part_ids = getPartIds();
close_shapes = new HashTable();
i = 0;
while (i < part_ids.length) {
if (inPart(shape, part_ids[i])){
part_shapes = getPartShapes(part_ids[i]);
j = 0;
while (j < part_shapes.length) {
close_shapes.setValue(part_shapes[j].getKey(), part_shapes[j]);
j++;
};
};
i++;
};
return (close_shapes.getValues());
}
public function addShape(shape:Shape){
var ids:*;
var i:*;
_shapes.setValue(shape.getKey());
ids = getPartIds();
i = 0;
while (i < ids.length) {
addPartShape(shape, ids[i]);
i++;
};
}
public function getSize():Number{
return (_size);
}
override public function clone():Shape{
var space:SpaceGrid;
var shapes:*;
var i:*;
space = newSpaceGrid(_size, _number_parts);
shapes = getShapes();
i = 0;
while (i < shapes.length) {
space.addShape(shapes[i].clone());
i++;
};
return (space);
}
public function getPartIds():Array{
return (_part_ids);
}
public function hasShape(shape:Shape):Boolean{
return (_shapes.hasKey(shape.getKey()));
}
public function getShape(shape:Shape):Shape{
if (hasShape(shape)){
return (Shape(_shapes.getValue(shape.getKey())));
};
}
override public function toString():String{
var shapes:*;
var string:*;
var i:*;
shapes = getShapes();
string = "{SpaceGrid: ";
i = 0;
while (i < shapes.length) {
string = (string + shapes[i].toString());
if (i < (shapes.length - 1)){
string = (string + ", ");
};
i++;
};
string = (string + "}");
return (string);
}
public function getPartLength():Number{
return (_part_length);
}
public function getNumberParts():Number{
return (_number_parts);
}
override public function intercepts(other:Shape):Boolean{
var shapes:*;
var i:*;
shapes = getCloseShapes(other);
i = 0;
while (i < shapes.length) {
if (other.intercepts(shapes[i])){
return (true);
};
i++;
};
return (false);
}
private function hasPartShape(shape:Shape, part_id:Array):Boolean{
return (_part_shapes[part_id[0]][part_id[1]].hasKey(shape.getKey()));
}
public function getShapes():Array{
return (_shapes.getValues());
}
public function getPart(part_id:Array):Rectangle{
return (_parts[part_id[0]][part_id[1]]);
}
private function getPartShapes(part_id:Array):Array{
return (_part_shapes[part_id[0]][part_id[1]].getValues());
}
public function (shape:Shape){
var part_ids:*;
var i:*;
if (hasShape(shape)){
_shapes.deleteKey(shape.getKey());
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
removePartShape(shape, part_ids[i]);
i++;
};
};
}
}
}//package framework.Geometry
Section 22
//EdgeCollection (framework.GeometryGraph.EdgeCollection)
package framework.GeometryGraph {
import framework.Geometry.*;
import framework.Utilities.*;
public class EdgeCollection extends Shape {
private var _edges:HashTable;// = null
public function EdgeCollection(){
_edges = null;
super();
_edges = new HashTable();
}
public function getEdges():Array{
return (_edges.getValues());
}
public function hasEdge(edge:GeoEdge):Boolean{
return (_edges.hasKey(edge.getKey()));
}
override public function toString():String{
var val:String;
var edges:*;
var i:*;
val = "{EdgeCollection: ";
edges = getEdges();
i = 0;
while (i < edges.length) {
val = (val + edges[i].toString());
if (i < (edges.length - 1)){
val = (val + ", ");
};
i++;
};
val = (val + "}");
return (val);
}
public function removeEdge(edge:GeoEdge){
if (hasEdge(edge)){
_edges.deleteKey(edge.getKey());
};
}
override public function intercepts(other:Shape):Boolean{
var edges:*;
var i:*;
edges = getEdges();
i = 0;
while (i < edges.length) {
if (edges[i].intercepts(other)){
return (true);
};
i++;
};
return (false);
}
public function getEdge(edge:GeoEdge):GeoEdge{
if (hasEdge(edge)){
return (GeoEdge(_edges.getValue(edge.getKey())));
};
return (null);
}
public function newEdgeCollection():EdgeCollection{
return (new EdgeCollection());
}
public function getLength():Number{
return (_edges.getSize());
}
override public function clone():Shape{
var collection:EdgeCollection;
var edges:*;
var i:*;
collection = newEdgeCollection();
edges = getEdges();
i = 0;
while (i < edges.length) {
collection.addEdge(edges[i]);
i++;
};
return (collection);
}
public function addEdge(edge:GeoEdge){
if (!hasEdge(edge)){
_edges.setValue(edge.getKey(), edge);
};
}
override public function equals(other:Shape):Boolean{
var edge_collection:*;
var other_edges:*;
var i:Number;
var edges:*;
if (!(other is EdgeCollection)){
return (false);
};
edge_collection = EdgeCollection(other);
other_edges = edge_collection.getEdges();
i = 0;
while (i < other_edges.length) {
if (!hasEdge(other_edges[i])){
return (false);
};
i++;
};
edges = getEdges();
i = 0;
while (i < edges.length) {
if (!edge_collection.hasEdge(edges[i])){
return (false);
};
i++;
};
return (true);
}
}
}//package framework.GeometryGraph
Section 23
//GeoEdge (framework.GeometryGraph.GeoEdge)
package framework.GeometryGraph {
import framework.Geometry.*;
public class GeoEdge extends Segment {
protected var _requires_fastening:Boolean;// = false
public function GeoEdge(n1:GeoNode, n2:GeoNode){
_requires_fastening = false;
super(n1, n2);
}
override public function newPoint(x:Number, y:Number):Point{
return (new GeoNode(x, y));
}
override public function getOtherPoint(point:Point):Point{
return (GeoNode(super.getOtherPoint(point)));
}
override public function clone():Shape{
return (newGeoEdge(GeoNode(p1.clone()), GeoNode(p2.clone())));
}
override public function getTopPoint():Point{
return (GeoNode(super.getTopPoint()));
}
public function newGeoEdge(n1:GeoNode, n2:GeoNode):GeoEdge{
return (new GeoEdge(n1, n2));
}
public function requiresFastening():Boolean{
return (_requires_fastening);
}
override public function getNormalPoint(point:Point):Point{
return (GeoNode(super.getNormalPoint(point)));
}
public function newEdge(n1:GeoNode, n2:GeoNode):GeoEdge{
return (newGeoEdge(n1, n2));
}
override public function getIntersection(line:Line):Point{
return (GeoNode(super.getIntersection(line)));
}
}
}//package framework.GeometryGraph
Section 24
//GeoGraph (framework.GeometryGraph.GeoGraph)
package framework.GeometryGraph {
import framework.Geometry.*;
import framework.Utilities.*;
import flash.utils.*;
public class GeoGraph extends SpaceGrid {
private var _part_nodes:Array;
private var _part_edges:Array;
private var _nodes:HashTable;// = null
private var _edges:HashTable;// = null
public static var debug_output:Boolean = false;
public function GeoGraph(size:Number, number_parts:Number){
var part_size:*;
var i:*;
var j:*;
_nodes = null;
_edges = null;
super(size, number_parts);
_nodes = new HashTable();
_edges = new HashTable();
_part_nodes = new Array();
_part_edges = new Array();
part_size = getPartLength();
i = 0;
while (i < number_parts) {
_part_nodes[i] = new Array();
_part_edges[i] = new Array();
j = 0;
while (j < number_parts) {
_part_nodes[i][j] = new HashTable();
_part_edges[i][j] = new HashTable();
j++;
};
i++;
};
}
public function addEdge(edge:GeoEdge){
_addEdge(edge, true);
}
public function hasEdge(edge:GeoEdge):Boolean{
return (_edges.hasKey(edge.getKey()));
}
private function hasPartEdge(edge:GeoEdge, part_id:Array):Boolean{
return (_part_edges[part_id[0]][part_id[1]].hasKey(edge.getKey()));
}
private function _addNode(node:GeoNode, careful:Boolean){
var i:Number;
var part_ids:*;
var edge:GeoEdge;
var edges:*;
if (!hasNode(node)){
doutput(("+.^ " + node));
_nodes.setValue(node.getKey(), node);
if (careful){
edges = getCloseEdges(node);
i = 0;
while (i < edges.length) {
edge = edges[i];
if (edge.intercepts(node)){
_addEdge(edge.newEdge(GeoNode(edge.p1), node), true);
_addEdge(edge.newEdge(node, GeoNode(edge.p2)), true);
removeEdge(edge, false);
break;
};
i++;
};
};
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
setPartNode(node, part_ids[i]);
i++;
};
doutput(("+.v " + node));
};
}
public function newEdge(p1:GeoNode, p2:GeoNode):GeoEdge{
return (new GeoEdge(p1, p2));
}
public function populateGraph(graph:GeoGraph){
var edgeKeys:Array;
var edge:GeoEdge;
var i:*;
edgeKeys = _edges.getKeys();
i = 0;
while (i < edgeKeys.length) {
edge = GeoEdge(_edges.getValue(edgeKeys[i])).clone();
graph._addEdge(edge, false);
i++;
};
}
private function setPartNode(node:GeoNode, part_id:Array){
if (inPart(node, part_id)){
_part_nodes[part_id[0]][part_id[1]].setValue(node.getKey(), node);
};
}
public function (origin:Point, target:Point, snap:Boolean):Array{
return (getDirection(origin, target, snap, false));
}
public function getClosestDirection(origin:Point, target:Point, snap:Boolean):Array{
return (getDirection(origin, target, snap, true));
}
public function getCloseNodes(shape:Shape):Array{
var part_ids:*;
var close_nodes:*;
var part_nodes:*;
var i:*;
var j:*;
part_ids = getPartIds();
close_nodes = new HashTable();
i = 0;
while (i < part_ids.length) {
if (inPart(shape, part_ids[i])){
part_nodes = getPartNodes(part_ids[i]);
j = 0;
while (j < part_nodes.length) {
close_nodes.setValue(part_nodes[j].getKey(), part_nodes[j]);
j++;
};
};
i++;
};
return (close_nodes.getValues());
}
public function getEdges():Array{
return (_edges.getValues());
}
public function getClosest(point:Point, snap:Boolean):Array{
var closest:Array;
var edges:Array;
var edge:GeoEdge;
var edge_closest:Array;
var point2:Point;
var distance:Number;
var i:*;
closest = [null, null, null];
edges = getEdges();
i = 0;
while (i < edges.length) {
edge = GeoEdge(edges[i]);
edge_closest = edge.getClosest(point, true, snap);
point2 = edge_closest[0];
distance = edge_closest[1];
if (distance == 0){
return ([edge, point2, distance]);
};
if ((((closest[2] == null)) || ((distance < closest[2])))){
closest = [edge, point2, distance];
};
i++;
};
return ([closest[0], closest[1], point.getDistance(closest[1])]);
}
public function removeNode(node:GeoNode){
var actualNode:GeoNode;
var edges:Array;
var i:Number;
var part_ids:*;
if (hasNode(node)){
doutput(("-.^ " + node));
actualNode = getNode(node);
edges = actualNode.getEdges();
i = 0;
while (i < edges.length) {
removeEdge(GeoEdge(edges[i]), true);
i++;
};
_nodes.deleteKey(actualNode.getKey());
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
removePartNode(node, part_ids[i]);
i++;
};
doutput(("-.v " + node));
};
}
public function getEdge(edge:GeoEdge):GeoEdge{
if (hasEdge(edge)){
return (GeoEdge(_edges.getValue(edge.getKey())));
};
return (null);
}
public function getCloseEdges(shape:Shape):Array{
var part_ids:*;
var close_edges:*;
var part_edges:*;
var i:*;
var j:*;
part_ids = getPartIds();
close_edges = new HashTable();
i = 0;
while (i < part_ids.length) {
if (inPart(shape, part_ids[i])){
part_edges = getPartEdges(part_ids[i]);
j = 0;
while (j < part_edges.length) {
close_edges.setValue(part_edges[j].getKey(), part_edges[j]);
j++;
};
};
i++;
};
return (close_edges.getValues());
}
private function removePartNode(node:GeoNode, part_id:Array){
if (hasPartNode(node, part_id)){
_part_nodes[part_id[0]][part_id[1]].deleteKey(node.getKey());
};
}
public function hasNode(node:GeoNode):Boolean{
return (_nodes.hasKey(node.getKey()));
}
public function
(size, number_parts):GeoGraph{
return (new GeoGraph(size, number_parts));
}
private function _addEdge(edge:GeoEdge, careful:Boolean){
var i:Number;
var part_ids:*;
var edges:*;
var node:GeoNode;
var oldEdge:GeoEdge;
var nodes:*;
if (edge.p1.equals(edge.p2)){
return;
};
if (!hasEdge(edge)){
doutput(("+/^ " + edge));
if (edge.requiresFastening()){
if (((((!(hasNode(edge.p1))) && (!(intercepts(edge.p1))))) || (((!(hasNode(edge.p2))) && (!(intercepts(edge.p2))))))){
trace((("!!! Cannot add " + edge) + " because it requires fastening."));
return;
};
};
if (!hasNode(GeoNode(edge.p1))){
_addNode(GeoNode(edge.p1), careful);
if (!hasNode(GeoNode(edge.p1))){
trace("!!! Uh!");
_addNode(GeoNode(edge.p1), careful);
};
};
if (!hasNode(GeoNode(edge.p2))){
_addNode(GeoNode(edge.p2), careful);
if (!hasNode(GeoNode(edge.p2))){
trace("!!! Oh!");
_addNode(GeoNode(edge.p2), careful);
};
};
if (careful){
edges = getCloseEdges(edge);
i = 0;
while (i < edges.length) {
oldEdge = edges[i];
if (((oldEdge.hasEndPoint(edge.p1)) || (oldEdge.hasEndPoint(edge.p2)))){
} else {
node = oldEdge.getIntersection(edge);
if (((!((node == null))) && (!(hasNode(node))))){
doutput(((("+/ " + edge) + " intercepts ") + oldEdge));
_addNode(node, true);
_addEdge(edge.newEdge(GeoNode(edge.p1), node), true);
_addEdge(edge.newEdge(node, GeoNode(edge.p2)), true);
return;
};
};
i++;
};
nodes = getCloseNodes(edge);
i = 0;
while (i < nodes.length) {
node = nodes[i];
if (!edge.hasEndPoint(node)){
if (edge.intercepts(node)){
doutput(((("+/ " + edge) + " intercepts ") + node));
_addEdge(edge.newEdge(GeoNode(edge.p1), node), true);
_addEdge(edge.newEdge(node, GeoNode(edge.p2)), true);
return;
};
};
i++;
};
};
if ((((getNode(GeoNode(edge.p1)) == null)) || ((getNode(GeoNode(edge.p2)) == null)))){
trace(("!!! Failed to add one or more nodes for " + edge));
node = getNode(GeoNode(edge.p1));
if (node != null){
if (node.numberEdges() == 0){
trace((" ! Removing " + node));
removeNode(node);
};
} else {
trace((" ! Failed to add " + node));
};
node = getNode(GeoNode(edge.p2));
if (node != null){
if (node.numberEdges() == 0){
trace((" ! Removing " + node));
removeNode(node);
};
} else {
trace((" ! Failed to add " + node));
};
return;
};
_edges.setValue(edge.getKey(), edge);
getNode(GeoNode(edge.p1)).addEdge(edge);
getNode(GeoNode(edge.p2)).addEdge(edge);
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
setPartEdge(edge, part_ids[i]);
i++;
};
doutput(("+/v " + edge));
};
}
public function newNode(x:Number, y:Number):GeoNode{
return (new GeoNode(x, y));
}
public function addNode(node:GeoNode){
_addNode(node, true);
}
override public function equals(other:Shape):Boolean{
var i:*;
var graph:GeoGraph;
var nodeKeys:Array;
var edgeKeys:Array;
if (!(other is GeoGraph)){
return (false);
};
graph = GeoGraph(other);
nodeKeys = _nodes.getKeys();
i = 0;
while (i < nodeKeys.length) {
if (!graph.hasNode(GeoNode(_nodes[nodeKeys[i]]))){
return (false);
};
i++;
};
nodeKeys = graph.getNodes().getKeys();
i = 0;
while (i < nodeKeys.length) {
if (!hasNode(GeoNode(graph.getNodes()[nodeKeys[i]]))){
return (false);
};
i++;
};
edgeKeys = _edges.getKeys();
i = 0;
while (i < edgeKeys.length) {
if (!graph.hasEdge(GeoEdge(_edges[edgeKeys[i]]))){
return (false);
};
i++;
};
edgeKeys = graph.getEdges().getKeys();
i = 0;
while (i < edgeKeys.length) {
if (!hasEdge(GeoEdge(graph.getEdges()[edgeKeys[i]]))){
return (false);
};
i++;
};
return (true);
}
private function getPartNodes(part_id:Array):Array{
return (_part_nodes[part_id[0]][part_id[1]].getValues());
}
public function getDirection(origin:Point, target:Point, snap:Boolean, near:Boolean):Array{
var line:Line;
var edges:Array;
var closest:Array;
var above:Boolean;
var horizontal:Boolean;
var edge:GeoEdge;
var point:Point;
var distance:Number;
var extreme:Boolean;
var i:*;
line = Line.fromPoints(origin, target);
edges = getIntersections(line, true).getEdges();
closest = [null, null, null];
horizontal = (line.slope == 0);
if (horizontal){
above = (origin.x > target.x);
} else {
above = (origin.y > target.y);
};
i = 0;
while (i < edges.length) {
edge = edges[i];
point = edge.getIntersection(line);
distance = origin.getDistance(point);
if (distance < 0.001){
} else {
if (near){
extreme = (distance < closest[2]);
} else {
extreme = (distance > closest[2]);
};
if ((((closest[2] == null)) || (extreme))){
if (horizontal){
if (((((above) && ((origin.x > point.x)))) || (((!(above)) && ((point.x > origin.x)))))){
closest = [edge, point, distance];
};
} else {
if (((((above) && ((origin.y > point.y)))) || (((!(above)) && ((point.y > origin.y)))))){
closest = [edge, point, distance];
};
};
};
};
i++;
};
if (closest[1] == null){
return (closest);
};
return ([closest[0], closest[1], origin.getDistance(closest[1])]);
}
private function hasPartNode(node:GeoNode, part_id:Array):Boolean{
return (_part_nodes[part_id[0]][part_id[1]].hasKey(node.getKey()));
}
public function getEdgesInRange(origin:Point, target:Point):PriorityQueue{
var line:Line;
var edges:Array;
var edges_in_range:PriorityQueue;
var closest_before:Array;
var closest_past:Array;
var above:Boolean;
var horizontal:Boolean;
var edge:GeoEdge;
var point:Point;
var origin_distance:Number;
var target_distance:Number;
var before:Boolean;
var current_edge_information:Array;
var i:*;
line = Line.fromPoints(origin, target);
edges = getIntersections(line, true).getEdges();
edges_in_range = new PriorityQueue();
closest_before = [null, null, null];
closest_past = [null, null, null];
horizontal = (line.slope == 0);
if (horizontal){
above = (origin.x > target.x);
} else {
above = (origin.y > target.y);
};
i = 0;
for (;i < edges.length;i++) {
edge = edges[i];
point = edge.getIntersection(line);
origin_distance = origin.getDistance(point);
if (origin_distance < 0.001){
} else {
if (horizontal){
if (((((above) && ((origin.x < point.x)))) || (((!(above)) && ((point.x < origin.x)))))){
continue;
};
if (((((above) && ((target.x <= point.x)))) || (((!(above)) && ((point.x <= target.x)))))){
before = true;
} else {
before = false;
};
} else {
if (((((above) && ((origin.y < point.y)))) || (((!(above)) && ((point.y < origin.y)))))){
continue;
};
if (((((above) && ((target.y <= point.y)))) || (((!(above)) && ((point.y <= target.y)))))){
before = true;
} else {
before = false;
};
};
target_distance = target.getDistance(point);
current_edge_information = [edge, point, origin_distance, target_distance];
if (before){
edges_in_range.push((-1 * origin_distance), current_edge_information);
if ((((closest_before[3] == null)) || ((target_distance < closest_before[3])))){
closest_before = current_edge_information;
};
} else {
if ((((closest_past[3] == null)) || ((target_distance < closest_past[3])))){
closest_past = current_edge_information;
};
};
};
};
if (closest_before[3] != null){
if (((!((closest_past[3] == null))) && ((closest_past[3] < closest_before[3])))){
edges_in_range.push((-1 * closest_past[2]), closest_past);
};
} else {
if (closest_past[3] != null){
if (origin.getDistance(target) > closest_past[3]){
edges_in_range.push((-1 * closest_past[2]), closest_past);
};
};
};
return (edges_in_range);
}
private function setPartEdge(edge:GeoEdge, part_id:Array){
if (inPart(edge, part_id)){
_part_edges[part_id[0]][part_id[1]].setValue(edge.getKey(), edge);
};
}
public function getIntersections(other:Shape, all_edges:Boolean):EdgeCollection{
var edges:*;
var edge:GeoEdge;
var intersections:EdgeCollection;
var i:*;
edges = getCloseEdges(other);
intersections = new EdgeCollection();
i = 0;
while (i < edges.length) {
edge = edges[i];
if (edge.intercepts(other)){
intersections.addEdge(edge);
};
i++;
};
return (intersections);
}
override public function clone():Shape{
var graph:GeoGraph;
graph = GeoGraph(super.clone());
populateGraph(graph);
return (graph);
}
public function doutput(message:String){
if (debug_output){
trace(message);
};
}
override public function toString():String{
var str:String;
var edgeKeys:Array;
var i:*;
str = "{Graph: ";
edgeKeys = _edges.getKeys();
i = 0;
while (i < edgeKeys.length) {
str = (str + GeoEdge(_edges.getValue(edgeKeys[i])).toString());
if (i != (edgeKeys.length - 1)){
str = (str + ", ");
};
i++;
};
str = (str + "}");
return (str);
}
private function getPartEdges(part_id:Array):Array{
return (_part_edges[part_id[0]][part_id[1]].getValues());
}
override public function intercepts(other:Shape):Boolean{
var edges:Array;
var edge:GeoEdge;
var i:*;
edges = getCloseEdges(other);
i = 0;
while (i < edges.length) {
edge = edges[i];
if (edge.intercepts(other)){
return (true);
};
i++;
};
return (false);
}
private function removePartEdge(edge:GeoEdge, part_id:Array){
if (hasPartEdge(edge, part_id)){
_part_edges[part_id[0]][part_id[1]].deleteKey(edge.getKey());
};
}
public function getNode(node:GeoNode):GeoNode{
if (hasNode(node)){
return (GeoNode(_nodes.getValue(node.getKey())));
};
return (null);
}
public function removeEdge(edge:GeoEdge, collapse:Boolean){
var node:GeoNode;
var part_ids:*;
var i:*;
if (hasEdge(edge)){
doutput(("-/^ " + edge));
node = getNode(GeoNode(edge.p1));
node.removeEdge(edge);
if (node.numberEdges() == 0){
removeNode(node);
};
node = getNode(GeoNode(edge.p2));
node.removeEdge(edge);
if (node.numberEdges() == 0){
removeNode(node);
};
_edges.deleteKey(edge.getKey());
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
removePartEdge(edge, part_ids[i]);
i++;
};
doutput(("-/v " + edge));
};
}
public function getNodes():Array{
return (_nodes.getValues());
}
public function findPath(start_point:GeoNode, end_point:GeoNode):Path{
var paths_searched:*;
var start_time:*;
var end_time:Number;
var i:Number;
var start_closest:Array;
var end_closest:Array;
var path:Path;
var added_edges:Array;
var removed_edges:Array;
var new_node:GeoNode;
var paths:PriorityQueue;
var edges:Array;
var edge:GeoEdge;
var seen:Boolean;
var new_path:Path;
var seen_edges:HashTable;
paths_searched = 0;
start_time = getTimer();
if (start_point.equals(end_point)){
return (new Path(start_point));
};
start_closest = getClosest(start_point, true);
end_closest = getClosest(end_point, true);
if (start_closest[1] == null){
trace("!!! Error: Undefined closest point!");
trace((" Searched from " + start_point));
} else {
if (start_closest[1].equals(start_closest[0].p1)){
start_closest[1] = start_closest[0].p1;
} else {
if (start_closest[1].equals(start_closest[0].p2)){
start_closest[1] = start_closest[0].p2;
};
};
};
if ((((start_closest[2] > 0.001)) || ((end_closest[2] > 0.001)))){
if (start_closest[2] > 0.001){
} else {
if (end_closest[2] > 0.001){
};
};
return (new Path(start_point));
};
if (start_closest[0].equals(end_closest[0])){
path = new Path(start_point);
path.addEdge(newEdge(newNode(start_point.x, start_point.y), newNode(end_point.x, end_point.y)));
end_time = getTimer();
return (path);
};
added_edges = new Array();
removed_edges = new Array();
if (!start_closest[0].hasEndPoint(start_point)){
new_node = start_closest[1];
added_edges.push(newEdge(new_node, start_closest[0].p1));
added_edges.push(newEdge(new_node, start_closest[0].p2));
};
if (!end_closest[0].hasEndPoint(end_point)){
new_node = end_closest[1];
added_edges.push(newEdge(new_node, end_closest[0].p1));
added_edges.push(newEdge(new_node, end_closest[0].p2));
};
i = 0;
while (i < added_edges.length) {
_addEdge(added_edges[i], false);
i++;
};
i = 0;
while (i < removed_edges.length) {
removeEdge(removed_edges[i], false);
i++;
};
paths = new PriorityQueue();
path = new Path(getNode(start_closest[1]));
paths.push((-1 * (path.getLength() + path.end_point.getDistance(end_point))), path);
seen_edges = new HashTable();
while (!(paths.isEmpty())) {
path = Path(paths.pop());
paths_searched++;
if (path.end_point.equals(end_point)){
i = 0;
while (i < added_edges.length) {
removeEdge(added_edges[i], false);
i++;
};
i = 0;
while (i < removed_edges.length) {
_addEdge(removed_edges[i], false);
i++;
};
end_time = getTimer();
return (path.collapse());
} else {
edges = getNode(path.end_point).getEdges();
if ((((getNode(path.end_point) == null)) || ((edges.length == 0)))){
trace((((("!!! Error: Node " + getNode(path.end_point)) + " (from ") + path.end_point) + ") has no edges!"));
trace((" ! Start point: " + start_point));
trace((" ! Closest: " + start_closest));
trace((" ! Actual closest: " + getNode(start_closest[1])));
};
i = 0;
while (i < edges.length) {
edge = edges[i];
if (!seen_edges.hasKey(edge.getKey())){
seen_edges.setValue(edge.getKey(), edge);
new_path = path.extendPath(edge);
paths.push((-1 * (new_path.getLength() + new_path.end_point.getDistance(end_point))), new_path);
};
i++;
};
};
};
trace(((("!!! No path found from " + start_point) + " to ") + end_point));
trace((" Paths searched: " + paths_searched));
i = 0;
while (i < added_edges.length) {
removeEdge(added_edges[i], false);
i++;
};
i = 0;
while (i < removed_edges.length) {
_addEdge(removed_edges[i], false);
i++;
};
return (new Path(start_point));
}
}
}//package framework.GeometryGraph
Section 25
//GeoNode (framework.GeometryGraph.GeoNode)
package framework.GeometryGraph {
import framework.Geometry.*;
import framework.Utilities.*;
public class GeoNode extends Point {
private var _edges:HashTable;// = null
public function GeoNode(x:Number, y:Number){
_edges = null;
super(x, y);
_edges = new HashTable();
}
public function newGeoNode(x:Number, y:Number):GeoNode{
return (new GeoNode(x, y));
}
public function getNextEdge():GeoEdge{
if (hasEdges()){
return (_edges.getValues()[0]);
};
return (null);
}
override public function moveTowards(distance:Number, target:Point):Point{
return (GeoNode(super.moveTowards(distance, target)));
}
public function numberEdges():Number{
return (_edges.getSize());
}
override public function newPoint(x:Number, y:Number):Point{
return (newGeoNode(x, y));
}
public function hasEdges():Boolean{
return ((_edges.getSize() > 0));
}
override public function clone():Shape{
return (newGeoNode(x, y));
}
public function getEdges():Array{
return (_edges.getValues());
}
public function removeEdge(edge:GeoEdge){
if (hasEdge(edge)){
_edges.deleteKey(edge.getKey());
};
}
public function hasEdge(edge:GeoEdge):Boolean{
return (_edges.hasKey(edge.getKey()));
}
public function getEdge(edge:GeoEdge):GeoEdge{
return (GeoEdge(_edges.getValue(edge.getKey())));
}
public function addEdge(edge:GeoEdge){
_edges.setValue(edge.getKey(), edge);
}
}
}//package framework.GeometryGraph
Section 26
//Path (framework.GeometryGraph.Path)
package framework.GeometryGraph {
import framework.Geometry.*;
public class Path extends Shape {
public var current_edge:Number;// = NAN
public var next_point:GeoNode;// = null
private var _length:Number;// = 0
public var current_point:GeoNode;// = null
private var _edges:Array;// = null
public var start_point:GeoNode;// = null
public var end_point:GeoNode;// = null
public function Path(starting_point:GeoNode){
_edges = null;
_length = 0;
start_point = null;
current_point = null;
next_point = null;
current_edge = NaN;
end_point = null;
super();
_edges = new Array();
_length = 0;
start_point = starting_point;
current_point = starting_point;
next_point = null;
current_edge = NaN;
end_point = starting_point;
}
public function isFirstEdge():Boolean{
return ((current_edge == 0));
}
public function travel(distance:Number, graph:GeoGraph):GeoNode{
var edge:GeoEdge;
var current_distance:Number;
if (isNaN(current_edge)){
return (current_point);
};
edge = _edges[current_edge];
current_distance = current_point.getDistance(next_point);
while (current_distance < distance) {
if (isLastEdge()){
current_edge = NaN;
current_point = end_point;
distance = 0;
return (current_point);
};
current_edge++;
current_point = next_point;
next_point = _edges[current_edge].getOtherPoint(next_point);
if (((!(isLastEdge())) && (!(graph.hasEdge(_edges[current_edge]))))){
return (null);
};
if (!graph.intercepts(end_point)){
return (null);
};
distance = (distance - current_distance);
current_distance = current_point.getDistance(next_point);
};
current_point = current_point.moveTowards(distance, next_point);
return (current_point);
}
public function getLength():Number{
return (_length);
}
override public function clone():Shape{
var path:Path;
var i:*;
path = newPath(start_point);
i = 0;
while (i < _edges.length) {
path.addEdge(_edges[i].clone());
i++;
};
return (path);
}
public function extendPath(edge:GeoEdge):PathExtension{
var path:PathExtension;
path = new PathExtension(this, edge);
return (path);
}
public function getCurrentEdge():GeoEdge{
if (isNaN(current_edge)){
return (null);
};
return (_edges[current_edge]);
}
public function newPath(starting_point:GeoNode):Path{
return (new Path(starting_point));
}
public function getEdges():Array{
return (_edges);
}
override public function toString():String{
var string:String;
var i:*;
string = "{Path: ";
i = 0;
while (i < _edges.length) {
string = (string + _edges[i].toString());
if (i != (_edges.length - 1)){
string = (string + ", ");
};
i++;
};
string = (string + "}");
return (string);
}
public function collapse():Path{
return (this);
}
override public function intercepts(other:Shape):Boolean{
return (false);
}
public function isLastEdge():Boolean{
return ((current_edge == (_edges.length - 1)));
}
public function addEdge(edge:GeoEdge){
if (!edge.hasEndPoint(end_point)){
throw (new Error(((end_point.toString() + " is not an end point of ") + edge.toString())));
};
_edges.push(edge);
_length = (_length + edge.getLength());
end_point = edge.getOtherPoint(end_point);
if (_edges.length == 1){
current_edge = 0;
next_point = end_point;
};
}
override public function equals(other:Shape):Boolean{
var path:Path;
var edges:Array;
var i:*;
if (!(other is Path)){
return (false);
};
path = Path(other);
if (!end_point.equals(path.end_point)){
return (false);
};
edges = path.getEdges();
if (_edges.length != edges.length){
return (false);
};
i = 0;
while (i < edges.length) {
if (!_edges[i].equals(edges[i])){
return (false);
};
i++;
};
return (true);
}
}
}//package framework.GeometryGraph
Section 27
//PathExtension (framework.GeometryGraph.PathExtension)
package framework.GeometryGraph {
public class PathExtension extends Path {
private var _new_edge:GeoEdge;
private var _old_path:Path;
public function PathExtension(old_path:Path, new_edge:GeoEdge){
_old_path = old_path;
super(_old_path.start_point);
start_point = _old_path.start_point;
_length = _old_path.getLength();
_new_edge = new_edge;
_length = (_length + _new_edge.getLength());
end_point = _new_edge.getOtherPoint(_old_path.end_point);
}
override public function toString():String{
return (((("Path ending with " + _new_edge) + " at ") + end_point));
}
override public function collapse():Path{
var path:Path;
path = _old_path.collapse();
path.addEdge(_new_edge);
return (path);
}
}
}//package framework.GeometryGraph
Section 28
//Catchable (framework.Spider.Abstract.Catchable)
package framework.Spider.Abstract {
import framework.Spider.Web.*;
import game.*;
import framework.Geometry.*;
import flash.display.*;
import audio.*;
import framework.Action.*;
import framework.GeometryGraph.*;
import framework.Spider.Actions.*;
import flash.utils.*;
public class Catchable implements Actor {
public var approach_time:Number;
public var hover_y_speed:Number;
protected var movie_clip:String;
protected var _body_radius:Number;
public var hover_finished:Boolean;// = false
public var id:Number;
public var hovering:Boolean;// = false
public var position:Point;
protected var _dying:Boolean;// = false
public var hover_duration:Number;
public var web:Web;
protected var _action:Action;// = null
protected var _edges:EdgeCollection;
protected var _scatter:Number;// = 0
public var hover_target_point:Point;
protected var _cache_on_catch:Boolean;// = true
public var hover_distance:Number;
protected var _caught:Boolean;// = false
public var tutorial_id:String;
public var hover_sound_name:String;
protected var _strength:Number;
public var body:Shape;
protected var _marked_graphic_type:String;// = "small"
public var hover_moving:Boolean;
public var approach_sound_name:String;
public var hover_y_direction:Number;
public var approach_sound:SoundHandle;
public var hover_probability:Number;
protected var _x_shift:Number;
public var hover_x_speed:Number;
public var tilt:Number;// = 0
protected var _strand_damage:Number;
public var graphic_parent:MovieClip;
public var graphic:MovieClip;
protected var _birth_time:Number;
public var hover_time:Number;
private var _marked_graphic:MovieClip;
public var hover_x_direction:Number;
protected var _y_shift:Number;
static var catchable_id = 0;
public function Catchable(x:Number, y:Number, web1:Web){
_action = null;
_cache_on_catch = true;
_caught = false;
_dying = false;
_edges = new EdgeCollection();
_scatter = 0;
_marked_graphic_type = "small";
hover_finished = false;
hovering = false;
tilt = 0;
super();
body = null;
approach_time = 0;
movie_clip = "None";
_strength = 0;
_strand_damage = 0;
}
public function flyAway(){
removeGraphic();
graphic_parent = web.after_web;
addGraphic();
graphic.gotoAndPlay("flying");
if (_cache_on_catch){
graphic.cacheAsBitmap = false;
};
removeMarkedGraphic();
addAction(new LeaveWebAction((approach_time / 2)));
}
public function startHover(){
hovering = true;
hover_time = hover_duration;
hover_moving = false;
graphic.gotoAndPlay("hovering");
playHoverSound();
}
public function addGraphic(){
graphic_parent.addChild(graphic);
}
public function (height:Number, width:Number, center:Point):Rectangle{
var half_height:Number;
var half_width:Number;
var p1:Point;
var p2:Point;
half_height = (height / 2);
half_width = (width / 2);
p1 = new Point((center.x - half_width), (center.y - half_height));
p2 = new Point((center.x + half_width), (center.y + half_height));
return (new Rectangle(p1, p2));
}
public function getBody():Shape{
return (body);
}
public function specialDestroy(){
}
public function swarmerKey():String{
return (actorKey());
}
public function endHover(){
hovering = false;
hover_finished = true;
graphic.gotoAndPlay("flying");
}
public function isDying():Boolean{
return (_dying);
}
public function actorKey():String{
return (("catchable" + id));
}
public function addAction(action:Action){
_action = action;
}
public function collide(){
var edges:EdgeCollection;
var edge_list:Array;
var strength:*;
var i:Number;
var start_time:Number;
var dividing_node:WebNode;
var current_strand:WebStrand;
var new_strand:WebStrand;
var j:Number;
var end_time:Number;
if (web != null){
removeGraphic();
graphic_parent = web.almost_web;
addGraphic();
clearFromEdges();
_caught = false;
edges = web.getIntersections(body, false);
if (edges.getLength() == 0){
flyAway();
} else {
edge_list = edges.getEdges();
strength = 0;
i = 0;
while (i < edge_list.length) {
strength = (strength + edge_list[i].getStrength());
i++;
};
if (strength < _strength){
updateMaintainedStrength((_strength - strength));
web.game.collapsing_web = true;
web.game.collapsing_precedent = 1;
start_time = getTimer();
web.addCollapsingStrand(null);
AudioEngine.PlaySound("sfxWebBreak", AudioEngine.SFX_CHANNEL, false);
j = 0;
while (j < edge_list.length) {
current_strand = WebStrand(edge_list[j]);
dividing_node = WebNode(current_strand.getClosest(position, true, false)[0]);
if (!dividing_node.equals(current_strand.p1)){
new_strand = new WebStrand(current_strand.p1, dividing_node, current_strand.getStrength());
web.game.addCollapsingStrand(new_strand, current_strand.p1);
};
if (!dividing_node.equals(current_strand.p2)){
new_strand = new WebStrand(current_strand.p2, dividing_node, current_strand.getStrength());
web.game.addCollapsingStrand(new_strand, current_strand.p2);
};
web.addCollapsingStrand(current_strand);
j++;
};
web.collapseStrands();
end_time = getTimer();
flyAway();
} else {
resetMaintainedStrength();
_caught = true;
_edges = edges;
i = 0;
while (i < edge_list.length) {
edge_list[i].addActor(this);
i++;
};
_strand_damage = (_strength / _edges.getLength());
graphic.scaleX = 1;
graphic.scaleY = 1;
graphic.gotoAndPlay("flying");
graphic.gotoAndPlay("caught");
if (_cache_on_catch){
graphic.cacheAsBitmap = true;
};
addAction(new StruggleAction(web));
specialCatch();
web.game.displayTutorial("caught");
};
};
};
}
public function actionUpdateGraphic(level_data:LevelData, time:Number){
if (_action == null){
return;
};
_action.updateGraphic(this, level_data, time);
}
public function isCaught():Boolean{
return (_caught);
}
public function newMarkedGraphic():MovieClip{
if (_marked_graphic_type == "small"){
return (new MarkedSmallGraphic());
};
if (_marked_graphic_type == "medium"){
return (new MarkedMediumGraphic());
};
if (_marked_graphic_type == "large"){
return (new MarkedLargeGraphic());
};
throw (new Exception(("Unknown marked graphic type: " + _marked_graphic_type)));
}
public function ():String{
return (actorKey());
}
public function getDamage():Number{
return (_strand_damage);
}
public function getMarkedGraphic():MovieClip{
if (_marked_graphic == null){
_marked_graphic = newMarkedGraphic();
_marked_graphic.alpha = 0.55;
};
return (_marked_graphic);
}
public function updateMaintainedStrength(value:Number){
}
public function specialCatch(){
}
public function playHoverSound(){
var hover_sound:SoundHandle;
if (hover_sound_name != null){
hover_sound = AudioEngine.PlaySound(hover_sound_name, AudioEngine.SFX_CHANNEL, false);
hover_sound.SetPan(((2 * position.x) - 1));
};
}
public function act(time:Number){
if (_action == null){
return;
};
if (_action.act(this, time)){
_action = null;
};
}
public function generalInitialize(x:Number, y:Number, web1:Web){
id = catchable_id++;
addAction(new ApproachWebAction(this.approach_time));
_birth_time = getTimer();
position = new Point(x, y);
body = new Circle(position, _body_radius);
web = web1;
graphic_parent = web.before_web;
addGraphic();
graphic.gotoAndPlay("flying");
_edges = new EdgeCollection();
web.addCatchable(this);
_x_shift = ((Math.random() * 0.2) - 0.1);
_y_shift = ((Math.random() * 0.2) - 0.1);
if ((((_x_shift == 0)) && ((_y_shift == 0)))){
_y_shift = 0.1;
};
while ((Math.abs(_x_shift) + Math.abs(_y_shift)) < 0.05) {
_x_shift = (_x_shift * 2);
_y_shift = (_y_shift * 2);
};
if (tutorial_id){
web.game.displayTutorial(tutorial_id);
};
}
public function getEdges():Array{
return (_edges.getEdges());
}
public function resetMaintainedStrength(){
}
public function equals(other:Object):Boolean{
if (!(other is Catchable)){
return (false);
};
return ((actorKey() == Catchable(other).actorKey()));
}
public function removeGraphic(){
graphic_parent.removeChild(graphic);
}
public function attachMarkedGraphic(){
graphic.addChild(getMarkedGraphic());
}
public function updateGraphic(level_data:LevelData, factor:Number, time:Number){
var x:Number;
var y:Number;
var current_tilt:Number;
if (position == null){
return;
};
if (_scatter > 0){
if (((!(isCaught())) && (!(hover_moving)))){
position.y = (position.y + (((Math.random() * _scatter) - (_scatter / 2)) * factor));
position.x = (position.x + (((Math.random() * _scatter) - (_scatter / 2)) * factor));
};
};
x = (position.x - (((factor - 1) * (factor - 1)) * _x_shift));
y = (position.y - (((factor - 1) * (factor - 1)) * _y_shift));
if (factor > 1){
if ((((((((y < 0)) || ((y > 1)))) || ((x < 0)))) || ((x > 1)))){
addAction(new CatchableDieAction(web));
};
};
if (approach_sound != null){
approach_sound.SetPan(((2 * x) - 1));
};
if (tilt != 0){
current_tilt = (((Math.random() * 2) * tilt) - tilt);
graphic.rotation = current_tilt;
};
graphic.x = level_data.convertX(x);
graphic.y = level_data.convertY(y);
graphic.scaleX = factor;
graphic.scaleY = factor;
}
public function updateHover(){
var angle:Number;
if (Math.random() < hover_probability){
hover_moving = true;
hover_target_point = web.game.environment.generatePoint();
angle = position.getAngle(hover_target_point);
if (hover_target_point.x < position.x){
hover_x_direction = -1;
} else {
hover_x_direction = 1;
};
hover_x_speed = (Math.cos(angle) / approach_time);
if (hover_target_point.y < position.y){
hover_y_direction = -1;
} else {
hover_y_direction = 1;
};
hover_y_speed = (Math.sin(angle) / approach_time);
hover_time = hover_duration;
} else {
endHover();
};
}
public function removeMarkedGraphic(){
if (((!((graphic == null))) && (!((_marked_graphic == null))))){
graphic.removeChild(getMarkedGraphic());
_marked_graphic = null;
};
}
public function destroy(){
_dying = true;
clearFromEdges();
specialDestroy();
}
public function clearFromEdges(){
var edges:Array;
var i:*;
edges = getEdges();
i = 0;
while (i < edges.length) {
if (!edges[i].isDying()){
edges[i].deleteActor(this);
};
i++;
};
}
}
}//package framework.Spider.Abstract
Section 29
//Edible (framework.Spider.Abstract.Edible)
package framework.Spider.Abstract {
import framework.Spider.Bugs.*;
public interface Edible {
function eat(_arg1:Spider, _arg2:Number):Boolean;
function (_arg1:Spider, _arg2:Number);
}
}//package framework.Spider.Abstract
Section 30
//Swarm (framework.Spider.Abstract.Swarm)
package framework.Spider.Abstract {
import framework.Utilities.*;
public class Swarm {
private static var _preparers:Number = 0;
private static var _swarmers:HashTable = new HashTable();
public function Swarm(){
super();
}
public static function addSwarmer(swarmer:Catchable){
if (!_swarmers.hasKey(swarmer.swarmerKey())){
_swarmers.setValue(swarmer.swarmerKey(), swarmer);
};
}
public static function prepare(){
_preparers = (_preparers + 1);
}
public static function collide(){
var swarmers_list:*;
var i:*;
_preparers = (_preparers - 1);
if (_preparers < 0){
throw (new Error("You can not collide a Swarm before preparing."));
};
if (_preparers == 0){
swarmers_list = Swarm._swarmers.getValues();
i = 0;
while (i < swarmers_list.length) {
swarmers_list[i].collide();
i++;
};
reset();
};
}
private static function reset(){
_preparers = 0;
_swarmers = new HashTable();
}
}
}//package framework.Spider.Abstract
Section 31
//WebCrawler (framework.Spider.Abstract.WebCrawler)
package framework.Spider.Abstract {
import framework.Spider.Web.*;
import game.*;
import framework.Geometry.*;
import flash.display.*;
import framework.Action.*;
import framework.Utilities.*;
public class WebCrawler extends WebNode implements Actor {
public var animation:String;// = "resting"
public var id:Number;// = NAN
private var _action_queue:Queue;// = null
public var edge:WebEdge;// = null
public var speed:Number;// = 1
public var rotation_speed:Number;// = 360
public var web:Web;// = null
public var graphic:MovieClip;// = null
static var web_crawler_id = 1;
public function WebCrawler(x1:Number, y1:Number, aweb:Web){
var closest:*;
edge = null;
id = NaN;
rotation_speed = 360;
speed = 1;
web = null;
graphic = null;
animation = "resting";
_action_queue = null;
super(x1, y1);
id = web_crawler_id++;
web = aweb;
closest = web.getClosest(this, true);
edge = closest[0];
x = closest[1].x;
y = closest[1].y;
_initializeActions();
}
public function forceAction(action:Action){
clearActions();
addAction(action);
}
public function act(time:Number){
var action:Action;
var time = time;
if (_action_queue.isEmpty()){
return;
};
action = Action(_action_queue.peek());
if (action.act(this, time)){
_action_queue.pop();
};
//unresolved jump
var _slot1 = exception;
action = _action_queue.pop();
action.cancel();
}
public function getBody():Shape{
return (null);
}
public function currentAction():Action{
if (!_action_queue.isEmpty()){
return (Action(_action_queue.peek()));
};
return (null);
}
public function cancelActions(){
var action:Action;
if (!_action_queue.isEmpty()){
action = Action(_action_queue.pop());
forceAction(action);
};
}
public function actorKey():String{
return (("WebCrawler" + id));
}
public function rotateTowards(point:Point, time:Number){
var angle:Number;
var difference:Number;
var rotation:Number;
angle = ((180 * getAngle(point)) / Math.PI);
difference = (graphic.rotation - angle);
if (difference > 180){
angle = (angle + 360);
} else {
if (difference < -180){
angle = (angle - 360);
};
};
rotation = ((speed * rotation_speed) * time);
if (graphic.rotation < angle){
if ((graphic.rotation + rotation) > angle){
updateGraphicRotation(angle);
} else {
updateGraphicRotation((graphic.rotation + rotation));
};
} else {
if (graphic.rotation > angle){
if ((graphic.rotation - rotation) < angle){
updateGraphicRotation(angle);
} else {
updateGraphicRotation((graphic.rotation - rotation));
};
};
};
fixRotation();
}
public function addAction(action:Action){
_action_queue.push(action);
}
public function updateAnimation(new_animation:String){
if (animation != new_animation){
animation = new_animation;
graphic.gotoAndPlay(new_animation);
};
}
public function onEdge(web_edge:WebEdge){
var edges:Array;
var i:*;
if (edge == null){
return (false);
};
if (edge.equals(web_edge)){
return (true);
};
if (web.hasNode(this)){
edges = web.getNode(this).getEdges();
i = 0;
while (i < edges.length) {
if (web_edge.equals(WebEdge(edges[i]))){
return (true);
};
i++;
};
};
return (false);
}
public function actionUpdateGraphic(level_data:LevelData, time:Number){
var mouse:*;
var action:Action;
if (_action_queue.isEmpty()){
mouse = web.game.gMouse;
rotateTowards(new Point(mouse.x, mouse.y), time);
} else {
action = Action(_action_queue.peek());
action.updateGraphic(this, level_data, time);
};
}
private function _initializeActions(){
_action_queue = new Queue();
}
public function fixRotation(){
if (graphic.rotation < 0){
graphic.rotation = (graphic.rotation + 360);
};
if (graphic.rotation > 360){
graphic.rotation = (graphic.rotation - 360);
};
}
public function updateGraphic(level_data:LevelData, time:Number){
if (graphic != null){
graphic.x = level_data.convertX(x);
graphic.y = level_data.convertY(y);
};
}
public function updateGraphicRotation(angle:Number){
graphic.rotation = angle;
}
public function clearActions(){
var action:Action;
while (!(_action_queue.isEmpty())) {
action = Action(_action_queue.pop());
action.cancel();
};
}
}
}//package framework.Spider.Abstract
Section 32
//AddMultipleStrandsAction (framework.Spider.Actions.AddMultipleStrandsAction)
package framework.Spider.Actions {
import framework.Spider.Web.*;
import audio.*;
import framework.Spider.Bugs.*;
import framework.Action.*;
import framework.Utilities.*;
public class AddMultipleStrandsAction extends AddStrandAction {
private var _planned_web_strand:WebStrand;
private var _web:Web;
private var _edges:PriorityQueue;
private var _sound_effect:SoundHandle;
private var _crawl_action:CrawlAction;
public function AddMultipleStrandsAction(start_node:WebNode, target:WebNode, web:Web){
var edges:PriorityQueue;
var info:Array;
super(target);
_edges = null;
_crawl_action = null;
_web = web;
edges = _web.getEdgesInRange(start_node, target);
while (!(edges.isEmpty())) {
info = edges.pop();
};
if (info != null){
_planned_web_strand = new WebStrand(start_node, info[1], 1);
web.addPlannedStrand(_planned_web_strand);
};
}
override public function act(actor:Actor, time:Number):Boolean{
var spider:Spider;
var target_info:Array;
var target_point:WebNode;
var distance_p1:Number;
var distance_p2:Number;
if (!(actor is Spider)){
throw (new Error(("Only Spiders can perform AddMultipleStrandsAction, not " + actor)));
};
spider = Spider(actor);
if (_edges == null){
_edges = spider.web.getEdgesInRange(spider, _target_point);
};
while ((((((path == null)) && ((_crawl_action == null)))) && (!(_edges.isEmpty())))) {
target_info = new Array(_edges.pop());
target_info = target_info[0];
if (spider.equals(target_info[1])){
} else {
if (!updatePath(spider, target_info[1], target_info[0])){
if (!hasWebbing(spider)){
_web.removePlannedStrand(_planned_web_strand);
endSound();
return (true);
};
path = null;
distance_p1 = target_info[1].getDistanceSquared(target_info[0].p1);
distance_p2 = target_info[1].getDistanceSquared(target_info[0].p2);
if (distance_p1 < 0.001){
if (distance_p2 < distance_p1){
target_point = WebNode(target_info[0].p2);
} else {
target_point = WebNode(target_info[0].p1);
};
} else {
if (distance_p2 < 0.001){
target_point = WebNode(target_info[0].p2);
} else {
target_point = target_info[1];
};
};
_crawl_action = new CrawlAction(target_point);
};
};
};
if ((((path == null)) && ((_crawl_action == null)))){
_web.removePlannedStrand(_planned_web_strand);
endSound();
return (true);
};
if (_crawl_action != null){
if (_crawl_action.act(spider, time)){
_crawl_action = null;
};
} else {
if (path != null){
if (_sound_effect == null){
_sound_effect = AudioEngine.PlaySound("sfxAddWeb", AudioEngine.SFX_CHANNEL, false);
_sound_effect.SetPan(((2 * spider.x) - 1));
};
if (super.act(actor, time)){
path = null;
};
};
};
if ((((((path == null)) && ((_crawl_action == null)))) && (_edges.isEmpty()))){
_web.removePlannedStrand(_planned_web_strand);
endSound();
return (true);
};
return (false);
}
override public function cancel(){
_web.removePlannedStrand(_planned_web_strand);
}
public function endSound(){
if (_sound_effect != null){
_sound_effect.Stop();
_sound_effect = null;
};
}
}
}//package framework.Spider.Actions
Section 33
//AddStrandAction (framework.Spider.Actions.AddStrandAction)
package framework.Spider.Actions {
import framework.Spider.Web.*;
import game.*;
import framework.Geometry.*;
import audio.*;
import framework.Spider.Bugs.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
public class AddStrandAction extends CrawlerFlyAction {
public function AddStrandAction(target:WebNode){
super(target, false);
}
override public function pathAllowed(actor:Actor):Boolean{
var spider:Spider;
var sound_effect:SoundHandle;
if (!super.pathAllowed(actor)){
return (false);
};
spider = Spider(actor);
if (!hasWebbing(spider)){
spider.ui.warnWebbing();
sound_effect = AudioEngine.PlaySound("sfxNoWebbing", AudioEngine.SFX_CHANNEL, false);
sound_effect.SetPan(((2 * spider.x) - 1));
return (false);
};
return (true);
}
public function hasWebbing(spider:Spider):Boolean{
if (path == null){
return (true);
};
if (!spider.hasWebbing(path.getLength())){
return (false);
};
return (true);
}
override public function toString():String{
return (("AddStrandAction to " + _target_point));
}
override public function updatePath(web_crawler:WebCrawler, target_node:WebNode, target_edge:WebEdge):Boolean{
var success:Boolean;
success = super.updatePath(web_crawler, target_node, target_edge);
return (success);
}
override public function act(actor:Actor, time:Number):Boolean{
var spider:Spider;
var old_position:Point;
var finished:Boolean;
var distance:Number;
var new_edge:WebStrand;
var web_node:WebNode;
var n_e:WebEdge;
if (!(actor is Spider)){
throw (new Error(("Only Spiders can perform AddStrandAction, not " + actor)));
};
spider = Spider(actor);
if (path == null){
old_position = spider;
} else {
old_position = path.current_point;
};
if (path == null){
if (!updatePath(spider, _target_point)){
return (true);
};
};
finished = super.act(actor, time);
if (finished){
if (((((((spider.web.hasEdge(_start_edge)) || (spider.web.hasNode(_start_point)))) && (((spider.web.hasEdge(_target_edge)) || (spider.web.hasNode(_target_point)))))) && (!(path.start_point.equals(path.end_point))))){
new_edge = new WebStrand(WebNode(path.start_point), WebNode(path.end_point), spider.getWebStrength());
Swarm.prepare();
spider.web.addEdge(new_edge);
Swarm.collide();
web_node = WebNode(spider.web.getNode(WebNode(path.start_point)));
if (web_node){
web_node.collapse(spider.web);
};
web_node = WebNode(spider.web.getNode(WebNode(path.end_point)));
if (web_node){
web_node.collapse(spider.web);
};
n_e = spider.web.getEdge(new_edge);
if ((((n_e == null)) || (!(spider.intercepts(n_e))))){
trace(("!!! (ASA58) Incorrectly assinging spider's edge: " + n_e));
};
spider.edge = spider.web.getEdge(new_edge);
} else {
if ((((_target_edge == null)) || (!(spider.intercepts(_target_edge))))){
trace(("!!! (ASA66) Incorrectly assinging spider's edge: " + _target_edge));
};
spider.edge = _target_edge;
};
};
distance = old_position.getDistance(path.current_point);
if (!isNaN(distance)){
spider.useWebbing(distance);
};
return (finished);
}
override public function getClosestDirection(spider:WebCrawler):Array{
return (spider.web.getClosestDirection(spider, _target_point, false));
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
var spider:Spider;
var temp_strand:WebStrand;
if (path != null){
spider = Spider(actor);
super.updateGraphic(actor, level_data, time);
temp_strand = new WebStrand(new WebNode(path.start_point.x, path.start_point.y), new WebNode(path.current_point.x, path.current_point.y), spider.getWebStrength());
temp_strand.Draw(spider.web.drawer);
};
}
}
}//package framework.Spider.Actions
Section 34
//ApproachWebAction (framework.Spider.Actions.ApproachWebAction)
package framework.Spider.Actions {
import game.*;
import audio.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
public class ApproachWebAction extends Action {
private var _current_time:Number;
private var _approach_time:Number;
public function ApproachWebAction(approach_time:Number){
super();
_approach_time = approach_time;
_current_time = _approach_time;
}
override public function act(actor:Actor, time:Number):Boolean{
var catchable:Catchable;
var distance:*;
var volume:Number;
if (!(actor is Catchable)){
throw (new Error(("Only Catchables can perform ApproachWebActions, not " + actor)));
};
catchable = Catchable(actor);
if (((!((catchable.approach_sound_name == null))) && ((catchable.approach_sound == null)))){
catchable.approach_sound = AudioEngine.PlaySound(catchable.approach_sound_name, AudioEngine.SFX_CHANNEL, false);
catchable.approach_sound.SetVolume(0);
};
if (((((!(isNaN(catchable.hover_distance))) && (!(catchable.hover_finished)))) && (!(catchable.hovering)))){
distance = ((_approach_time - _current_time) / _approach_time);
if (distance >= catchable.hover_distance){
catchable.startHover();
};
};
if (catchable.hovering){
if (!catchable.hover_moving){
catchable.hover_time = (catchable.hover_time - time);
if (catchable.hover_time < 0){
catchable.hover_time = 0;
};
if (catchable.hover_time == 0){
catchable.updateHover();
};
} else {
catchable.position.x = (catchable.position.x + (catchable.hover_x_speed * time));
catchable.position.y = (catchable.position.y + (catchable.hover_y_speed * time));
if ((((((catchable.hover_x_direction == 1)) && ((catchable.position.x > catchable.hover_target_point.x)))) || ((((catchable.hover_x_direction == -1)) && ((catchable.position.x < catchable.hover_target_point.x)))))){
catchable.position.x = catchable.hover_target_point.x;
catchable.position.y = catchable.hover_target_point.y;
catchable.hover_moving = false;
catchable.playHoverSound();
};
};
} else {
_current_time = (_current_time - time);
if (_current_time < 0){
_current_time = 0;
};
if (catchable.approach_sound != null){
volume = ((_approach_time - _current_time) / _approach_time);
catchable.approach_sound.SetVolume(volume);
};
if (_current_time == 0){
catchable.collide();
} else {
return (false);
};
};
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
var catchable:*;
var factor:Number;
var factor_squared:Number;
if (!(actor is Catchable)){
return;
};
catchable = Catchable(actor);
if (((!(catchable.hovering)) || (catchable.hover_moving))){
factor = ((_approach_time - _current_time) / _approach_time);
factor_squared = (factor * factor);
catchable.updateGraphic(level_data, factor_squared, time);
};
}
public function toString():String{
return ("approach");
}
}
}//package framework.Spider.Actions
Section 35
//CatchableDieAction (framework.Spider.Actions.CatchableDieAction)
package framework.Spider.Actions {
import framework.Spider.Web.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
public class CatchableDieAction extends Action {
private var _web:Web;
public function CatchableDieAction(web:Web){
super();
_web = web;
}
override public function act(actor:Actor, time:Number):Boolean{
var catchable:Catchable;
if (!(actor is Catchable)){
throw (new Error(("Only Catchables can perform CatchableDieActions, not " + actor)));
};
catchable = Catchable(actor);
_web.deleteCatchable(catchable);
catchable.destroy();
catchable.removeGraphic();
catchable.graphic = null;
return (true);
}
public function toString():String{
return ("Die!");
}
}
}//package framework.Spider.Actions
Section 36
//CrawlAction (framework.Spider.Actions.CrawlAction)
package framework.Spider.Actions {
import framework.Spider.Web.*;
import game.*;
import audio.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
import framework.Utilities.*;
import framework.GeometryGraph.*;
public class CrawlAction extends Action {
private var _sound_effect:SoundHandle;
private var _path:Path;
private var _target_point:WebNode;
private var _seen_edges:HashTable;
private var _started:Boolean;// = false
public function CrawlAction(target:WebNode){
_started = false;
super();
_target_point = target;
_path = null;
_seen_edges = new HashTable();
}
public function toString():String{
return (((("Crawling: " + _target_point) + ": ") + _path));
}
public function updatePath(web_crawler:WebCrawler){
_path = web_crawler.web.findPath(web_crawler, _target_point);
}
override public function act(actor:Actor, time:Number):Boolean{
var web_crawler:WebCrawler;
var distance:Number;
var new_node:GeoNode;
var old_edge:GeoEdge;
var current_edge:*;
var p_ce:WebEdge;
var closest:Array;
var c_e:WebEdge;
if (!(actor is WebCrawler)){
throw (new Error(("Only WebCrawlers can perform CrawlAction, not " + actor)));
};
web_crawler = WebCrawler(actor);
distance = (web_crawler.speed * time);
if (!_started){
_started = true;
};
web_crawler.updateAnimation("crawling");
if (_path == null){
updatePath(web_crawler);
if (_path.getLength() == 0){
endAction(web_crawler);
return (true);
};
_sound_effect = AudioEngine.PlaySound("sfxSpiderMove", AudioEngine.SFX_CHANNEL, false);
_sound_effect.SetPan(((2 * web_crawler.x) - 1));
};
old_edge = web_crawler.edge;
while (1) {
new_node = _path.travel(distance, web_crawler.web);
if (new_node == null){
updatePath(web_crawler);
if (_path.getLength() == 0){
return (true);
};
} else {
break;
};
};
web_crawler.x = new_node.x;
web_crawler.y = new_node.y;
_sound_effect.SetPan(((2 * web_crawler.x) - 1));
current_edge = _path.getCurrentEdge();
if (((!((current_edge == null))) && (!(_seen_edges.hasKey(current_edge.getKey()))))){
if (web_crawler.web.hasEdge(_path.getCurrentEdge())){
p_ce = web_crawler.web.getEdge(_path.getCurrentEdge());
if ((((p_ce == null)) || (!(web_crawler.intercepts(p_ce))))){
trace(("!!! (CA86) Incorrectly assinging spider's edge: " + p_ce));
};
web_crawler.edge = web_crawler.web.getEdge(_path.getCurrentEdge());
} else {
if (((_path.isLastEdge()) && (!(_path.isFirstEdge())))){
closest = web_crawler.web.getClosest(_target_point, true);
c_e = web_crawler.web.getEdge(closest[0]);
if ((((c_e == null)) || (!(web_crawler.intercepts(c_e))))){
trace(("!!! (CA96) Incorrectly assinging spider's edge: " + c_e));
};
web_crawler.edge = web_crawler.web.getEdge(closest[0]);
} else {
closest = web_crawler.web.getClosest(web_crawler, true);
c_e = web_crawler.web.getEdge(closest[0]);
if ((((c_e == null)) || (!(web_crawler.intercepts(c_e))))){
trace(("!!! (CA103) Incorrectly assinging spider's edge: " + c_e));
};
web_crawler.edge = web_crawler.web.getEdge(closest[0]);
};
};
_seen_edges.setValue(current_edge.getKey(), current_edge);
};
if (new_node.equals(_path.end_point)){
endAction(web_crawler);
return (true);
};
return (false);
}
public function endAction(actor:WebCrawler){
actor.updateAnimation("resting");
if (_sound_effect != null){
_sound_effect.Stop();
_sound_effect = null;
};
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
var web_crawler:WebCrawler;
if ((actor is WebCrawler)){
web_crawler = WebCrawler(actor);
if (_path != null){
web_crawler.rotateTowards(_path.next_point, time);
};
};
}
}
}//package framework.Spider.Actions
Section 37
//CrawlerFlyAction (framework.Spider.Actions.CrawlerFlyAction)
package framework.Spider.Actions {
import framework.Spider.Web.*;
import game.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
import framework.GeometryGraph.*;
public class CrawlerFlyAction extends Action {
public var path:Path;
private var _started:Boolean;// = false
private var _latch:Boolean;
public var _target_point:WebNode;
protected var _target_edge:WebEdge;
protected var _start_edge:WebEdge;
protected var _start_point:WebNode;
public function CrawlerFlyAction(target_point:WebNode, latch:Boolean){
_started = false;
super();
path = null;
_latch = latch;
_start_edge = null;
_start_point = null;
_target_edge = null;
_target_point = target_point;
}
public function toString():String{
return ("Free flyin' action");
}
public function pathAllowed(actor:Actor):Boolean{
var web_crawler:WebCrawler;
var node:WebNode;
var edges:Array;
var edge:WebEdge;
var i:*;
web_crawler = WebCrawler(actor);
if (web_crawler.onEdge(_target_edge)){
return (false);
};
if (web_crawler.web.hasNode(web_crawler)){
node = WebNode(web_crawler.web.getNode(web_crawler));
edges = node.getEdges();
i = 0;
while (i < edges.length) {
edge = edges[i];
if (edge.getOtherPoint(node).equals(path.end_point)){
if ((((edge == null)) || (!(web_crawler.intercepts(edge))))){
trace(("!!! (CFA118) Incorrectly assinging spider's edge: " + edge));
};
web_crawler.edge = edge;
return (false);
};
i++;
};
} else {
if (((((!((web_crawler.edge == null))) && (((path.end_point.equals(web_crawler.edge.p1)) || (path.end_point.equals(web_crawler.edge.p2)))))) && (web_crawler.web.hasEdge(web_crawler.edge)))){
return (false);
};
};
return (true);
}
public function updatePath(web_crawler:WebCrawler, target_node:WebNode, target_edge:WebEdge):Boolean{
var start_node:WebNode;
var new_edge:WebEdge;
var distance_p1:Number;
var distance_p2:Number;
var closest:*;
if (((!((target_edge == null))) && (!(web_crawler.web.hasEdge(target_edge))))){
return (false);
};
if (web_crawler.edge != null){
distance_p1 = web_crawler.getDistanceSquared(web_crawler.edge.p1);
distance_p2 = web_crawler.getDistanceSquared(web_crawler.edge.p2);
if (distance_p1 < 0.001){
if (distance_p2 < distance_p1){
web_crawler.x = web_crawler.edge.p2.x;
web_crawler.y = web_crawler.edge.p2.y;
} else {
web_crawler.x = web_crawler.edge.p1.x;
web_crawler.y = web_crawler.edge.p1.y;
};
} else {
if (distance_p2 < 0.001){
web_crawler.x = web_crawler.edge.p2.x;
web_crawler.y = web_crawler.edge.p2.y;
};
};
};
_start_edge = web_crawler.edge;
_start_point = new WebNode(web_crawler.x, web_crawler.y);
if ((((target_edge == null)) || (!(target_edge.intercepts(target_node))))){
closest = getClosestDirection(web_crawler);
if ((((((closest == null)) || ((closest[0] == null)))) || ((closest[1] == null)))){
trace((((" !! Could not find closest from " + web_crawler) + " to ") + _target_point));
return (false);
};
target_edge = closest[0];
target_node = closest[1];
};
if (target_node.equals(_start_point)){
return (false);
};
_target_edge = target_edge;
if (target_node.getDistanceSquared(_target_edge.p1) < 0.001){
_target_point = WebNode(_target_edge.p1);
} else {
if (target_node.getDistanceSquared(_target_edge.p2) < 0.001){
_target_point = WebNode(_target_edge.p2);
} else {
_target_point = target_node;
};
};
start_node = new WebNode(web_crawler.x, web_crawler.y);
path = new Path(start_node);
new_edge = new WebEdge(start_node, _target_point);
path.addEdge(new_edge);
if (!pathAllowed(web_crawler)){
return (false);
};
if (_latch){
if ((((_target_edge == null)) || (!(web_crawler.intercepts(_target_edge))))){
trace(("!!! (CFA215) Incorrectly assinging spider's edge: " + _target_edge));
};
web_crawler.edge = _target_edge;
};
return (true);
}
override public function act(actor:Actor, time:Number):Boolean{
var web_crawler:WebCrawler;
var distance:Number;
var new_node:GeoNode;
if (!(actor is WebCrawler)){
throw (new Error(("Only WebCrawlers can perform CrawlerFlyAction, not " + actor)));
};
web_crawler = WebCrawler(actor);
distance = (web_crawler.speed * time);
if (!_started){
_started = true;
};
web_crawler.updateAnimation("flying");
if (path == null){
if (!updatePath(web_crawler, _target_point, null)){
trace(((("!!! Unable to find path from " + web_crawler) + " towards ") + _target_point));
_started = false;
web_crawler.updateAnimation("resting");
return (true);
};
};
new_node = path.travel(distance, web_crawler.web);
web_crawler.x = new_node.x;
web_crawler.y = new_node.y;
if (new_node.equals(path.end_point)){
if ((((_target_edge == null)) || (!(web_crawler.intercepts(_target_edge))))){
trace(("!!! (CFA68) Incorrectly assinging spider's edge: " + _target_edge));
};
web_crawler.edge = _target_edge;
web_crawler.updateAnimation("resting");
_started = false;
return (true);
//unresolved jump
};
return (false);
}
public function getClosestDirection(web_crawler:WebCrawler):Array{
var closest:Array;
var distance:Number;
closest = web_crawler.web.getClosestDirection(web_crawler, _target_point, false);
if (((!((closest[0] == null))) && (!((closest[1] == null))))){
distance = closest[1].getDistance(closest[0].p1);
if (distance < 0.001){
closest = [closest[0], closest[0].p1, distance];
} else {
distance = closest[1].getDistance(closest[0].p2);
if (distance < 0.001){
closest = [closest[0], closest[0].p2, distance];
};
};
};
return (closest);
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
var web_crawler:WebCrawler;
if ((actor is WebCrawler)){
web_crawler = WebCrawler(actor);
web_crawler.rotateTowards(path.next_point, time);
};
}
}
}//package framework.Spider.Actions
Section 38
//EatAction (framework.Spider.Actions.EatAction)
package framework.Spider.Actions {
import game.*;
import audio.*;
import framework.Spider.Bugs.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
public class EatAction extends Action {
private var _sound_effect:SoundHandle;
private var _started:Boolean;
private var _food:Edible;
public function EatAction(food:Edible){
var prey:Prey;
super();
_food = food;
_started = false;
if ((_food is Prey)){
prey = Prey(_food);
prey.attachMarkedGraphic();
};
}
override public function cancel(){
if ((_food is Prey)){
Prey(_food).removeMarkedGraphic();
};
if (_sound_effect != null){
_sound_effect.Stop();
_sound_effect = null;
};
}
public function toString():String{
return ("Eating");
}
override public function act(actor:Actor, time:Number):Boolean{
var spider:*;
var finished:Boolean;
if (!(actor is Spider)){
throw (new Error(("Only Spiders can perform EatActions, not " + actor)));
};
spider = Spider(actor);
if (!_started){
_started = true;
_sound_effect = AudioEngine.PlaySound("sfxEatLoop", AudioEngine.SFX_CHANNEL, true);
_sound_effect.SetPan(((2 * spider.x) - 1));
};
spider.updateAnimation("eating");
finished = _food.eat(spider, time);
if (finished){
spider.updateAnimation("resting");
_sound_effect.Stop();
_sound_effect = null;
};
return (finished);
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
var spider:Spider;
if ((actor is Spider)){
spider = Spider(actor);
if ((_food is Prey)){
spider.rotateTowards(Prey(_food).position, time);
};
};
}
}
}//package framework.Spider.Actions
Section 39
//LeaveWebAction (framework.Spider.Actions.LeaveWebAction)
package framework.Spider.Actions {
import game.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
public class LeaveWebAction extends Action {
private var _leave_time:Number;
private var _current_time:Number;
public function LeaveWebAction(leave_time:Number){
super();
_leave_time = leave_time;
_current_time = 0;
}
override public function act(actor:Actor, time:Number):Boolean{
if (!(actor is Catchable)){
throw (new Error(("Only Catchables can perform LeaveWebActions, not " + actor)));
};
_current_time = (_current_time + time);
return (false);
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
var catchable:*;
var factor:Number;
var factor_squared:Number;
if (!(actor is Catchable)){
return;
};
catchable = Catchable(actor);
factor = ((_leave_time + _current_time) / _leave_time);
factor_squared = (factor * factor);
catchable.updateGraphic(level_data, factor_squared, time);
}
public function toString():String{
return ("leave");
}
}
}//package framework.Spider.Actions
Section 40
//StruggleAction (framework.Spider.Actions.StruggleAction)
package framework.Spider.Actions {
import framework.Spider.Web.*;
import game.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
public class StruggleAction extends Action {
private var _web:Web;
public function StruggleAction(web:Web){
super();
_web = web;
}
override public function act(actor:Actor, time:Number):Boolean{
var catchable:Catchable;
if ((actor is Catchable)){
catchable = Catchable(actor);
if (catchable.approach_sound != null){
catchable.approach_sound.Stop();
};
};
return (false);
}
override public function updateGraphic(actor:Actor, level_data:LevelData, time:Number){
}
}
}//package framework.Spider.Actions
Section 41
//Bat (framework.Spider.Bugs.Bat)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
import flash.geom.*;
public class Bat extends Prey {
public static var strength_current:Number = 0;
public static var strength_max:Number = 100;
public function Bat(x:Number, y:Number, web1:Web){
var percent_strength:Number;
super(x, y, web1);
approach_time = 1;
_scatter = 0.075;
tilt = 25;
_edges = undefined;
_bites = 5;
_body_radius = 0.1;
_energy = 35;
_points = 2500;
_webbing = 3;
_wraps = 2;
tutorial_id = "bat";
graphic = new BatGraphic();
_marked_graphic_type = "large";
generalInitialize(x, y, web1);
if (strength_current <= 0){
resetMaintainedStrength();
};
_strength = strength_current;
percent_strength = (strength_current / strength_max);
updateLifeOverlay(percent_strength);
approach_sound_name = "sfxBatApproach";
}
public function updateLifeOverlay(percent_strength:Number){
var transformer:ColorTransform;
transformer = graphic.transform.colorTransform;
transformer.greenMultiplier = percent_strength;
transformer.blueMultiplier = percent_strength;
graphic.transform.colorTransform = transformer;
}
override public function updateMaintainedStrength(value:Number){
strength_current = value;
}
public function toString():String{
return (("Bat at " + position));
}
override public function resetMaintainedStrength(){
strength_current = strength_max;
}
override public function finishEating(eater:Spider){
eater.web.game.turnOnTutorials();
eater.web.game.displayTutorial("eat_bat");
}
}
}//package framework.Spider.Bugs
Section 42
//Bee (framework.Spider.Bugs.Bee)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class Bee extends Prey {
public function Bee(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 2.25;
tilt = 10;
_edges = undefined;
_strength = 3.5;
_bites = 0.75;
_body_radius = 0.02;
_energy = -2;
_points = 25;
_webbing = 0.1;
_wraps = 1;
tutorial_id = "bee";
graphic = new BeeGraphic();
generalInitialize(x, y, web1);
approach_sound_name = "sfxBeeApproach";
}
}
}//package framework.Spider.Bugs
Section 43
//ButterFly (framework.Spider.Bugs.ButterFly)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class ButterFly extends Prey {
public function ButterFly(x:Number, y:Number, web1:Web){
var bucket:Number;
super(x, y, web1);
approach_time = 4;
_edges = undefined;
_strength = 5.5;
_bites = 5;
_body_radius = 0.05;
_energy = 35;
_points = 300;
_webbing = 3;
_wraps = 2;
tutorial_id = "butterfly";
bucket = Math.random();
if (bucket < 0.333){
graphic = new ButterflyGraphic();
} else {
if (bucket < 0.666){
graphic = new ButterflyGraphic2();
} else {
if (bucket <= 1){
graphic = new ButterflyGraphic3();
};
};
};
_marked_graphic_type = "large";
generalInitialize(x, y, web1);
}
public function toString():String{
return (("ButterFly at " + position));
}
}
}//package framework.Spider.Bugs
Section 44
//DragonFly (framework.Spider.Bugs.DragonFly)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class DragonFly extends Prey {
public function DragonFly(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 1.2;
_edges = undefined;
_strength = 4.5;
_bites = 0.5;
_body_radius = 0.05;
_energy = 10;
_points = 30;
_webbing = 0.2;
_wraps = 2;
tutorial_id = "dragonfly";
graphic = new DragonflyGraphic();
_marked_graphic_type = "medium";
generalInitialize(x, y, web1);
approach_sound_name = "sfxDragonflyApproach";
}
public function toString():String{
return (("DragonFly at " + position));
}
override public function finishEating(eater:Spider){
eater.setBonusSpeedFull();
}
}
}//package framework.Spider.Bugs
Section 45
//FireFly (framework.Spider.Bugs.FireFly)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class FireFly extends Prey {
public function FireFly(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 2;
_edges = undefined;
_strength = 0.25;
_bites = 0.5;
_body_radius = 0.015;
_energy = 5;
_points = 50;
_webbing = 0.25;
_wraps = 1;
tutorial_id = "fire_fly";
graphic = new FireFlyGraphic();
generalInitialize(x, y, web1);
_cache_on_catch = false;
approach_sound_name = "sfxFlyApproach1";
}
override public function specialDestroy(){
web.removeFireFly(this);
}
public function toString():String{
return (("FireFly at " + position));
}
override public function specialCatch(){
web.addFireFly(this);
}
}
}//package framework.Spider.Bugs
Section 46
//Fly (framework.Spider.Bugs.Fly)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class Fly extends Prey {
public function Fly(x:Number, y:Number, web1:Web){
var rand:Number;
super(x, y, web1);
approach_time = 2;
tilt = 10;
_edges = undefined;
_strength = 0.35;
_bites = 0.5;
_body_radius = 0.015;
_energy = 5;
_points = 5;
_webbing = 0.25;
_wraps = 1;
tutorial_id = "fly";
graphic = new FlyGraphic();
generalInitialize(x, y, web1);
rand = Math.random();
if (rand <= 0.15){
approach_sound_name = "sfxFlyApproach1";
} else {
if (rand <= 0.3){
approach_sound_name = "sfxFlyApproach2";
} else {
if (rand <= 0.45){
approach_sound_name = "sfxFlyApproach3";
};
};
};
}
}
}//package framework.Spider.Bugs
Section 47
//HummingBird (framework.Spider.Bugs.HummingBird)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class HummingBird extends Prey {
public function HummingBird(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 1;
_edges = undefined;
_strength = 13.5;
_bites = 2.5;
_body_radius = 0.075;
_energy = 15;
_points = 500;
_webbing = 0.2;
_wraps = 2;
tutorial_id = "hummingbird";
graphic = new HummingBirdGraphic();
_marked_graphic_type = "large";
hover_distance = 0.8;
hover_duration = 1.75;
hover_probability = 0.4;
generalInitialize(x, y, web1);
approach_sound_name = "sfxHummingbirdHover";
hover_sound_name = "sfxHummingbirdHover";
}
public function toString():String{
return (("HummingBird at " + position));
}
}
}//package framework.Spider.Bugs
Section 48
//LadyBug (framework.Spider.Bugs.LadyBug)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class LadyBug extends Prey {
public function LadyBug(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 3.5;
_edges = undefined;
_strength = 0.8;
_bites = 1;
_body_radius = 0.025;
_energy = 10;
_points = 15;
_webbing = 0.15;
_wraps = 3;
tutorial_id = "ladybug";
graphic = new LadyBugGraphic();
_marked_graphic_type = "medium";
generalInitialize(x, y, web1);
}
}
}//package framework.Spider.Bugs
Section 49
//Moth (framework.Spider.Bugs.Moth)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class Moth extends Prey {
public function Moth(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 2.25;
tilt = 20;
_edges = undefined;
_strength = 2;
_bites = 0.5;
_body_radius = 0.03;
_energy = 2.5;
_points = 15;
_scatter = 0.05;
_webbing = 0.5;
_wraps = 2;
tutorial_id = "moth";
graphic = new MothGraphic();
_marked_graphic_type = "medium";
generalInitialize(x, y, web1);
}
public function toString():String{
return (("Moth at " + position));
}
}
}//package framework.Spider.Bugs
Section 50
//Prey (framework.Spider.Bugs.Prey)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import game.*;
import framework.Spider.Abstract.*;
import framework.Spider.Actions.*;
public class Prey extends Catchable implements Edible {
protected var _bites_remaining:Number;
protected var _points:Number;// = 0
protected var _plus_webbing_target:Number;// = 0
protected var _health_remaining:Number;
protected var _plus_points_target:Number;// = 0
protected var _wraps_remaining:Number;
protected var _wraps:Number;// = 0
protected var _webbing:Number;// = 0
protected var _bites:Number;// = 0
protected var _minus_health_target:Number;// = 0
protected var _webbing_remaining:Number;
protected var _plus_health_target:Number;// = 0
protected var _energy:Number;// = 0
protected var _points_remaining:Number;
protected static var _plus_points_increment:Number = 4.95;
protected static var _plus_health_increment:Number = 3;
protected static var _minus_health_increment:Number = -1.5;
protected static var _plus_webbing_increment:Number = 0.2;
public function Prey(x:Number, y:Number, web1:Web){
_bites = 0;
_energy = 0;
_points = 0;
_webbing = 0;
_wraps = 0;
_plus_webbing_target = 0;
_plus_health_target = 0;
_minus_health_target = 0;
_plus_points_target = 0;
super(x, y, web1);
}
public function updatePoints(eater:Spider, ratio:Number){
_points_remaining = (_points_remaining - (_points * ratio));
if (_points_remaining <= _plus_points_target){
eater.displayPlusPoints();
_plus_points_target = (_plus_points_target - _plus_points_increment);
};
}
public function finishEating(eater:Spider){
}
public function (wrapper:Spider, time:Number){
var wraps:*;
wraps = (wrapper.wrap_rate * time);
if (wraps > _wraps_remaining){
wraps = _wraps_remaining;
};
_wraps_remaining = (_wraps_remaining - wraps);
if (_wraps_remaining == 0){
return (true);
};
return (false);
}
public function eat(eater:Spider, time:Number):Boolean{
var bites:*;
var ratio:Number;
if (((!(eater.web.hasCatchable(this))) || (!(eater.intercepts(body))))){
removeMarkedGraphic();
return (true);
};
bites = (eater.bite_rate * time);
if (bites > _bites_remaining){
bites = _bites_remaining;
};
_bites_remaining = (_bites_remaining - bites);
ratio = (bites / _bites);
eater.addWebbing((_webbing * ratio));
updateWebbing(eater, ratio);
eater.addEnergy((_energy * ratio));
updateHealth(eater, ratio);
Game.AwardPoints((_points * ratio));
updatePoints(eater, ratio);
if (_bites_remaining == 0){
finishEating(eater);
addAction(new CatchableDieAction(web));
eater.increaseEatCount(tutorial_id);
return (true);
};
return (false);
}
public function updateWebbing(eater:Spider, ratio:Number){
_webbing_remaining = (_webbing_remaining - (_webbing * ratio));
if (_webbing_remaining <= _plus_webbing_target){
eater.displayPlusWebbing();
_plus_webbing_target = (_plus_webbing_target - _plus_webbing_increment);
};
}
public function updateHealth(eater:Spider, ratio:Number){
_health_remaining = (_health_remaining - (_energy * ratio));
if (_health_remaining <= _plus_health_target){
eater.displayPlusHealth();
_plus_health_target = (_plus_health_target - _plus_health_increment);
};
if (_health_remaining >= _minus_health_target){
eater.displayMinusHealth();
_minus_health_target = (_minus_health_target - _minus_health_increment);
};
}
override public function generalInitialize(x:Number, y:Number, web1:Web){
super.generalInitialize(x, y, web1);
_bites_remaining = _bites;
_wraps_remaining = _wraps;
_webbing_remaining = _webbing;
_plus_webbing_target = (_webbing - _plus_webbing_increment);
_health_remaining = _energy;
_plus_health_target = (_energy - _plus_health_increment);
_minus_health_target = (_energy - _minus_health_increment);
_points_remaining = _points;
_plus_points_target = (_points - _plus_points_increment);
}
}
}//package framework.Spider.Bugs
Section 51
//QueenBee (framework.Spider.Bugs.QueenBee)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class QueenBee extends Prey {
public function QueenBee(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 3;
_edges = undefined;
_strength = 2.7;
_bites = 2.5;
_body_radius = 0.037;
_energy = -5;
_points = 25;
_webbing = 0.1;
_wraps = 2.5;
tutorial_id = "queen_bee";
graphic = new QueenBeeGraphic();
_marked_graphic_type = "medium";
generalInitialize(x, y, web1);
_cache_on_catch = false;
approach_sound_name = "sfxBeeApproach";
}
override public function specialDestroy(){
web.removeQueenBee(this);
}
override public function specialCatch(){
web.addQueenBee(this);
}
}
}//package framework.Spider.Bugs
Section 52
//Spider (framework.Spider.Bugs.Spider)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import game.*;
import flash.display.*;
import audio.*;
import framework.Spider.Abstract.*;
import framework.Utilities.*;
import framework.Spider.UI.*;
import framework.Spider.Graphics.*;
import flash.geom.*;
public class Spider extends WebCrawler {
public var warning_energy_time:Number;
public var bonus_speed:Number;
public var energy_max:Number;
public var webbing_max:Number;
public var warning_sound_handle:SoundHandle;
public var minus_health_graphics:HashTable;
public var bonus_speed_max:Number;
public var base_speed:Number;
public var bonus_speed_graphic1:MovieClip;
public var bonus_speed_graphic2:MovieClip;
public var plus_health_graphics:HashTable;
public var eat_count:HashTable;
public var warning_energy:Number;
public var energy:Number;
public var bonus_web_strength_max:Number;
public var webbing:Number;
public var ui:SpiderUI;
public var webstrength:Number;
public var wrap_rate:Number;
public var bite_rate:Number;
public var plus_points_graphics:HashTable;
public var plus_webbing_graphics:HashTable;
public var warning_currently:Boolean;
public var bonus_speed_time:Number;
public var bonus_web_strength:Number;
public function Spider(x1:Number, y1:Number, aweb:Web, game:Game){
plus_webbing_graphics = new HashTable();
plus_health_graphics = new HashTable();
minus_health_graphics = new HashTable();
plus_points_graphics = new HashTable();
super(x1, y1, aweb);
base_speed = 1;
bonus_speed = 1.5;
speed = base_speed;
bite_rate = base_speed;
bonus_web_strength = 0;
bonus_web_strength_max = 10;
bonus_speed_time = 0;
bonus_speed_max = 8;
energy_max = 30;
energy = energy_max;
warning_energy = 8;
warning_currently = false;
webstrength = 1;
webbing_max = 3;
webbing = webbing_max;
eat_count = new HashTable();
wrap_rate = 1;
graphic = new SpiderGraphic();
bonus_speed_graphic1 = new SpiderGraphic();
bonus_speed_graphic2 = new SpiderGraphic();
hideBonusSpeedGraphics();
}
public function fixEnergy(){
if (energy > energy_max){
energy = energy_max;
} else {
if (energy < 0){
energy = 0;
};
};
}
public function hideBonusSpeedGraphics(){
bonus_speed_graphic1.alpha = 0;
bonus_speed_graphic2.alpha = 0;
}
public function useWebbing(amount:Number){
webbing = (webbing - amount);
fixWebbing();
}
public function loseEnergy(amount:Number){
energy = (energy - amount);
fixEnergy();
}
public function setBonusSpeedFull(){
setBonusSpeed(bonus_speed_max);
speed = bonus_speed;
bite_rate = bonus_speed;
showBonusSpeedGraphics();
}
public function removePlusHealth(plus_health_graphic:PlusHealthGraphic){
plus_health_graphics.deleteKey(plus_health_graphic.id);
web.after_web.removeChild(plus_health_graphic);
}
public function removeGraphics(anchor:MovieClip){
anchor.removeChild(graphic);
anchor.removeChild(bonus_speed_graphic1);
anchor.removeChild(bonus_speed_graphic2);
}
public function fixBonusWebStrength(){
if (bonus_web_strength > bonus_web_strength_max){
bonus_web_strength = bonus_web_strength_max;
} else {
if (bonus_web_strength < 0){
bonus_web_strength = 0;
};
};
}
public function addGraphics(anchor:MovieClip){
anchor.addChild(bonus_speed_graphic2);
anchor.addChild(bonus_speed_graphic1);
anchor.addChild(graphic);
}
public function endWarningSound(){
if (warning_sound_handle != null){
warning_sound_handle.Stop();
warning_sound_handle = null;
};
}
public function setBonusWebStrengthFull(){
setBonusWebStrength(bonus_web_strength_max);
}
public function loseBonusWebStrength(amount:Number){
bonus_web_strength = (bonus_web_strength - amount);
fixBonusWebStrength();
}
public function fixBonusSpeed(){
if (bonus_speed_time > bonus_speed_max){
bonus_speed_time = bonus_web_speed_max;
} else {
if (bonus_speed_time < 0){
bonus_speed_time = 0;
};
};
}
public function setBonusSpeed(amount:Number){
bonus_speed_time = amount;
}
public function loseBonusSpeed(amount:Number){
bonus_speed_time = (bonus_speed_time - amount);
fixBonusSpeed();
if (bonus_speed_time == 0){
speed = base_speed;
bite_rate = base_speed;
hideBonusSpeedGraphics();
};
}
public function removePlusWebbing(plus_webbing_graphic:PlusWebbingGraphic){
plus_webbing_graphics.deleteKey(plus_webbing_graphic.id);
web.after_web.removeChild(plus_webbing_graphic);
}
override public function updateGraphicRotation(angle:Number){
bonus_speed_graphic2.rotation = bonus_speed_graphic1.rotation;
bonus_speed_graphic1.rotation = graphic.rotation;
super.updateGraphicRotation(angle);
}
public function displayPlusPoints(){
var plus_points_graphic:PlusPointsGraphic;
plus_points_graphic = new PlusPointsGraphic(this);
plus_points_graphics.setValue(plus_points_graphic.id, plus_points_graphic);
web.after_web.addChild(plus_points_graphic);
}
public function getWebStrength():Number{
return ((webstrength + (bonus_web_strength / bonus_web_strength_max)));
}
public function displayPlusWebbing(){
var plus_webbing_graphic:PlusWebbingGraphic;
plus_webbing_graphic = new PlusWebbingGraphic(this);
plus_webbing_graphics.setValue(plus_webbing_graphic.id, plus_webbing_graphic);
web.after_web.addChild(plus_webbing_graphic);
}
public function addEnergy(amount:Number){
energy = (energy + amount);
fixEnergy();
}
private function setBlinking(percent:Number){
var transformer:ColorTransform;
transformer = graphic.transform.colorTransform;
transformer.greenMultiplier = percent;
transformer.blueMultiplier = percent;
graphic.transform.colorTransform = transformer;
if (warning_sound_handle != null){
warning_sound_handle.SetPan(((2 * x) - 1));
};
}
public function hasWebbing(amount:Number):Boolean{
return ((webbing >= amount));
}
public function setBonusWebStrength(amount:Number){
bonus_web_strength = amount;
}
public function addWebbing(amount:Number){
webbing = (webbing + amount);
fixWebbing();
}
override public function updateAnimation(new_animation:String){
if (animation != new_animation){
bonus_speed_graphic1.gotoAndPlay(new_animation);
bonus_speed_graphic2.gotoAndPlay(new_animation);
};
super.updateAnimation(new_animation);
}
public function removePlusPoints(plus_points_graphic:PlusPointsGraphic){
plus_points_graphics.deleteKey(plus_points_graphic.id);
web.after_web.removeChild(plus_points_graphic);
}
public function removeMinusHealth(minus_health_graphic:MinusHealthGraphic){
minus_health_graphics.deleteKey(minus_health_graphic.id);
web.after_web.removeChild(minus_health_graphic);
}
public function fixWebbing(){
if (webbing > webbing_max){
webbing = webbing_max;
} else {
if (webbing < 0){
webbing = 0;
};
};
}
public function displayMinusHealth(){
var minus_health_graphic:MinusHealthGraphic;
minus_health_graphic = new MinusHealthGraphic(this);
minus_health_graphics.setValue(minus_health_graphic.id, minus_health_graphic);
web.after_web.addChild(minus_health_graphic);
}
override public function updateGraphic(level_data:LevelData, time:Number){
var graphics:Array;
var i:Number;
var multiplier:Number;
bonus_speed_graphic2.x = bonus_speed_graphic1.x;
bonus_speed_graphic2.y = bonus_speed_graphic1.y;
bonus_speed_graphic1.x = graphic.x;
bonus_speed_graphic1.y = graphic.y;
super.updateGraphic(level_data, time);
if (ui.spider_webbing_warning != null){
ui.spider_webbing_warning.x = level_data.convertX(x);
ui.spider_webbing_warning.y = level_data.convertY(y);
};
if (((!(warning_currently)) && ((energy <= warning_energy)))){
warning_currently = true;
warning_energy_time = 0;
warning_sound_handle = AudioEngine.PlaySound("sfxLowHealthLoop", AudioEngine.SFX_CHANNEL, true);
} else {
if (warning_currently){
if (energy > (warning_energy + 2)){
setBlinking(1);
warning_currently = false;
endWarningSound();
} else {
warning_energy_time = (warning_energy_time + (time * 6));
};
};
};
if (warning_currently){
multiplier = (Math.sin(warning_energy_time) + (1 / 2));
if (multiplier > 1){
multiplier = 1;
};
setBlinking(multiplier);
};
graphics = plus_webbing_graphics.getValues();
i = 0;
while (i < graphics.length) {
PlusWebbingGraphic(graphics[i]).update(time);
i++;
};
graphics = plus_health_graphics.getValues();
i = 0;
while (i < graphics.length) {
PlusHealthGraphic(graphics[i]).update(time);
i++;
};
graphics = minus_health_graphics.getValues();
i = 0;
while (i < graphics.length) {
MinusHealthGraphic(graphics[i]).update(time);
i++;
};
graphics = plus_points_graphics.getValues();
i = 0;
while (i < graphics.length) {
PlusPointsGraphic(graphics[i]).update(time);
i++;
};
}
public function displayPlusHealth(){
var plus_health_graphic:PlusHealthGraphic;
plus_health_graphic = new PlusHealthGraphic(this);
plus_health_graphics.setValue(plus_health_graphic.id, plus_health_graphic);
web.after_web.addChild(plus_health_graphic);
}
public function increaseEatCount(food_type:String){
var new_value:Number;
if (eat_count.hasKey(food_type)){
new_value = (Number(eat_count.getValue(food_type)) + 1);
} else {
new_value = 1;
};
eat_count.setValue(food_type, new_value);
if ((((food_type == "fly")) && ((new_value == 25)))){
web.game.awardAchievement(4);
} else {
if ((((food_type == "fire_fly")) && ((new_value == 10)))){
web.game.awardAchievement(5);
} else {
if ((((food_type == "bat")) && ((new_value == 1)))){
web.game.awardAchievement(6);
};
};
};
}
public function showBonusSpeedGraphics(){
bonus_speed_graphic1.alpha = 0.66;
bonus_speed_graphic2.alpha = 0.33;
}
}
}//package framework.Spider.Bugs
Section 53
//StagBeetle (framework.Spider.Bugs.StagBeetle)
package framework.Spider.Bugs {
import framework.Spider.Web.*;
import framework.Spider.Graphics.*;
public class StagBeetle extends Prey {
public function StagBeetle(x:Number, y:Number, web1:Web){
super(x, y, web1);
approach_time = 5;
_edges = undefined;
_strength = 7.5;
_bites = 2;
_body_radius = 0.075;
_energy = 15;
_points = 25;
_webbing = 0.2;
_wraps = 3;
tutorial_id = "stag_beetle";
graphic = new StagBeetleGraphic();
_marked_graphic_type = "large";
generalInitialize(x, y, web1);
approach_sound_name = "sfxStagbeetleApproach";
}
override public function finishEating(eater:Spider){
eater.setBonusWebStrengthFull();
}
}
}//package framework.Spider.Bugs
Section 54
//MoonBackgroundGraphic (framework.Spider.Environments.Moon.MoonBackgroundGraphic)
package framework.Spider.Environments.Moon {
import flash.display.*;
public class MoonBackgroundGraphic extends MovieClip {
public function MoonBackgroundGraphic(){
super();
cacheAsBitmap = true;
}
}
}//package framework.Spider.Environments.Moon
Section 55
//MoonBranchGraphic (framework.Spider.Environments.Moon.MoonBranchGraphic)
package framework.Spider.Environments.Moon {
import flash.display.*;
public class MoonBranchGraphic extends MovieClip {
public function MoonBranchGraphic(){
super();
cacheAsBitmap = true;
}
}
}//package framework.Spider.Environments.Moon
Section 56
//MoonEnvironment (framework.Spider.Environments.Moon.MoonEnvironment)
package framework.Spider.Environments.Moon {
import framework.Spider.Environments.*;
import framework.Geometry.*;
public class MoonEnvironment extends Environment {
public function MoonEnvironment(){
var p1:Point;
var p2:Point;
var p3:Point;
var p4:Point;
var p5:Point;
var p6:Point;
var p7:Point;
var p8:Point;
var p9:Point;
var p10:Point;
var p11:Point;
var p12:Point;
var p13:Point;
super();
background_graphics = [new MoonBackgroundGraphic()];
frame_graphics = [new MoonBranchGraphic()];
p1 = new Point(0.01, 0.1);
p2 = new Point(0.5, 0.95);
p3 = new Point(0.5, 0.5);
p4 = new Point(0.99, 0.8);
p5 = new Point(0.5, 0.01);
p6 = new Point(0.75, 0.5);
p7 = new Point(0.75, 0.07);
p8 = new Point(0.85, 0.5);
p9 = new Point(0.5, 0.8);
p10 = new Point(0.92, 0.87);
p11 = new Point(0.92, 0.39);
p12 = new Point(0.5, 0.87);
p13 = new Point(0.71, 0.92);
addRegion(new Rectangle(p1, p2));
addRegion(new Rectangle(p3, p4));
addRegion(new Rectangle(p5, p6));
addRegion(new Rectangle(p7, p8));
addRegion(new Rectangle(p9, p10));
addRegion(new Rectangle(p8, p11));
addRegion(new Rectangle(p12, p13));
}
}
}//package framework.Spider.Environments.Moon
Section 57
//Environment (framework.Spider.Environments.Environment)
package framework.Spider.Environments {
import game.*;
import framework.Geometry.*;
public class Environment {
public var allowed_regions:Array;
public var background_graphics:Array;
public var frame_graphics:Array;
public function Environment(){
allowed_regions = new Array();
super();
}
public function clearFrame(game:Game){
var i:*;
i = 0;
while (i < frame_graphics.length) {
game["graphics_anchor"].removeChild(frame_graphics[i]);
i++;
};
}
public function attachBackground(game:Game){
var i:*;
i = 0;
while (i < background_graphics.length) {
game["graphics_anchor"].addChild(background_graphics[i]);
i++;
};
}
public function generatePoint():Point{
var point:Point;
point = new Point(Math.random(), Math.random());
while (!(inRegion(point))) {
point = new Point(Math.random(), Math.random());
};
return (point);
}
public function addRegion(region:Shape){
allowed_regions[allowed_regions.length] = region;
}
public function attachFrame(game:Game){
var i:*;
i = 0;
while (i < frame_graphics.length) {
game["graphics_anchor"].addChild(frame_graphics[i]);
i++;
};
}
public function inRegion(shape:Shape):Boolean{
var i:*;
i = 0;
while (i < allowed_regions.length) {
if (shape.intercepts(allowed_regions[i])){
return (true);
};
i++;
};
return (false);
}
public function clearBackground(game:Game){
var i:*;
i = 0;
while (i < background_graphics.length) {
game["graphics_anchor"].removeChild(background_graphics[i]);
i++;
};
}
}
}//package framework.Spider.Environments
Section 58
//BatGraphic (framework.Spider.Graphics.BatGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class BatGraphic extends MovieClip {
public function BatGraphic(){
super();
addFrameScript(6, frame7, 7, frame8, 8, frame9);
}
function frame7(){
gotoAndPlay("flying");
}
function frame8(){
stop();
}
function frame9(){
gotoAndPlay("caught");
}
}
}//package framework.Spider.Graphics
Section 59
//BeeGraphic (framework.Spider.Graphics.BeeGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class BeeGraphic extends MovieClip {
public function BeeGraphic(){
super();
addFrameScript(4, frame5, 5, frame6, 6, frame7);
}
function frame6(){
stop();
}
function frame7(){
gotoAndPlay("caught");
}
function frame5(){
gotoAndPlay("flying");
}
}
}//package framework.Spider.Graphics
Section 60
//ButterflyGraphic (framework.Spider.Graphics.ButterflyGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class ButterflyGraphic extends MovieClip {
public function ButterflyGraphic(){
super();
addFrameScript(8, frame9, 10, frame11, 11, frame12);
}
function frame12(){
gotoAndPlay("caught");
}
function frame9(){
gotoAndPlay("flying");
}
function frame11(){
stop();
}
}
}//package framework.Spider.Graphics
Section 61
//ButterflyGraphic2 (framework.Spider.Graphics.ButterflyGraphic2)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class ButterflyGraphic2 extends MovieClip {
public function ButterflyGraphic2(){
super();
addFrameScript(8, frame9, 10, frame11, 11, frame12);
}
function frame12(){
gotoAndPlay("caught");
}
function frame9(){
gotoAndPlay("flying");
}
function frame11(){
stop();
}
}
}//package framework.Spider.Graphics
Section 62
//ButterflyGraphic3 (framework.Spider.Graphics.ButterflyGraphic3)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class ButterflyGraphic3 extends MovieClip {
public function ButterflyGraphic3(){
super();
addFrameScript(8, frame9, 10, frame11, 11, frame12);
}
function frame12(){
gotoAndPlay("caught");
}
function frame9(){
gotoAndPlay("flying");
}
function frame11(){
stop();
}
}
}//package framework.Spider.Graphics
Section 63
//DragonflyGraphic (framework.Spider.Graphics.DragonflyGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class DragonflyGraphic extends MovieClip {
public function DragonflyGraphic(){
super();
addFrameScript(2, frame3, 3, frame4, 4, frame5);
}
function frame3(){
gotoAndPlay("flying");
}
function frame4(){
stop();
}
function frame5(){
gotoAndPlay("caught");
}
}
}//package framework.Spider.Graphics
Section 64
//FireFlyGraphic (framework.Spider.Graphics.FireFlyGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class FireFlyGraphic extends MovieClip {
public function FireFlyGraphic(){
super();
addFrameScript(4, frame5, 7, frame8);
}
function frame8(){
gotoAndPlay("caught");
}
function frame5(){
gotoAndPlay("flying");
}
}
}//package framework.Spider.Graphics
Section 65
//FlyGraphic (framework.Spider.Graphics.FlyGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class FlyGraphic extends MovieClip {
public function FlyGraphic(){
super();
addFrameScript(4, frame5, 5, frame6, 6, frame7, 13, frame14);
}
function frame14(){
gotoAndPlay("marked");
}
function frame6(){
stop();
}
function frame7(){
gotoAndPlay("caught");
}
function frame5(){
gotoAndPlay("flying");
}
}
}//package framework.Spider.Graphics
Section 66
//HummingBirdGraphic (framework.Spider.Graphics.HummingBirdGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class HummingBirdGraphic extends MovieClip {
public function HummingBirdGraphic(){
super();
addFrameScript(2, frame3, 3, frame4, 4, frame5, 7, frame8);
}
function frame3(){
gotoAndPlay("hovering");
}
function frame8(){
gotoAndPlay("flying");
}
function frame4(){
stop();
}
function frame5(){
gotoAndPlay("caught");
}
}
}//package framework.Spider.Graphics
Section 67
//LadyBugGraphic (framework.Spider.Graphics.LadyBugGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class LadyBugGraphic extends MovieClip {
public function LadyBugGraphic(){
super();
addFrameScript(3, frame4, 5, frame6, 6, frame7);
}
function frame6(){
stop();
}
function frame7(){
gotoAndPlay("caught");
}
function frame4(){
gotoAndPlay("flying");
}
}
}//package framework.Spider.Graphics
Section 68
//MothGraphic (framework.Spider.Graphics.MothGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class MothGraphic extends MovieClip {
public function MothGraphic(){
super();
addFrameScript(4, frame5, 10, frame11, 11, frame12);
}
function frame12(){
gotoAndPlay("caught");
}
function frame5(){
gotoAndPlay("flying");
}
function frame11(){
stop();
}
}
}//package framework.Spider.Graphics
Section 69
//QueenBeeGraphic (framework.Spider.Graphics.QueenBeeGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class QueenBeeGraphic extends MovieClip {
public function QueenBeeGraphic(){
super();
addFrameScript(4, frame5, 7, frame8);
}
function frame8(){
gotoAndPlay("caught");
}
function frame5(){
gotoAndPlay("flying");
}
}
}//package framework.Spider.Graphics
Section 70
//SpiderGraphic (framework.Spider.Graphics.SpiderGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class SpiderGraphic extends MovieClip {
public function SpiderGraphic(){
super();
addFrameScript(0, frame1, 9, frame10, 18, frame19, 27, frame28);
}
function frame10(){
gotoAndPlay("eating");
}
function frame1(){
stop();
}
function frame19(){
gotoAndPlay("flying");
}
function frame28(){
gotoAndPlay("crawling");
}
}
}//package framework.Spider.Graphics
Section 71
//StagBeetleGraphic (framework.Spider.Graphics.StagBeetleGraphic)
package framework.Spider.Graphics {
import flash.display.*;
public dynamic class StagBeetleGraphic extends MovieClip {
public function StagBeetleGraphic(){
super();
addFrameScript(4, frame5, 6, frame7, 7, frame8);
}
function frame7(){
stop();
}
function frame8(){
gotoAndPlay("caught");
}
function frame5(){
gotoAndPlay("flying");
}
}
}//package framework.Spider.Graphics
Section 72
//ArtLevel (framework.Spider.Levels.ArtLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class ArtLevel extends Level {
private var level:Number;
public function ArtLevel(){
super();
name = "art_level";
enemy_time = 750;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket <= 1){
spawn(new Bee(x, y, web), web);
};
}
}
}//package framework.Spider.Levels
Section 73
//BatAllLevel (framework.Spider.Levels.BatAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class BatAllLevel extends Level {
private var seen_bat:Boolean;// = false
private var level:Number;
public function BatAllLevel(){
seen_bat = false;
super();
name = "bat_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
length = (length + (level * 5000));
if (timeSinceUpdate > length){
level++;
seen_bat = false;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.36){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.46){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.56){
spawn(new Bee(x, y, web), web);
} else {
if (bucket <= 0.66){
spawn(new FireFly(x, y, web), web);
} else {
if (bucket <= 0.75){
spawn(new DragonFly(x, y, web), web);
} else {
if (bucket < 0.8){
spawn(new StagBeetle(x, y, web), web);
} else {
if (bucket < 0.85){
spawn(new ButterFly(x, y, web), web);
} else {
if (bucket < 0.9){
spawn(new QueenBee(x, y, web), web);
} else {
if (bucket < 0.95){
spawn(new HummingBird(x, y, web), web);
} else {
if (bucket <= 1){
if (!seen_bat){
spawn(new Bat(x, y, web), web);
seen_bat = true;
} else {
spawn(new Fly(x, y, web), web);
};
};
};
};
};
};
};
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 74
//BatLevel (framework.Spider.Levels.BatLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class BatLevel extends Level {
private var level:Number;
public function BatLevel(){
super();
name = "bat_level";
enemy_time = 1250;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.75){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.97){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 1){
spawn(new Bat(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 75
//BeeLevel (framework.Spider.Levels.BeeLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class BeeLevel extends Level {
private var level:Number;
public function BeeLevel(){
super();
name = "bee_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
if (timeSinceUpdate > 60000){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.6){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.8){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket <= 1){
spawn(new Bee(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 76
//ButterflyAllLevel (framework.Spider.Levels.ButterflyAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class ButterflyAllLevel extends Level {
private var level:Number;
public function ButterflyAllLevel(){
super();
name = "butterfly_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
length = (length + (level * 10000));
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.43){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.53){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.63){
spawn(new Bee(x, y, web), web);
} else {
if (bucket <= 0.73){
spawn(new FireFly(x, y, web), web);
} else {
if (bucket <= 0.82){
spawn(new DragonFly(x, y, web), web);
} else {
if (bucket < 0.87){
spawn(new StagBeetle(x, y, web), web);
} else {
if (bucket < 0.93){
spawn(new ButterFly(x, y, web), web);
} else {
if (bucket < 1){
spawn(new QueenBee(x, y, web), web);
};
};
};
};
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 77
//ButterflyLevel (framework.Spider.Levels.ButterflyLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class ButterflyLevel extends Level {
private var level:Number;
public function ButterflyLevel(){
super();
name = "butterfly_level";
enemy_time = 1250;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.74){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.94){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 1){
spawn(new ButterFly(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 78
//DragonflyAllLevel (framework.Spider.Levels.DragonflyAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class DragonflyAllLevel extends Level {
private var level:Number;
public function DragonflyAllLevel(){
super();
name = "dragonfly_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
length = (length + (level * 10000));
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.41){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.51){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.71){
spawn(new Bee(x, y, web), web);
} else {
if (bucket < 0.76){
spawn(new StagBeetle(x, y, web), web);
} else {
if (bucket <= 0.91){
spawn(new FireFly(x, y, web), web);
} else {
if (bucket <= 1){
spawn(new DragonFly(x, y, web), web);
};
};
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 79
//DragonflyLevel (framework.Spider.Levels.DragonflyLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class DragonflyLevel extends Level {
private var level:Number;
public function DragonflyLevel(){
super();
name = "dragonfly_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.75){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.95){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket <= 1){
spawn(new DragonFly(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 80
//FireFlyAllLevel (framework.Spider.Levels.FireFlyAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class FireFlyAllLevel extends Level {
private var level:Number;
public function FireFlyAllLevel(){
super();
name = "firefly_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
length = (length + (level * 10000));
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.5){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.6){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.8){
spawn(new Bee(x, y, web), web);
} else {
if (bucket < 0.85){
spawn(new StagBeetle(x, y, web), web);
} else {
if (bucket <= 1){
spawn(new FireFly(x, y, web), web);
};
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 81
//FireFlyLevel (framework.Spider.Levels.FireFlyLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class FireFlyLevel extends Level {
private var level:Number;
public function FireFlyLevel(){
super();
name = "firefly_level";
enemy_time = 1050;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.65){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.85){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket <= 1){
spawn(new FireFly(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 82
//FlyLevel (framework.Spider.Levels.FlyLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class FlyLevel extends Level {
private var testing:Boolean;// = false
private var level:Number;
public function FlyLevel(){
testing = false;
super();
name = "fly_level";
enemy_time = 750;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
if (!testing){
length = 30000;
if (level == 0){
length = 45000;
};
if (timeSinceUpdate > length){
level++;
return (true);
};
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket <= 1){
if (testing){
spawn(new ButterFly(x, y, web), web);
} else {
spawn(new Fly(x, y, web), web);
};
};
}
}
}//package framework.Spider.Levels
Section 83
//HummingBirdAllLevel (framework.Spider.Levels.HummingBirdAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class HummingBirdAllLevel extends Level {
private var level:Number;
public function HummingBirdAllLevel(){
super();
name = "hummingbird_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
length = (length + (level * 10000));
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.41){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.51){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.61){
spawn(new Bee(x, y, web), web);
} else {
if (bucket <= 0.71){
spawn(new FireFly(x, y, web), web);
} else {
if (bucket <= 0.8){
spawn(new DragonFly(x, y, web), web);
} else {
if (bucket < 0.85){
spawn(new StagBeetle(x, y, web), web);
} else {
if (bucket < 0.9){
spawn(new ButterFly(x, y, web), web);
} else {
if (bucket < 0.95){
spawn(new QueenBee(x, y, web), web);
} else {
if (bucket < 1){
spawn(new HummingBird(x, y, web), web);
};
};
};
};
};
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 84
//HummingBirdLevel (framework.Spider.Levels.HummingBirdLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class HummingBirdLevel extends Level {
private var level:Number;
public function HummingBirdLevel(){
super();
name = "hummingbird_level";
enemy_time = 1250;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.75){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.95){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 1){
spawn(new HummingBird(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 85
//LadyBugLevel (framework.Spider.Levels.LadyBugLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class LadyBugLevel extends Level {
public function LadyBugLevel(){
super();
name = "ladybug_level";
enemy_time = 850;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
if (timeSinceUpdate > 45000){
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.8){
spawn(new Fly(x, y, web), web);
} else {
if (bucket <= 1){
spawn(new LadyBug(x, y, web), web);
};
};
}
}
}//package framework.Spider.Levels
Section 86
//Level (framework.Spider.Levels.Level)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import game.*;
import framework.Geometry.*;
import framework.Spider.Bugs.*;
import framework.Spider.Abstract.*;
public class Level {
public var enemy_time:Number;
public var bucket:Number;
public var name:String;
public function Level(){
super();
}
public function displayLevel(game:Game, level_index:String, level_name:String){
game.spider.ui.displayLevel(level_index, level_name);
}
public function start(game:Game){
}
public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
var pull:Number;
var new_x:Number;
var new_y:Number;
var i:Number;
var point:Point;
var fire_flies:Array;
var fire_fly:FireFly;
var chance:Number;
var queen_bees:Array;
var queen_bee:QueenBee;
bucket = Math.random();
if (web.hasFireFly()){
fire_flies = web.getFireFlies();
pull = 3;
i = 0;
while (i < fire_flies.length) {
chance = (Math.random() * 3);
if (chance < 2){
fire_fly = FireFly(fire_flies[i]);
point = environment.generatePoint();
new_x = ((point.x + (fire_fly.position.x * pull)) / (pull + 1));
new_y = ((point.y + (fire_fly.position.y * pull)) / (pull + 1));
web.spawnMoth(new_x, new_y);
};
i++;
};
if (Math.random() < 0.5){
bucket = 100000;
};
};
if (web.hasQueenBee()){
queen_bees = web.getQueenBees();
pull = 1;
i = 0;
while (i < queen_bees.length) {
queen_bee = QueenBee(queen_bees[i]);
point = environment.generatePoint();
new_x = ((point.x + (queen_bee.position.x * pull)) / (pull + 1));
new_y = ((point.y + (queen_bee.position.y * pull)) / (pull + 1));
web.spawnBee(new_x, new_y);
i++;
};
bucket = 100000;
};
}
public function spawn(bug:Catchable, web:Web){
web.addCatchable(bug);
}
public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
return (false);
}
public function getEnemyTime(web:Web):Number{
var return_time:Number;
return_time = enemy_time;
if (web.hasQueenBee()){
return_time = 750;
};
if (web.hasFireFly()){
return_time = (return_time / 2);
};
return (return_time);
}
}
}//package framework.Spider.Levels
Section 87
//PeacefulLevel (framework.Spider.Levels.PeacefulLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
public class PeacefulLevel extends Level {
private var level:Number;
public function PeacefulLevel(){
super();
name = "peaceful_level";
enemy_time = 750;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
if (timeSinceUpdate > 5000){
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
}
}
}//package framework.Spider.Levels
Section 88
//QueenBeeAllLevel (framework.Spider.Levels.QueenBeeAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class QueenBeeAllLevel extends Level {
private var level:Number;
public function QueenBeeAllLevel(){
super();
name = "queen_bee_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
length = (length + (level * 10000));
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.49){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.59){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.69){
spawn(new Bee(x, y, web), web);
} else {
if (bucket <= 0.79){
spawn(new FireFly(x, y, web), web);
} else {
if (bucket <= 0.88){
spawn(new DragonFly(x, y, web), web);
} else {
if (bucket < 0.93){
spawn(new StagBeetle(x, y, web), web);
} else {
if (bucket < 1){
spawn(new QueenBee(x, y, web), web);
};
};
};
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 89
//QueenBeeLevel (framework.Spider.Levels.QueenBeeLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class QueenBeeLevel extends Level {
private var level:Number;
public function QueenBeeLevel(){
super();
name = "queen_bee_level";
enemy_time = 1250;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.72){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.92){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 1){
spawn(new QueenBee(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 90
//ShortPeacefulLevel (framework.Spider.Levels.ShortPeacefulLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
public class ShortPeacefulLevel extends Level {
private var level:Number;
public function ShortPeacefulLevel(){
super();
name = "short_peaceful_level";
enemy_time = 750;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
if (timeSinceUpdate > 3000){
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
}
}
}//package framework.Spider.Levels
Section 91
//StagBeetleAllLevel (framework.Spider.Levels.StagBeetleAllLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class StagBeetleAllLevel extends Level {
private var level:Number;
public function StagBeetleAllLevel(){
super();
name = "stag_beetle_all_level";
enemy_time = 950;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 60000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.65){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.75){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 0.95){
spawn(new Bee(x, y, web), web);
} else {
if (bucket < 1){
spawn(new StagBeetle(x, y, web), web);
};
};
};
};
}
}
}//package framework.Spider.Levels
Section 92
//StagBeetleLevel (framework.Spider.Levels.StagBeetleLevel)
package framework.Spider.Levels {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Spider.Bugs.*;
public class StagBeetleLevel extends Level {
private var level:Number;
public function StagBeetleLevel(){
super();
name = "stag_beetle_level";
enemy_time = 1250;
level = 0;
}
override public function updateDifficulty(score:Number, timeSinceUpdate:Number):Boolean{
var length:Number;
length = 45000;
if (timeSinceUpdate > length){
level++;
return (true);
};
return (false);
}
override public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
super.spawnBug(x, y, web, environment);
if (bucket < 0.72){
spawn(new Fly(x, y, web), web);
} else {
if (bucket < 0.92){
spawn(new LadyBug(x, y, web), web);
} else {
if (bucket < 1){
spawn(new StagBeetle(x, y, web), web);
};
};
};
}
}
}//package framework.Spider.Levels
Section 93
//ArtBeeTutorial (framework.Spider.Tutorials.ArtBeeTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class ArtBeeTutorial extends Tutorial {
public function ArtBeeTutorial(game:Game){
title = "Bees";
description = "This is your eraser. Use it to remove strands you no longer want.\n- Hold down 'b' (for bee) and click to summon a bee.";
hint = "You can also use bees to test the strength of your web. Try breaking a strand and see what else breaks with it.";
graphic = new BeeGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 94
//ArtSpiderTutorial (framework.Spider.Tutorials.ArtSpiderTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class ArtSpiderTutorial extends Tutorial {
public function ArtSpiderTutorial(game:Game){
title = "Art Mode";
description = "In art mode, this is your paint brush. You don't have to worry about dying, because your life will never go down. In art mode, you're free to create the masterpiece you've always envisioned!";
hint = "Art mode can also be used to test out a new web strategy, or to just experiment with the game's engine.";
graphic = new SpiderGraphic();
graphic.gotoAndPlay("crawling");
super(game);
}
override public function close(game:Game):Boolean{
window.removeChild(graphic);
graphic = null;
window = null;
game.displayTutorial("art_web");
return (true);
}
}
}//package framework.Spider.Tutorials
Section 95
//ArtWebTutorial (framework.Spider.Tutorials.ArtWebTutorial)
package framework.Spider.Tutorials {
import game.*;
public class ArtWebTutorial extends Tutorial {
public function ArtWebTutorial(game:Game){
title = "Masterpiece";
description = "In art mode, this is your masterpiece.\n- Click on your web to move there.\n- Drag your mouse to add strands to your web.";
hint = "You don't have to worry about webbing in art mode... you're always fully stocked! You also don't need to worry about bugs breaking your web as you create it.";
graphic = new WebTutorialGraphic();
super(game);
}
override public function close(game:Game):Boolean{
window.removeChild(graphic);
graphic = null;
window = null;
game.displayTutorial("art_bee");
return (true);
}
}
}//package framework.Spider.Tutorials
Section 96
//BatTutorial (framework.Spider.Tutorials.BatTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class BatTutorial extends Tutorial {
public function BatTutorial(game:Game){
title = "The Bat";
description = "This is a bat. Bats are rare, so you'll only see one at a time. They are big and strong. If one hits your web, it will probably break. But don't give up, because it will eventually get weak and you can catch it. Eat it quickly, because it will give you a lot of points!";
hint = "If you catch the bat, you will be a legend among spiders.";
facts = "Bats are mammals, like humans, who feed milk to their young. Bats make up 20% of all mammal species. They are the only mammals that can fly.\n\n";
facts = (facts + "While bats are known as blood suckers, very few actually suck blood. Most eat insects like moths, while some eat fruit or nectar. Bats are generally nocturnal, and many use echolocation, or sonar, to navigate and identify prey.");
graphic = new BatGraphic();
graphic.scaleX = 0.33;
graphic.scaleY = 0.33;
super(game);
}
}
}//package framework.Spider.Tutorials
Section 97
//BeeTutorial (framework.Spider.Tutorials.BeeTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class BeeTutorial extends Tutorial {
public function BeeTutorial(game:Game){
title = "Bee";
description = "This is a bee. Bees are nasty. Usually they'll break your web if they hit it. If you catch one, be careful, because you'll get hurt if you eat it!";
hint = "Bees that you catch will greatly weaken your web, so you may want to eat them even though they will hurt you.";
facts = "Bees are social insects, living and working together for the good of the hive. Most bees are workers, females who gather food and care for the nest.\n\n";
facts = (facts + "Bees have a reputation for stinging, but most bees are peaceful, only stinging to defend the colony. They eat nectar from flowers and play the very important ecological role of pollinating plants, helping them reproduce.");
graphic = new BeeGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 98
//ButterFlyTutorial (framework.Spider.Tutorials.ButterFlyTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class ButterFlyTutorial extends Tutorial {
public function ButterFlyTutorial(game:Game){
title = "ButterFly";
description = "This is a butterfly. Butterflies are really tasty! Eating one will replenish your health, your webbing, and give you a lot of points. Be careful when you eat it, though, because your spider will get carried away and eat for a while.";
hint = "Wait until you have time to eat a butterfly before endulging. Re-enforce the web around the butterfly so it can't escape before you eat it.";
facts = "Butterflies are actually moths, but a number of characteristics generally distinguish them from more standard moths, such as wings that rest upright rather than lying down and being active during the day. Butterflies use their brilliant wings for a number of purposes, including warning predators of toxins and bad tastes, mimicking other species, and confusing predators. Butterflies, like bees, play the very important ecological role of pollinating flowers.";
graphic = new ButterflyGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 99
//CaughtTutorial (framework.Spider.Tutorials.CaughtTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class CaughtTutorial extends Tutorial {
public function CaughtTutorial(game:Game){
title = "Catching Bugs";
description = "You've caught a delicious bug! Click on it once to eat it.";
hint = "When you catch a bug, the strands holding it will weaken and turn red. These strands are more likely to break. Remember, a clean web is a strong web!";
facts = "Though our hero runs around a lot, many spiders spend much of their time motionless in the center of their webs. Instead of their web turning red, they feel the vibrations when prey hits their web, which tells them it's time to eat.";
graphic = new CaughtTutorialGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 100
//CaughtTutorialGraphic (framework.Spider.Tutorials.CaughtTutorialGraphic)
package framework.Spider.Tutorials {
import flash.display.*;
import framework.Spider.Graphics.*;
public dynamic class CaughtTutorialGraphic extends MovieClip {
var bug_graphic:MovieClip;
public function CaughtTutorialGraphic(){
super();
bug_graphic = new FlyGraphic();
bug_graphic.gotoAndPlay("caught");
addChild(bug_graphic);
}
}
}//package framework.Spider.Tutorials
Section 101
//DragonFlyTutorial (framework.Spider.Tutorials.DragonFlyTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class DragonFlyTutorial extends Tutorial {
public function DragonFlyTutorial(game:Game){
title = "Dragonfly";
description = "This is a dragonfly. Dragonflies are fast. If you manage to catch one, make sure you eat it, because you'll be able to move and eat faster for a while.";
hint = "Eating a dragonfly allows you to quickly clean up your web. Eat one before you eat a stag beetle so you can lay golden webbing faster.";
facts = "Dragonflies are expert predators that feed on other insects. Their big eyes and lightning fast speed ensure that they can easily identify and catch prey. Dragonflies are often found near water because young dragonflies, called nymphs, live under water. Dragonfly nymphs are also formidable hunters, capable of catching fish and tadpoles.";
graphic = new DragonflyGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 102
//EatBatTutorial (framework.Spider.Tutorials.EatBatTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class EatBatTutorial extends Tutorial {
public function EatBatTutorial(game:Game){
title = "Victory";
description = "This is you. You are a legend. By capturing and eating a bat, you have proven that you truly are a godlike invertebrate.";
hint = "Can't get enough spider action? You can keep playing for a high score until you inevitably die of hunger.";
facts = "Vertibrates, like humming birds, bats, and humans, appear to rule the world. However, vertibrates make up only 3% of all animal species. Our hero, an invertibrate, is a reminder that we're far from alone in this world.\n\n";
facts = (facts + "The global ecosystem is a delicate web of life. Remember that you and I are part of this beautiful, amazing planet, and that our actions help shape it.");
graphic = new SpiderGraphic();
graphic.gotoAndPlay("eating");
graphic.scaleX = 2;
graphic.scaleY = 2;
graphic.rotation = 270;
super(game);
}
}
}//package framework.Spider.Tutorials
Section 103
//FireFlyTutorial (framework.Spider.Tutorials.FireFlyTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class FireFlyTutorial extends Tutorial {
public function FireFlyTutorial(game:Game){
title = "FireFly";
description = "This is a fire fly. Fire flies are pretty. When you catch one, it will attract other bugs. They give you a lot of points, so make sure you eat them before they escape!";
hint = "Remember to press the space bar to cancel your upcoming actions if you need to reach a fire fly in time.";
facts = "Fire flies are not flies at all, but are actually beetles. They produce bioluminecence, or light, from their bodies using chemicals. Their lights are almost ten times as energy efficient as most light bulbs. They usually use their bioluminecence to attract mates, but some use their lights to lure prey.";
graphic = new FireFlyGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 104
//FlyTutorial (framework.Spider.Tutorials.FlyTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class FlyTutorial extends Tutorial {
public function FlyTutorial(game:Game){
title = "Fly";
description = "This is a fly. Flies are your main source of food. Eating them will heal you and give you webbing.\n\nYou'll see more tasty treats soon.";
hint = "A little low on webbing? Eat a few of these.";
facts = "Flies are insects, six legged bugs that usually have wings and antenna. Spiders eat a lot of insects, and you'll see a lot of them in this game.\n\n";
facts = (facts + "Though flies can be predators, parasites, or herbivores, many flies are scavengers, eating dead plants and animals. Scavengers play a very important role in an ecosystem, making sure that dead organic matter returns to the food chain.");
graphic = new FlyGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 105
//HummingBirdTutorial (framework.Spider.Tutorials.HummingBirdTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class HummingBirdTutorial extends Tutorial {
public function HummingBirdTutorial(game:Game){
title = "Humming Bird";
description = "This is a humming bird. Humming birds are tricky. They're very fast, very strong, and give you a lot of points. Before they collide, they hover for a moment, so take advantage to re-enforce your web.";
hint = "Sometimes, a humming bird will move before it collides, so stay on your toes.";
facts = "Humming birds are some of the smallest birds. They fly in a way unlike other birds, flapping their wings up to eighty times per second. This allows them to hover, so they can feed on nectar and pollinate flowers like bees and butterflies. Though mostly known for eating nectar, many humming birds also eat insects and spiders for protein.";
graphic = new HummingBirdGraphic();
graphic.gotoAndPlay("hovering");
super(game);
}
}
}//package framework.Spider.Tutorials
Section 106
//LadyBugTutorial (framework.Spider.Tutorials.LadyBugTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class LadyBugTutorial extends Tutorial {
public function LadyBugTutorial(game:Game){
title = "LadyBug";
description = "This is a ladybug. Ladybugs are tasty. They're a little stronger than flies, and eating one will give you a lot of health.";
hint = "Try keeping one or two of these in your web in case of an emergency.";
facts = "Ladybugs are beetles, insects with hard shells covering their wings. There are more species of beetles than any other insect.\n\n";
facts = (facts + "Ladybugs look cute, but they're actually predators, just like spiders. Gardeners often use them as environmentally friendly pest control. Ladybugs use their bright colors to tell potential predators that they taste very bad.");
graphic = new LadyBugGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 107
//MothTutorial (framework.Spider.Tutorials.MothTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class MothTutorial extends Tutorial {
public function MothTutorial(game:Game){
title = "Moth";
description = "This is a moth. They like the light and will show up like crazy if you catch a fire fly.";
hint = "Moths give you a lot of webbing, so you may want to let a fire fly attract a few before you eat it.";
facts = "Moths are insects that are usually nocturnal, meaning they are active at night. They usually eat plants, but are known for eating cloth.\n\n";
facts = (facts + "Moths are not really attracted to fire flies, but are attracted to electric lights and candles. No one knows why moths like lights, but some people think it is because they navigate using the moon, and electric lights confuse them.");
graphic = new MothGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 108
//QueenBeeTutorial (framework.Spider.Tutorials.QueenBeeTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class QueenBeeTutorial extends Tutorial {
public function QueenBeeTutorial(game:Game){
title = "QueenBee";
description = "This is a queen bee. Queen bees are really nasty. If you catch one, it will call lots of bees to help free it, so eat it quickly. Make sure you have lots of life, though, because eating one will hurt you even more than a normal bee.";
hint = "Have any ladybugs lying around? They'll come in handy now.";
facts = "Queen bees spend their lives protected in their hives. They are the most important part of a colony, and workers feed them and take care of them.\n\n";
facts = (facts + "The queen bee's role in a colony is to reproduce. Even though all of the workers are female, the queen bee is the only female that reproduces, and she does so constantly. A queen bee is easily distinguished from other bees by her large size.");
graphic = new QueenBeeGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 109
//SpiderTutorial (framework.Spider.Tutorials.SpiderTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class SpiderTutorial extends Tutorial {
public function SpiderTutorial(game:Game){
title = "Spider";
description = "This is you. You are a spider. You are a hungry spider, and some bugs sound pretty tasty right about now.\n- Click on a bug stuck in your web to eat it.\n- Press 'enter' to pause and unpause.";
hint = "The red bar on the right shows your life. If you run out of life, you will die and your game will be over.";
facts = "Spiders are arachnids. Arachnids have eight legs and are usually predators, hunting other animals for food. Other arachnids include scorpions, ticks, and mites. Though they can bite and some are poisonous, spiders generally eat animals many people consider pests, so they aren't all bad. The hero of our game is an unspecified species of spider.\n\nArachnophilia means \"love of spiders\".";
graphic = new SpiderGraphic();
graphic.gotoAndPlay("crawling");
super(game);
}
override public function close(game:Game):Boolean{
window.removeChild(graphic);
graphic = null;
window = null;
game.displayTutorial("web");
return (true);
}
}
}//package framework.Spider.Tutorials
Section 110
//StagBeetleTutorial (framework.Spider.Tutorials.StagBeetleTutorial)
package framework.Spider.Tutorials {
import game.*;
import framework.Spider.Graphics.*;
public class StagBeetleTutorial extends Tutorial {
public function StagBeetleTutorial(game:Game){
title = "StagBeetle";
description = "This is a stag beetle. Stag beetles are strong. They're tough to catch, but worth it. If you eat one, you'll get golden webbing for a while, which is stronger than normal webbing.";
hint = "Make sure you have lots of webbing before you eat one of these, because you'll only have a few seconds to lay golden webbing.";
facts = "Stag beetles are large insects whose mandibles, or mouth parts, look like the antlers of deer. Some can grow larger than a quarter of a foot. While they look scary, most stag beetles are gentle and only use their mandibles to fight other stag beetles for mates, just like deer and other mammals with antlers.";
graphic = new StagBeetleGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 111
//Tutorial (framework.Spider.Tutorials.Tutorial)
package framework.Spider.Tutorials {
import game.*;
import flash.events.*;
import flash.display.*;
public class Tutorial {
protected var hint:String;
protected var graphic:MovieClip;
protected var facts:String;
protected var full_description:String;
public var window:TutorialWindow;
protected var title:String;
protected var description:String;
public function Tutorial(game:Game){
super();
window = new TutorialWindow(game);
window.tutorialTitle.text = title;
full_description = description;
if (hint){
full_description = ((full_description + "\n\nTip: ") + hint);
};
showHelp();
graphic.x = 150;
graphic.y = 235;
window.addChild(graphic);
}
public function showHelpEvent(event:MouseEvent){
showHelp();
}
public function close(game:Game):Boolean{
window.removeChild(graphic);
graphic = null;
window = null;
return (false);
}
public function showFacts(){
window.tutorialDescription.text = facts;
window["factsButton"].gotoAndPlay("help");
window["factsButton"].removeEventListener(MouseEvent.MOUSE_UP, showFactsEvent);
window["factsButton"].addEventListener(MouseEvent.MOUSE_UP, showHelpEvent);
}
public function showFactsEvent(event:MouseEvent){
showFacts();
}
public function showHelp(){
window.tutorialDescription.text = full_description;
if (facts == null){
window["factsButton"].visible = false;
} else {
window["factsButton"].gotoAndPlay("facts");
window["factsButton"].removeEventListener(MouseEvent.MOUSE_UP, showHelpEvent);
window["factsButton"].addEventListener(MouseEvent.MOUSE_UP, showFactsEvent);
};
}
}
}//package framework.Spider.Tutorials
Section 112
//TutorialWindow (framework.Spider.Tutorials.TutorialWindow)
package framework.Spider.Tutorials {
import game.*;
import flash.events.*;
import flash.display.*;
public dynamic class TutorialWindow extends MovieClip {
public function TutorialWindow(game:Game){
super();
this["continueButton"].addEventListener(MouseEvent.MOUSE_UP, game.tutorialContinue);
this["turnOffTutorialsButton"].addEventListener(MouseEvent.MOUSE_UP, game.turnOffTutorialsAndContinue);
}
}
}//package framework.Spider.Tutorials
Section 113
//WebTutorial (framework.Spider.Tutorials.WebTutorial)
package framework.Spider.Tutorials {
import game.*;
public class WebTutorial extends Tutorial {
public function WebTutorial(game:Game){
title = "Web";
description = "This is your web. Catch prey with your web.\n- Click on your web to move there.\n- Drag your mouse to add strands to your web.\n- Press 'space' to cancel actions.";
hint = "You can only add to your web if you have enough webbing. The grey bar to the right indicates how much webbing you have left. Eat bugs to replenish your webbing.";
facts = "All spiders are capable of producing silk. Our hero uses her silk like an orb-weaver spider, which create the vertical spiralling webs you've probably seen. Some spiders don't create webs, but use their silk in other ways. Some use their silk as armor for their eggs, while others use their silk like a net for hunting.";
graphic = new WebTutorialGraphic();
super(game);
}
}
}//package framework.Spider.Tutorials
Section 114
//WebTutorialGraphic (framework.Spider.Tutorials.WebTutorialGraphic)
package framework.Spider.Tutorials {
import flash.display.*;
public dynamic class WebTutorialGraphic extends MovieClip {
public function WebTutorialGraphic(){
super();
}
}
}//package framework.Spider.Tutorials
Section 115
//AchievementDisplay (framework.Spider.UI.AchievementDisplay)
package framework.Spider.UI {
import flash.display.*;
public dynamic class AchievementDisplay extends MovieClip {
public function AchievementDisplay(){
super();
}
}
}//package framework.Spider.UI
Section 116
//LevelDisplay (framework.Spider.UI.LevelDisplay)
package framework.Spider.UI {
import flash.display.*;
public dynamic class LevelDisplay extends MovieClip {
public function LevelDisplay(){
super();
}
}
}//package framework.Spider.UI
Section 117
//MinusHealthGraphic (framework.Spider.UI.MinusHealthGraphic)
package framework.Spider.UI {
import framework.Spider.Bugs.*;
public dynamic class MinusHealthGraphic extends PlusGraphic {
public function MinusHealthGraphic(the_spider:Spider){
super();
x_offset = 0;
y_offset = 0.04;
total_y_change = 0.175;
generalInitialize(the_spider);
}
override public function remove(){
spider.removeMinusHealth(this);
}
}
}//package framework.Spider.UI
Section 118
//PlusGraphic (framework.Spider.UI.PlusGraphic)
package framework.Spider.UI {
import game.*;
import flash.display.*;
import framework.Spider.Bugs.*;
public dynamic class PlusGraphic extends MovieClip {
public var id:Number;
public var y_offset:Number;
public var level_data:LevelData;
public var x_offset:Number;
public var total_y_change:Number;// = -0.175
public var current_time:Number;
public var spider:Spider;
public var total_x_change:Number;// = 0
public static var count:Number = 0;
public static var total_time:Number = 1.25;
public static var starting_alpha:Number = 1;
public function PlusGraphic(){
total_x_change = 0;
total_y_change = -0.175;
super();
}
public function remove(){
}
public function generalInitialize(the_spider:Spider){
id = count++;
current_time = total_time;
spider = the_spider;
level_data = spider.web.game.level_data;
total_x_change = level_data.xRatio(total_x_change);
total_y_change = level_data.yRatio(total_y_change);
x = (spider.graphic.x + level_data.xRatio(x_offset));
y = (spider.graphic.y + level_data.yRatio(y_offset));
alpha = starting_alpha;
}
public function update(amount:Number){
var ratio:Number;
current_time = (current_time - amount);
ratio = (amount / total_time);
x = (x + (ratio * total_x_change));
y = (y + (ratio * total_y_change));
alpha = (alpha - ratio);
if (current_time <= 0){
remove();
};
}
}
}//package framework.Spider.UI
Section 119
//PlusHealthGraphic (framework.Spider.UI.PlusHealthGraphic)
package framework.Spider.UI {
import framework.Spider.Bugs.*;
public dynamic class PlusHealthGraphic extends PlusGraphic {
public function PlusHealthGraphic(the_spider:Spider){
super();
x_offset = 0;
y_offset = -0.04;
generalInitialize(the_spider);
}
override public function remove(){
spider.removePlusHealth(this);
}
}
}//package framework.Spider.UI
Section 120
//PlusPointsGraphic (framework.Spider.UI.PlusPointsGraphic)
package framework.Spider.UI {
import framework.Spider.Bugs.*;
public dynamic class PlusPointsGraphic extends PlusGraphic {
public function PlusPointsGraphic(the_spider:Spider){
super();
x_offset = 0.08;
y_offset = -0.04;
total_x_change = 0.075;
generalInitialize(the_spider);
}
override public function remove(){
spider.removePlusPoints(this);
}
}
}//package framework.Spider.UI
Section 121
//PlusWebbingGraphic (framework.Spider.UI.PlusWebbingGraphic)
package framework.Spider.UI {
import framework.Spider.Bugs.*;
public dynamic class PlusWebbingGraphic extends PlusGraphic {
public function PlusWebbingGraphic(the_spider:Spider){
super();
x_offset = -0.1;
y_offset = -0.04;
total_x_change = -0.075;
generalInitialize(the_spider);
}
override public function remove(){
spider.removePlusWebbing(this);
}
}
}//package framework.Spider.UI
Section 122
//SpiderUI (framework.Spider.UI.SpiderUI)
package framework.Spider.UI {
import game.*;
import flash.display.*;
import framework.UserInterface.*;
public class SpiderUI extends UI {
public var level_display_time:Number;
public var level_display:LevelDisplay;
public var spider_webbing_warning:MovieClip;
public var hungry_bar:MovieClip;
public var webbing_symbol:MovieClip;
public var energy_symbol:MovieClip;
public var achievement_display:AchievementDisplay;
public var webbing_warning_alpha_max:Number;// = 0.85
public var achievement_display_time:Number;
public var webbing_warning_bar:MovieClip;
public var bonus_webbing_bar:MovieClip;
public var bar_height:Number;
public var achievement_graphic:MovieClip;
public var webbing_warning_time:Number;
public var achievement_display_fade_time:Number;// = 7.5
public var webbing_bar:MovieClip;
public var webbing_warning_fade_time:Number;// = 0.5
public var webbing_warning_solid_time:Number;// = 0.5
public var webbing_warning:MovieClip;
public var level_display_fade_time:Number;// = 3
public var full_bar:MovieClip;
public function SpiderUI(level_data:LevelData){
level_display_fade_time = 3;
achievement_display_fade_time = 7.5;
webbing_warning_solid_time = 0.5;
webbing_warning_fade_time = 0.5;
webbing_warning_alpha_max = 0.85;
super();
x = (LevelData.screenWidth + (2 * LevelData.screenOffsetX));
y = 175;
bar_height = 100;
base_webbing_bar_x = 80;
base_webbing_bar_y = 75;
webbing_bar = new WebbingBar();
webbing_bar.x = (x + base_webbing_bar_x);
webbing_bar.y = (y + base_webbing_bar_y);
webbing_symbol = new WebbingSymbol();
webbing_symbol.x = (x + base_webbing_bar_x);
webbing_symbol.y = (y + base_webbing_bar_y);
webbing_warning_bar = new FullBar();
webbing_warning_bar.height = bar_height;
webbing_warning_bar.x = (x + base_webbing_bar_x);
webbing_warning_bar.y = (y + base_webbing_bar_y);
webbing_warning_bar.alpha = 0;
webbing_warning = new WebbingWarning();
webbing_warning.x = (x + base_webbing_bar_x);
webbing_warning.y = (y + base_webbing_bar_y);
webbing_warning.alpha = 0;
spider_webbing_warning = new SpiderWebbingWarning();
spider_webbing_warning.alpha = 0;
base_full_bar_x = 115;
base_full_bar_y = 75;
full_bar = new FullBar();
full_bar.x = (x + base_full_bar_x);
full_bar.y = (y + base_full_bar_y);
hungry_bar = new HungryBar();
hungry_bar.alpha = 0;
hungry_bar.x = (x + base_full_bar_x);
hungry_bar.y = (y + base_full_bar_y);
energy_symbol = new EnergySymbol();
energy_symbol.x = (x + base_full_bar_x);
energy_symbol.y = (y + base_full_bar_y);
bonus_webbing_bar = new BonusWebbingBar();
bonus_webbing_bar.x = (x + base_webbing_bar_x);
bonus_webbing_bar.y = (y + base_webbing_bar_y);
level_display = new LevelDisplay();
level_display.alpha = 0;
achievement_display = new AchievementDisplay();
achievement_display.alpha = 0;
}
public function updateWebbing(time:Number, percent:Number){
var ratio:Number;
webbing_bar.height = (bar_height * percent);
bonus_webbing_bar.height = webbing_bar.height;
if (webbing_warning_time > 0){
webbing_warning_time = (webbing_warning_time - time);
if (webbing_warning_time < 0){
webbing_warning_time = 0;
};
if (webbing_warning_time < webbing_warning_fade_time){
ratio = (webbing_warning_time / webbing_warning_fade_time);
webbing_warning.alpha = ratio;
spider_webbing_warning.alpha = (webbing_warning_alpha_max * ratio);
webbing_warning_bar.alpha = ratio;
};
};
}
public function displayAchievement(achievement_title:String, graphic:MovieClip){
achievement_display.achievementTitle.text = achievement_title;
if (graphic != null){
achievement_graphic = graphic;
achievement_display.graphicAnchor.addChild(achievement_graphic);
};
achievement_display.alpha = 1;
achievement_display_time = achievement_display_fade_time;
}
public function updateAchievement(time:Number){
if (achievement_display_time > 0){
achievement_display_time = (achievement_display_time - time);
if (achievement_display_time < 0){
achievement_display_time = 0;
};
if ((((achievement_display_time == 0)) && (!((achievement_graphic == null))))){
achievement_display.graphicAnchor.removeChild(achievement_graphic);
achievement_graphic = null;
};
achievement_display.alpha = (achievement_display_time / achievement_display_fade_time);
};
}
public function updateEnergy(time:Number, percent:Number){
full_bar.height = (bar_height * percent);
hungry_bar.height = (bar_height * percent);
hungry_bar.alpha = ((1 - percent) * (1 - percent));
}
public function updateLevel(time:Number){
if (level_display_time > 0){
level_display_time = (level_display_time - time);
if (level_display_time < 0){
level_display_time = 0;
};
level_display.alpha = (level_display_time / level_display_fade_time);
};
}
public function warnWebbing(){
webbing_warning.alpha = 1;
spider_webbing_warning.alpha = webbing_warning_alpha_max;
webbing_warning_bar.alpha = 1;
webbing_warning_time = (webbing_warning_solid_time + webbing_warning_fade_time);
}
public function removeGraphics(game:Game){
game["graphics_anchor"].removeChild(webbing_warning_bar);
game["graphics_anchor"].removeChild(webbing_bar);
game["graphics_anchor"].removeChild(webbing_symbol);
game["graphics_anchor"].removeChild(webbing_warning);
game["graphics_anchor"].removeChild(spider_webbing_warning);
game["graphics_anchor"].removeChild(full_bar);
game["graphics_anchor"].removeChild(hungry_bar);
game["graphics_anchor"].removeChild(energy_symbol);
game["graphics_anchor"].removeChild(bonus_webbing_bar);
game["graphics_anchor"].removeChild(level_display);
game["graphics_anchor"].removeChild(achievement_display);
}
public function updateBonusWebbing(time:Number, percent:Number){
bonus_webbing_bar.alpha = percent;
}
public function attachGraphics(game:Game){
game["graphics_anchor"].addChild(webbing_warning_bar);
game["graphics_anchor"].addChild(webbing_bar);
game["graphics_anchor"].addChild(webbing_symbol);
game["graphics_anchor"].addChild(webbing_warning);
game["graphics_anchor"].addChild(spider_webbing_warning);
game["graphics_anchor"].addChild(full_bar);
game["graphics_anchor"].addChild(hungry_bar);
game["graphics_anchor"].addChild(energy_symbol);
game["graphics_anchor"].addChild(bonus_webbing_bar);
game["graphics_anchor"].addChild(level_display);
game["graphics_anchor"].addChild(achievement_display);
}
public function displayLevel(level:String, level_name:String){
level_display.levelNumber.text = level;
level_display.levelName.text = level_name;
level_display.alpha = 1;
level_display_time = level_display_fade_time;
}
}
}//package framework.Spider.UI
Section 123
//WebDrawer (framework.Spider.UI.WebDrawer)
package framework.Spider.UI {
import game.*;
import framework.Geometry.*;
import flash.display.*;
import framework.UserInterface.*;
public class WebDrawer extends Drawer {
public var level_data:LevelData;
public function WebDrawer(pen1:MovieClip, level_data1:LevelData){
super(pen1);
level_data = level_data1;
line_width = level_data.web_width;
line_alpha = level_data.web_alpha;
dot_length = 0.03;
dot_spacing = 0.04;
circle_radius = 8;
circle_alpha = (level_data.web_alpha / 2);
}
override public function convertX(x:Number):Number{
return (level_data.convertX(x));
}
override public function convertY(y:Number):Number{
return (level_data.convertY(y));
}
public function drawWebGuide(start_point:Point, end_point:Point, color:Number){
line_color = color;
line_width = level_data.web_width;
line_alpha = level_data.web_alpha;
dottedLine(start_point, end_point);
circle_color = color;
circle(end_point);
}
}
}//package framework.Spider.UI
Section 124
//StrandCollection (framework.Spider.Web.StrandCollection)
package framework.Spider.Web {
import framework.Geometry.*;
import framework.GeometryGraph.*;
public class StrandCollection extends EdgeCollection {
public function StrandCollection(){
super();
}
public function ():StrandCollection{
return (new StrandCollection());
}
override public function clone():Shape{
return (StrandCollection(super.clone()));
}
}
}//package framework.Spider.Web
Section 125
//Web (framework.Spider.Web.Web)
package framework.Spider.Web {
import game.*;
import framework.Geometry.*;
import flash.display.*;
import audio.*;
import framework.Spider.Bugs.*;
import framework.Spider.Abstract.*;
import framework.Utilities.*;
import framework.GeometryGraph.*;
import framework.Spider.UI.*;
public class Web extends GeoGraph {
public var fire_flies:HashTable;
private var _part_catchables:Array;
public var queen_bees:HashTable;
public var fire_fly_sound_name:String;// = "sfxFireFlyCaught"
public var :HashTable;
public var after_web:MovieClip;
private var _planned_strands:HashTable;
public var fire_fly_sound:SoundHandle;
public var catchables:HashTable;
public var before_web:MovieClip;
public var web_pen:MovieClip;
private var _collapsing_strands:Queue;
public var almost_web:MovieClip;
public var drawer:WebDrawer;
public var game:Game;
public function Web(size:Number, number_parts:Number, level_data:LevelData, game1:Game){
var part_size:*;
var i:*;
var j:*;
= new HashTable();
fire_fly_sound_name = "sfxFireFlyCaught";
super(size, number_parts);
catchables = new HashTable();
_collapsing_strands = new Queue();
_planned_strands = new HashTable();
_part_catchables = new Array();
part_size = getPartLength();
i = 0;
while (i < number_parts) {
_part_catchables[i] = new Array();
j = 0;
while (j < number_parts) {
_part_catchables[i][j] = new HashTable();
j++;
};
i++;
};
game = game1;
before_web = new MovieClip();
almost_web = new MovieClip();
web_pen = new MovieClip();
drawer = new WebDrawer(web_pen, level_data);
after_web = new MovieClip();
fire_flies = new HashTable();
queen_bees = new HashTable();
}
public function getFireFlies():Array{
return (fire_flies.getValues());
}
public function spawnBee(x:Number, y:Number){
var bee:Bee;
bee = new Bee(x, y, this);
addCatchable(bee);
}
public function (web:Web){
var keys:Array;
var i:*;
keys = catchables.getKeys();
i = 0;
while (i < keys.length) {
web.addCatchable(keys[i], Catchable(catchables.getValue(keys[i])));
i++;
};
}
public function hasCatchable(catchable:Catchable):Boolean{
return (catchables.hasKey(catchable.actorKey()));
}
override public function getClosest(point:Point, exact:Boolean):Array{
var closest:Array;
closest = super.getClosest(point, !(exact));
closest[0] = WebEdge(closest[0]);
return (closest);
}
public function deleteCatchable(catchable:Catchable){
var part_ids:*;
var i:*;
catchables.deleteKey(catchable.actorKey());
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
removePartCatchable(catchable, part_ids[i]);
i++;
};
}
public function drawPlannedStrands(){
var strand:WebStrand;
var strands:Array;
var i:*;
strands = _planned_strands.getValues();
i = 0;
while (i < strands.length) {
strand = WebStrand(strands[i]);
drawer.line_color = drawer.level_data.planned_web_color;
drawer.line_width = (drawer.level_data.web_width * 4);
drawer.line_alpha = drawer.level_data.planned_web_alpha;
drawer.line(strand.p1, strand.p2);
i++;
};
}
public function removeFireFly(fire_fly:FireFly){
if (fire_flies.hasKey(fire_fly.actorKey())){
fire_flies.deleteKey(fire_fly.actorKey());
if (fire_flies.getSize() == 0){
fire_fly_sound.Stop();
fire_fly_sound = null;
};
};
}
override public function getIntersections(other:Shape, all_edges:Boolean):EdgeCollection{
var edges:Array;
var edge:GeoEdge;
var intersections:StrandCollection;
var i:*;
var part_ids:Array;
var j:Number;
edges = getCloseEdges(other);
intersections = new StrandCollection();
i = 0;
while (i < edges.length) {
edge = edges[i];
if (((((all_edges) || ((edge is WebStrand)))) && (edge.intercepts(other)))){
if (hasEdge(edge)){
intersections.addEdge(edge);
} else {
trace(("--- Edge part, but no edge! " + edge));
part_ids = getPartIds();
j = 0;
while (j < part_ids.length) {
removePartEdge(edge, part_ids[j]);
j++;
};
};
};
i++;
};
return (intersections);
}
override public function clone():Shape{
var web:Web;
web = newWeb(getSize(), getNumberParts());
populateGraph(web);
return (web);
}
override public function removeEdge(edge:GeoEdge, collapse:Boolean){
var web_strand:*;
var p1:WebNode;
var p2:WebNode;
if (hasEdge(edge)){
super.removeEdge(edge, collapse);
if ((edge is WebStrand)){
web_strand = WebStrand(edge);
if (!web_strand.isDying()){
web_strand.destroy();
};
if (collapse){
p1 = WebNode(getNode(web_strand.p1));
if (p1 != null){
p1.collapse(this);
};
p2 = WebNode(getNode(web_strand.p2));
if (p2 != null){
p2.collapse(this);
};
};
};
};
}
public function hasFireFly():Boolean{
return ((fire_flies.getSize() > 0));
}
public function Draw(){
var edges:Array;
var edge:WebEdge;
var i:*;
edges = getEdges();
i = 0;
while (i < edges.length) {
edge = WebEdge(edges[i]);
edge.Draw(drawer);
i++;
};
}
public function (shape:Shape):Array{
var part_ids:*;
var close_catchables:*;
var part_catchables:*;
var i:*;
var j:*;
part_ids = getPartIds();
close_catchables = new HashTable();
i = 0;
while (i < part_ids.length) {
if (inPart(shape, part_ids[i])){
part_catchables = getPartCatchables(part_ids[i]);
j = 0;
while (j < part_catchables.length) {
close_catchables.setValue(part_catchables[j].getKey(), part_catchables[j]);
j++;
};
};
i++;
};
return (close_catchables.getValues());
}
public function hasPartCatchable(catchable:Catchable, part_id:Array):Boolean{
return (_part_catchables[part_id[0]][part_id[1]].hasKey(catchable.actorKey()));
}
public function getCatchables():Array{
return (catchables.getValues());
}
public function addFireFly(fire_fly:FireFly){
if (!fire_flies.hasKey(fire_fly.actorKey())){
fire_flies.setValue(fire_fly.actorKey(), fire_fly);
if (fire_flies.getSize() == 1){
fire_fly_sound = AudioEngine.PlaySound(fire_fly_sound_name, AudioEngine.SFX_CHANNEL, true);
};
};
}
override public function findPath(start_point:GeoNode, end_point:GeoNode):Path{
var path:Path;
Swarm.prepare();
path = super.findPath(start_point, end_point);
Swarm.collide();
return (path);
}
override public function newEdge(p1:GeoNode, p2:GeoNode):GeoEdge{
return (new WebEdge(WebNode(p1), WebNode(p2)));
}
public function addCollapsingStrand(web_strand:WebStrand){
if (web_strand == null){
_collapsing_strands.push(web_strand);
} else {
if (!web_strand.isCollapsing()){
web_strand.setCollapsing();
_collapsing_strands.push(web_strand);
};
};
}
public function scan(){
var ok:Boolean;
var edges:Array;
var edge:GeoEdge;
var node:GeoNode;
var i:*;
ok = true;
edges = getEdges();
i = 0;
while (i < edges.length) {
edge = edges[i];
if (!hasNode(GeoNode(edge.p1))){
trace(((("!!! Problem: " + edge.p1) + " not in graph, but end point of ") + edge));
ok = false;
};
node = getNode(GeoNode(edge.p1));
if (!node.hasEdge(edge)){
trace(((("!!! Problem: " + node) + " doesn't have ") + edge));
ok = false;
};
if (!hasNode(GeoNode(edge.p2))){
trace(((("!!! Problem: " + edge.p1) + " not in graph, but end point of ") + edge));
ok = false;
};
node = getNode(GeoNode(edge.p2));
if (!node.hasEdge(edge)){
trace(((("!!! Problem: " + node) + " doesn't have ") + edge));
ok = false;
};
i++;
};
if (ok){
trace(" No problems found when scanning.");
};
}
public function newWeb(size:Number, parts:Number):Web{
return (new Web(size, parts));
}
override public function getClosestDirection(origin:Point, target:Point, exact:Boolean):Array{
var closest:Array;
closest = super.getClosestDirection(origin, target, !(exact));
closest[0] = WebEdge(closest[0]);
return (closest);
}
public function removeQueenBee(queen_bee:QueenBee){
if (queen_bees.hasKey(queen_bee.actorKey())){
queen_bees.deleteKey(queen_bee.actorKey());
};
}
private function setPartCatchable(catchable:Catchable, part_id:Array){
if (inPart(catchable.body, part_id)){
_part_catchables[part_id[0]][part_id[1]].setValue(catchable.actorKey(), catchable);
};
}
public function spawnMoth(x:Number, y:Number){
var moth:Moth;
moth = new Moth(x, y, this);
addCatchable(moth);
}
public function hasQueenBee():Boolean{
return ((queen_bees.getSize() > 0));
}
public function addQueenBee(queen_bee:QueenBee){
if (!queen_bees.hasKey(queen_bee.actorKey())){
queen_bees.setValue(queen_bee.actorKey(), queen_bee);
};
}
private function removePartCatchable(catchable:Catchable, part_id:Array){
if (hasPartCatchable(catchable, part_id)){
_part_catchables[part_id[0]][part_id[1]].deleteKey(catchable.actorKey());
};
}
public function collapseStrands(){
var web_strand:WebStrand;
Swarm.prepare();
while (!(_collapsing_strands.isEmpty())) {
web_strand = _collapsing_strands.pop();
if (web_strand == null){
if (!_collapsing_strands.isEmpty()){
game.lowerCollapsingPrecedent();
addCollapsingStrand(null);
};
} else {
removeEdge(web_strand, true);
};
};
game.resetCollapsingPrecedent();
Swarm.collide();
}
override public function newNode(x:Number, y:Number):GeoNode{
return (new WebNode(x, y));
}
public function getQueenBees():Array{
return (queen_bees.getValues());
}
public function removePlannedStrand(web_strand:WebStrand){
if (web_strand != null){
if (_planned_strands.hasKey(web_strand.getKey())){
_planned_strands.deleteKey(web_strand.getKey());
};
};
}
public function getPartCatchables(part_id:Array):Array{
return (_part_catchables[part_id[0]][part_id[1]].getValues());
}
private function
(closest:Array, point:Point):Array{
if (closest[1].getDistanceSquared(closest[0].p1) < 0.001){
closest = [closest[0], closest[0].p1, point.getDistance(closest[0].p1)];
} else {
if (closest[1].getDistanceSquared(closest[0].p2) < 0.001){
closest = [closest[0], closest[0].p2, point.getDistance(closest[0].p2)];
};
};
return (closest);
}
public function addPlannedStrand(web_strand:WebStrand){
_planned_strands.setValue(web_strand.getKey(), web_strand);
}
public function addCatchable(catchable:Catchable){
var part_ids:*;
var i:*;
catchables.setValue(catchable.actorKey(), catchable);
part_ids = getPartIds();
i = 0;
while (i < part_ids.length) {
setPartCatchable(catchable, part_ids[i]);
i++;
};
}
}
}//package framework.Spider.Web
Section 126
//WebEdge (framework.Spider.Web.WebEdge)
package framework.Spider.Web {
import framework.Geometry.*;
import framework.GeometryGraph.*;
import framework.Spider.UI.*;
public class WebEdge extends GeoEdge {
protected var _breakable;// = false
protected var _strength;// = 0
public function WebEdge(n1:WebNode, n2:WebNode){
_breakable = false;
_strength = 0;
super(n1, n2);
_breakable = false;
}
override public function getIntersection(line:Line):Point{
return (WebNode(super.getIntersection(line)));
}
override public function newEdge(n1:GeoNode, n2:GeoNode):GeoEdge{
return (newWebEdge(WebNode(n1), WebNode(n2)));
}
override public function newPoint(x:Number, y:Number):Point{
return (new WebNode(x, y));
}
public function newWebEdge(n1:WebNode, n2:WebNode):WebEdge{
return (new WebEdge(n1, n2));
}
public function getMaxStrength():Number{
return (_strength);
}
override public function clone():Shape{
return (newWebEdge(WebNode(p1.clone()), WebNode(p2.clone())));
}
public function isBreakable():Boolean{
return (_breakable);
}
public function Draw(drawer:WebDrawer){
}
public function getStrength():Number{
return (_strength);
}
override public function getTopPoint():Point{
return (WebNode(super.getTopPoint()));
}
protected function _initializePen(drawer:WebDrawer){
drawer.line_color = drawer.level_data.edge_color;
drawer.line_width = drawer.level_data.edge_width;
drawer.line_alpha = drawer.level_data.edge_alpha;
}
override public function getNormalPoint(point:Point):Point{
return (WebNode(super.getNormalPoint(point)));
}
}
}//package framework.Spider.Web
Section 127
//WebNode (framework.Spider.Web.WebNode)
package framework.Spider.Web {
import framework.Geometry.*;
import framework.Spider.Abstract.*;
import framework.Utilities.*;
import framework.GeometryGraph.*;
public class WebNode extends GeoNode {
private var _collapsing:Boolean;// = false
public static var debug_output:Boolean = false;
public function WebNode(x:Number, y:Number){
_collapsing = false;
super(x, y);
_collapsing = false;
}
public function collapseStrands(web:Web){
var edges:Array;
var web_strand:WebStrand;
var i:*;
edges = getEdges();
Swarm.prepare();
_collapsing = true;
i = 0;
while (i < edges.length) {
web_strand = WebStrand(edges[i]);
web.game.addCollapsingStrand(web_strand, WebNode(web_strand.getOtherPoint(this)));
web.addCollapsingStrand(web_strand);
i++;
};
Swarm.collide();
}
public function hasUnbreakableEdge():Boolean{
var edges:Array;
var i:*;
edges = getEdges();
i = 0;
while (i < edges.length) {
if (!edges[i].isBreakable()){
return (true);
};
i++;
};
return (false);
}
public function ():WebEdge{
if (hasEdges()){
return (WebEdge(super.getNextEdge()));
};
return (null);
}
override public function clone():Shape{
return (newWebNode(x, y));
}
public function doutput(message:String){
if (debug_output){
trace(message);
};
}
public function collapse(web:Web){
var number_edges:Number;
var edges:Array;
var strength:Number;
var new_edge:WebEdge;
var sorted_angles:PriorityQueue;
var angle:Number;
var i:*;
var first_angle:Number;
var last_angle:Number;
var current_angle:Number;
var difference:Number;
var greatest_angle:Number;
if (!isCollapsing()){
doutput(("x.^ " + toString()));
number_edges = numberEdges();
if (number_edges > 10){
return;
};
edges = getEdges();
if ((((number_edges == 1)) && (!(hasUnbreakableEdge())))){
doutput(("x1 " + toString()));
collapseStrands(web);
} else {
if (number_edges == 2){
if ((((((Math.abs((edges[0].getAngle() - edges[1].getAngle())) < 0.001)) && (!(WebNode(web.getNode(edges[0].getOtherPoint(this))).isCollapsing())))) && (!(WebNode(web.getNode(edges[1].getOtherPoint(this))).isCollapsing())))){
Swarm.prepare();
doutput(((((("x2/ " + toString()) + ": ") + edges[0]) + ", ") + edges[1]));
doutput(((((("x " + toString()) + ": ") + web.getNode(edges[0].getOtherPoint(this))) + " collapsing: ") + WebNode(web.getNode(edges[0].getOtherPoint(this))).isCollapsing()));
doutput(((((("x " + toString()) + ": ") + web.getNode(edges[1].getOtherPoint(this))) + " collapsing: ") + WebNode(web.getNode(edges[1].getOtherPoint(this))).isCollapsing()));
web.removeEdge(edges[0], false);
web.removeEdge(edges[1], false);
strength = ((edges[0].getMaxStrength() + edges[1].getMaxStrength()) / 2);
if ((edges[0] is WebStrand)){
new_edge = edges[0].newWebStrand(edges[0].getOtherPoint(this), edges[1].getOtherPoint(this), strength);
} else {
new_edge = edges[0].newEdge(edges[0].getOtherPoint(this), edges[1].getOtherPoint(this));
};
web.addEdge(new_edge);
Swarm.collide();
} else {
if (!hasUnbreakableEdge()){
doutput(((((("x2> " + toString()) + ": ") + edges[0]) + ", ") + edges[1]));
collapseStrands(web);
};
};
} else {
if (!hasUnbreakableEdge()){
sorted_angles = new PriorityQueue();
i = 0;
while (i < edges.length) {
if (equals(edges[i].getTopPoint())){
angle = (edges[i].getAngle() + Math.PI);
} else {
angle = edges[i].getAngle();
};
sorted_angles.push(angle, angle);
i++;
};
while (!(sorted_angles.isEmpty())) {
current_angle = Number(sorted_angles.pop());
if (isNaN(first_angle)){
first_angle = current_angle;
last_angle = current_angle;
} else {
difference = Math.abs((current_angle - last_angle));
if (((isNaN(greatest_angle)) || ((difference > greatest_angle)))){
greatest_angle = difference;
};
last_angle = current_angle;
};
};
difference = Math.abs((last_angle - (first_angle - (2 * Math.PI))));
if (((isNaN(greatest_angle)) || ((difference > greatest_angle)))){
greatest_angle = difference;
};
if ((greatest_angle - 0.1) > Math.PI){
doutput(("x3> " + toString()));
collapseStrands(web);
};
};
};
};
doutput(("x.v " + toString()));
};
}
public function isCollapsing():Boolean{
return (_collapsing);
}
public function newWebNode(x:Number, y:Number):WebNode{
return (new WebNode(x, y));
}
}
}//package framework.Spider.Web
Section 128
//WebStrand (framework.Spider.Web.WebStrand)
package framework.Spider.Web {
import framework.Geometry.*;
import framework.Action.*;
import framework.Spider.Abstract.*;
import framework.Utilities.*;
import framework.GeometryGraph.*;
import framework.Spider.UI.*;
public class WebStrand extends WebEdge {
private var _dying:Boolean;// = false
private var _actors:HashTable;// = null
private var _pivot:WebNode;
private var _collapsing_dx:Number;
private var _collapsing_dy:Number;
private var _collapsing_pivot:WebNode;
private var _collapsing_y_target:Number;
private var _collapsing:Boolean;// = false
private var _collapsing_mode:Number;
private var _free_node:WebNode;
private var _collapsing_free_node:WebNode;
public function WebStrand(n1:WebNode, n2:WebNode, strength:Number){
_collapsing = false;
_free_node = new WebNode(0, 0);
_pivot = new WebNode(0, 0);
_actors = null;
_dying = false;
super(n1, n2);
_requires_fastening = true;
_actors = new HashTable();
_breakable = true;
_strength = strength;
}
public function setCollapsingPivot(web_node:WebNode){
if (web_node == null){
return;
};
if (!hasEndPoint(web_node)){
throw (Exception(((web_node + " cannot be the pivot of ") + toString())));
};
_collapsing_pivot = web_node;
_collapsing_free_node = WebNode(getOtherPoint(web_node).clone());
}
public function destroy(){
var actors:*;
var i:*;
_dying = true;
Swarm.prepare();
actors = getActors();
i = 0;
while (i < actors.length) {
if (!actors[i].isDying()){
Swarm.addSwarmer(actors[i]);
};
i++;
};
Swarm.collide();
}
public function deleteActor(actor:Actor){
if (hasActor(actor)){
_actors.deleteKey(actor.actorKey());
};
}
public function drawCollapsing(drawer:WebDrawer, precedence:Number){
var inverse_precedence:Number;
var inverse_pi_halved:*;
var inverse_precedence_squared:Number;
drawer.line_color = drawer.level_data.getWebColor(getStrength());
drawer.line_width = drawer.level_data.web_width;
drawer.line_alpha = (drawer.level_data.web_alpha / 2);
if (_collapsing_pivot != null){
_pivot.x = _collapsing_pivot.x;
_pivot.y = _collapsing_pivot.y;
_free_node.x = _collapsing_free_node.x;
_free_node.y = _collapsing_free_node.y;
} else {
_pivot.x = p1.x;
_pivot.y = p1.y;
_free_node.x = p2.x;
_free_node.y = p2.y;
};
if (isNaN(_collapsing_mode)){
setupCollapsing();
};
if (precedence < 1){
inverse_precedence = (1 - precedence);
drawer.line_alpha = (drawer.line_alpha * precedence);
if (_collapsing_mode == 0){
} else {
if (_collapsing_mode == 1){
inverse_pi_halved = ((inverse_precedence * Math.PI) / 2);
_free_node.x = (_collapsing_pivot.x + (_collapsing_dx * Math.cos(inverse_pi_halved)));
_free_node.y = (_collapsing_free_node.y + (_collapsing_dy * Math.sin(inverse_pi_halved)));
if ((((((_pivot.x > _collapsing_free_node.x)) && ((_free_node.x > _pivot.x)))) || ((((_pivot.x < _collapsing_free_node.x)) && ((_free_node.x < _pivot.x)))))){
_free_node.x = _collapsing_pivot.x;
_collapsing_free_node.x = _free_node.x;
_collapsing_free_node.y = _free_node.y;
setupCollapsing();
};
} else {
if (_collapsing_mode == 2){
inverse_precedence_squared = (inverse_precedence * inverse_precedence);
_free_node.y = (_collapsing_free_node.y + (0.2 * inverse_precedence_squared));
if (_free_node.y > _collapsing_y_target){
_free_node.y = _collapsing_y_target;
_collapsing_free_node.y = _free_node.y;
setupCollapsing();
};
};
};
};
};
drawer.line(_pivot, _free_node);
}
public function hasActor(actor:Actor):Boolean{
return (_actors.hasKey(actor.actorKey()));
}
public function getActors():Array{
return (_actors.getValues());
}
public function setupCollapsing(){
if (_collapsing_pivot == null){
_collapsing_mode = 0;
} else {
if (_collapsing_pivot.x == _collapsing_free_node.x){
_collapsing_mode = 0;
} else {
if (_collapsing_pivot.y <= _collapsing_free_node.y){
_collapsing_mode = 1;
_collapsing_dy = ((_collapsing_pivot.y + getLength()) - _collapsing_free_node.y);
_collapsing_dx = (_collapsing_free_node.x - _collapsing_pivot.x);
} else {
_collapsing_mode = 2;
_collapsing_y_target = (_collapsing_pivot.y - (_collapsing_free_node.y - _collapsing_pivot.y));
};
};
};
}
public function isDying():Boolean{
return (_dying);
}
public function setCollapsing(){
_collapsing = true;
}
override public function getStrength():Number{
var strength:*;
var actors:*;
var i:*;
strength = _strength;
actors = getActors();
i = 0;
while (i < actors.length) {
strength = (strength - actors[i].getDamage());
i++;
};
return (strength);
}
public function (actor:Actor):Actor{
if (hasActor(actor)){
return (Actor(_actors.getValue(actor.actorKey())));
};
return (null);
}
public function newWebStrand(p1:WebNode, p2:WebNode, strength:Number):WebStrand{
return (new WebStrand(p1, p2, strength));
}
public function addActor(actor:Actor){
if (!hasActor(actor)){
_actors.setValue(actor.actorKey(), actor);
};
}
override public function clone():Shape{
return (newWebStrand(WebNode(p1.clone()), WebNode(p2.clone()), _strength));
}
override public function Draw(drawer:WebDrawer){
_initializePen(drawer);
drawer.line(p1, p2);
}
override protected function _initializePen(drawer:WebDrawer){
drawer.line_color = drawer.level_data.getWebColor(getStrength());
drawer.line_width = drawer.level_data.web_width;
drawer.line_alpha = drawer.level_data.web_alpha;
}
public function isCollapsing():Boolean{
return (_collapsing);
}
override public function newEdge(n1:GeoNode, n2:GeoNode):GeoEdge{
return (newWebStrand(WebNode(n1), WebNode(n2), _strength));
}
}
}//package framework.Spider.Web
Section 129
//Drawer (framework.UserInterface.Drawer)
package framework.UserInterface {
import framework.Geometry.*;
import flash.display.*;
public class Drawer {
public var dot_spacing:Number;
public var line_alpha:Number;
public var line_color:Number;
public var pen:MovieClip;
public var dot_length:Number;
public var circle_radius:Number;
public var circle_alpha:Number;
public var circle_color:Number;
public var line_width:Number;
public function Drawer(pen1:MovieClip){
super();
pen = pen1;
}
public function line(start_point:Point, end_point:Point){
pen.graphics.lineStyle(line_width, line_color, line_alpha);
pen.graphics.moveTo(convertX(start_point.x), convertY(start_point.y));
pen.graphics.lineTo(convertX(end_point.x), convertY(end_point.y));
}
public function convertX(x:Number):Number{
return (x);
}
public function convertY(y:Number):Number{
return (y);
}
public function circle(point:Point){
pen.graphics.lineStyle(circle_radius, circle_color, circle_alpha);
pen.graphics.moveTo(convertX(point.x), convertY(point.y));
pen.graphics.lineTo(convertX((point.x + 0.001)), convertY((point.y + 0.001)));
}
public function dottedLine(start_point:Point, end_point:Point){
var dx:Number;
var dy:Number;
var normal:Number;
var horizontal:Boolean;
var above:Boolean;
var current_point:Point;
pen.graphics.lineStyle(line_width, line_color, line_alpha);
dx = (end_point.x - start_point.x);
dy = (end_point.y - start_point.y);
normal = Math.sqrt(((dy * dy) + (dx * dx)));
dx = (dx / normal);
dy = (dy / normal);
horizontal = (start_point.y == end_point.y);
if (horizontal){
above = (start_point.x > end_point.x);
} else {
above = (start_point.y > end_point.y);
};
current_point = start_point.clone();
while (true) {
if (horizontal){
if (((((above) && ((current_point.x <= end_point.x)))) || (((!(above)) && ((end_point.x <= current_point.x)))))){
break;
};
} else {
if (((((above) && ((current_point.y <= end_point.y)))) || (((!(above)) && ((end_point.y <= current_point.y)))))){
break;
};
};
pen.graphics.moveTo(convertX(current_point.x), convertY(current_point.y));
current_point.x = (current_point.x + (dx * dot_length));
current_point.y = (current_point.y + (dy * dot_length));
if (horizontal){
if (((((above) && ((current_point.x <= end_point.x)))) || (((!(above)) && ((end_point.x <= current_point.x)))))){
break;
};
} else {
if (((((above) && ((current_point.y <= end_point.y)))) || (((!(above)) && ((end_point.y <= current_point.y)))))){
break;
};
};
pen.graphics.lineTo(convertX(current_point.x), convertY(current_point.y));
current_point.x = (current_point.x + (dx * dot_spacing));
current_point.y = (current_point.y + (dy * dot_spacing));
};
}
}
}//package framework.UserInterface
Section 130
//GameMouse (framework.UserInterface.GameMouse)
package framework.UserInterface {
public class GameMouse {
public var down_time:Number;
public var target:Object;
public var up_x:Number;
public var up_y:Number;
public var dragging:Object;
public var drag_distance_squared:Number;// = 0.001
public var down_y:Number;
public var down:Boolean;
public var click_time:Number;
public var :Number;// = 100
public var up_time:Number;
public var down_x:Number;
public var y:Number;
public var x:Number;
public function GameMouse(){
= 100;
drag_distance_squared = 0.001;
super();
x = NaN;
y = NaN;
down_x = NaN;
down_y = NaN;
down = false;
down_time = NaN;
up_x = NaN;
up_y = NaN;
up_time = NaN;
dragging = null;
click_time = NaN;
target = null;
}
public function toString(){
return ((((("(" + x) + ", ") + y) + ")"));
}
}
}//package framework.UserInterface
Section 131
//UI (framework.UserInterface.UI)
package framework.UserInterface {
public class UI {
public var x:Number;
public var y:Number;
public function UI(){
super();
x = 0;
y = 0;
}
}
}//package framework.UserInterface
Section 132
//HashTable (framework.Utilities.HashTable)
package framework.Utilities {
public class HashTable {
private var _values:Array;// = null
private var _count;// = 0
private var _dirty;// = true
private var _contents:Array;// = null
private var _keys:Array;// = null
public function HashTable(){
_contents = null;
_count = 0;
_dirty = true;
_keys = null;
_values = null;
super();
_contents = new Array();
_count = 0;
_dirty = true;
_keys = new Array();
_values = new Array();
}
public function hasKey(key:String):Boolean{
return (!((_contents[key] == undefined)));
}
public function getKeys():Array{
return (_keys);
}
public function deleteKey(key:String){
var temp:Array;
var i:*;
if (!hasKey(key)){
throw (new Error(("Cannot delete nonexisting key: " + key)));
};
_contents[key] = undefined;
_count--;
_dirty = true;
temp = new Array();
i = 0;
while (i < _keys.length) {
if (_keys[i] != key){
temp.push(_keys[i]);
};
i++;
};
_keys = temp;
}
public function setValue(key:String, value:Object){
if (!hasKey(key)){
_count++;
_keys.push(key);
};
_contents[key] = value;
_dirty = true;
}
public function getSize(){
return (_count);
}
public function getValues():Array{
var temp:Array;
var i:*;
if (_dirty){
temp = new Array();
i = 0;
while (i < _keys.length) {
temp.push(getValue(_keys[i]));
i++;
};
_values = temp;
_dirty = false;
};
return (_values);
}
public function getValue(key:String):Object{
if (!hasKey(key)){
throw (new Error(("Cannot get value for nonexisting key: " + key)));
};
return (_contents[key]);
}
}
}//package framework.Utilities
Section 133
//ListItem (framework.Utilities.ListItem)
package framework.Utilities {
public class ListItem {
private var _next:ListItem;
private var _content:Object;
public function ListItem(content:Object){
super();
_content = content;
_next = null;
}
public function getContent():Object{
return (_content);
}
public function getNext():ListItem{
return (_next);
}
public function setNext(next:ListItem){
_next = next;
}
}
}//package framework.Utilities
Section 134
//PriorityQueue (framework.Utilities.PriorityQueue)
package framework.Utilities {
public class PriorityQueue {
private var _count:Number;
private var _contents:Array;// = null
public function PriorityQueue(){
_contents = null;
super();
_contents = new Array();
_count = 0;
}
public function isEmpty():Boolean{
return ((_count == 0));
}
public function ():Number{
return (getValue(0));
}
private function getContent(id:Number):Object{
if (isIdLegal(id)){
return (_contents[id][1]);
};
return (null);
}
public function nodeToString(id):String{
return ((((("[" + getValue(id)) + ", ") + getContent(id)) + "]"));
}
public function pop():Object{
var best_content:*;
if (isEmpty()){
return (null);
};
best_content = getContent(0);
_count--;
_contents[0] = _contents[_count];
_contents[_count] = null;
sinkDown(0);
return (best_content);
}
private function isIdLegal(id:Number):Boolean{
return ((id < _count));
}
private function sinkDown(id:Number){
var left_child_id:*;
var switch_id:*;
var switch_value:*;
var left_child_value:*;
var right_child_id:*;
var right_child_value:*;
var temp:*;
left_child_id = getLeftChildId(id);
if (isNaN(left_child_id)){
return;
};
left_child_value = getValue(left_child_id);
right_child_id = getRightChildId(id);
if (isNaN(right_child_id)){
switch_id = left_child_id;
switch_value = left_child_value;
} else {
right_child_value = getValue(right_child_id);
if (left_child_value > right_child_value){
switch_id = left_child_id;
switch_value = left_child_value;
} else {
switch_id = right_child_id;
switch_value = right_child_value;
};
};
if (switch_value > getValue(id)){
temp = _contents[id];
_contents[id] = _contents[switch_id];
_contents[switch_id] = temp;
sinkDown(switch_id);
};
}
public function testOrderId(id:Number):Boolean{
var val:*;
var left_child_id:*;
var right_child_id:*;
val = getValue(id);
left_child_id = getLeftChildId(id);
if (!isNaN(left_child_id)){
if (val < getValue(left_child_id)){
return (false);
};
if (!testOrderId(left_child_id)){
return (false);
};
};
right_child_id = getRightChildId(id);
if (!isNaN(right_child_id)){
if (val < getValue(right_child_id)){
return (false);
};
if (!testOrderId(right_child_id)){
return (false);
};
};
return (true);
}
private function getRightChildId(id:Number):Number{
var child_id:*;
child_id = ((2 * id) + 2);
if (isIdLegal(child_id)){
return (child_id);
};
return (NaN);
}
private function getLeftChildId(id:Number):Number{
var child_id:*;
child_id = ((2 * id) + 1);
if (isIdLegal(child_id)){
return (child_id);
};
return (NaN);
}
private function getParentId(id:Number):Number{
if (id == 0){
return (NaN);
};
return (Math.floor(((id - 1) / 2)));
}
public function ():Boolean{
if (isEmpty()){
return (true);
};
return (testOrderId(0));
}
private function floatUp(id:Number){
var parent_id:*;
var temp:*;
if (id == 0){
return;
};
parent_id = getParentId(id);
if (getValue(parent_id) < getValue(id)){
temp = _contents[parent_id];
_contents[parent_id] = _contents[id];
_contents[id] = temp;
floatUp(parent_id);
};
}
private function makeNode(value:Number, content:Object):Array{
return ([value, content]);
}
public function push(value:Number, content:Object){
var new_id:*;
new_id = _count;
_count++;
_contents[new_id] = makeNode(value, content);
floatUp(new_id);
}
public function idToString(id:Number):String{
var string:*;
var left_child_id:*;
var right_child_id:*;
string = (nodeToString(id) + ": (");
left_child_id = getLeftChildId(id);
if (!isNaN(left_child_id)){
string = (string + idToString(left_child_id));
string = (string + ", ");
};
right_child_id = getRightChildId(id);
if (!isNaN(right_child_id)){
string = (string + idToString(right_child_id));
};
string = (string + ")");
return (string);
}
public function toString():String{
if (isEmpty()){
return ("");
};
return (idToString(0));
}
private function getValue(id:Number):Number{
if (isIdLegal(id)){
return (_contents[id][0]);
};
return (NaN);
}
}
}//package framework.Utilities
Section 135
//Queue (framework.Utilities.Queue)
package framework.Utilities {
public class Queue {
private var _length:Number;
private var _first:ListItem;
private var _last:ListItem;
public function Queue(){
super();
_first = null;
_last = null;
_length = 0;
}
public function isEmpty():Boolean{
return ((_first == null));
}
public function pop():Object{
var content:Object;
content = peek();
_first = _first.getNext();
_length--;
if (isEmpty()){
_last = null;
};
return (content);
}
public function push(object:Object){
var item:ListItem;
item = new ListItem(object);
if (isEmpty()){
_first = item;
_last = item;
} else {
_last.setNext(item);
_last = item;
};
_length++;
}
public function peek():Object{
if (isEmpty()){
throw (new Error("No contents to pop."));
};
return (_first.getContent());
}
public function getLength():Number{
return (_length);
}
}
}//package framework.Utilities
Section 136
//Game (game.Game)
package game {
import framework.Spider.Web.*;
import framework.Spider.Environments.*;
import framework.Geometry.*;
import flash.events.*;
import flash.display.*;
import audio.*;
import framework.Spider.Bugs.*;
import framework.Utilities.*;
import framework.Spider.UI.*;
import framework.Spider.Tutorials.*;
import framework.UserInterface.*;
import achievements.*;
import security.*;
import performance.*;
import adserver.*;
import framework.Spider.Environments.Moon.*;
import framework.Spider.Actions.*;
import flash.ui.*;
import flash.utils.*;
public dynamic class Game extends MovieClip {
private var :Number;// = 0
private var mLastDifficultyChange:Number;// = 0
public var environment:Environment;
private var testing:Boolean;// = false
public var spawnCheat:Boolean;// = false
private var mPaused:Boolean;// = false
private var :Number;// = 30
private var mLevelCount:Number;// = 0
public var cancel_actions:Boolean;// = false
private var :Number;// = 90
private var i;// = 0
private var mAmbientSound:SoundHandle;// = null
private var debug_output:Boolean;// = false
public var gMouse:GameMouse;
public var mLastDifficultyTime:Number;
public var collapsing_web:Boolean;// = false
public var tutorial_container:MovieClip;
private var tutorial_tracing:Boolean;// = false
public var spider:Spider;
public var unseen_tutorials:HashTable;
private var mAmbientOwl1Timer:Timer;
public var :Number;// = 0
public var unseen_achievements:HashTable;
public var collapsing_precedent:Number;// = 0
private var mGameRunTime:Number;// = 0
private var
:Number;// = 1
public var mLastEnemyTime:Number;
private var
:Array;
private var mLastGameTimeStat:Number;// = 0
public var collapsing_strands:Queue;
private var mLastPowerupSpawn:Number;// = 0
private var :Number;// = 6
private var mLastUpdate:Number;// = 0
private var input_tracing:Boolean;// = false
public var web:Web;
public var current_tutorial:Tutorial;
private var mGameOver:Boolean;// = false
public var level_data:LevelData;
private var :Object;
public var display_tutorials:Boolean;// = true
private var mAmbientOwl2Timer:Timer;
private var :Number;// = 0
private var mLastPowerupLocations:Array;
private var :Number;// = 1.5
private var mDifficultyIndex:Number;// = 0
private var mPlayer:MovieClip;
private var
:Array;
private var mMusic:SoundHandle;// = null
private var
:Boolean;// = false
private var mSpawnArray:Array;// = null
public var displayPoint:Boolean;// = false
public var art_mode:Boolean;// = false
private static var sLevel2:Array = new Array(new Array("PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle"));
private static var sLevel4:Array = new Array(new Array("PyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "PyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "PyramidObstacle"));
private static var sLevel6:Array = new Array(new Array("PyramidObstacle", "LargePyramidObstacle", "FatPyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "FatPyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle"));
private static var sLevel8:Array = new Array(new Array("FlashMine", "FlashMine", "PyramidObstacle", "FlashMine", "PyramidObstacle", "FlashMine", "FlashMine", "PyramidObstacle", "FlashMine", "FlashMine"));
private static var sLevel3:Array = new Array(new Array("PyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "PyramidObstacle", "LargePyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "PyramidObstacle"));
private static var sLevel5:Array = new Array(new Array("FatPyramidObstacle", "PyramidObstacle", "FatPyramidObstacle", "PyramidObstacle", "FatPyramidObstacle", "FatPyramidObstacle", "FatPyramidObstacle"));
private static var sLevel7:Array = new Array(new Array("FlashMine", "FlashMine", "FlashMine", "FlashMine", "FlashMine", "FlashMine"));
private static var sLevel9:Array = new Array(new Array("PyramidObstacle", "LargePyramidObstacle", "FatPyramidObstacle", "PyramidObstacle", "PyramidObstacle", "FlashMine", "PyramidObstacle", "FatPyramidObstacle", "LargePyramidObstacle", "PyramidObstacle", "PyramidObstacle"));
private static var sLevel1:Array = new Array(new Array("PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle", "PyramidObstacle"));
private static var sClipDepth:Number = 10;
private static var sPowerupSpawnRate10:Number = 3;
private static var sPowerupSpawnRate11:Number = 1;
private static var sEnemyID:Number = 0;
private static var sLevel10:Array = new Array(new Array("FatPyramidObstacle", "LargePyramidObstacle", "FatPyramidObstacle", "LargePyramidObstacle", "FatPyramidObstacle", "LargePyramidObstacle", "FatPyramidObstacle", "LargePyramidObstacle", "FlashMine", "FlashMine"));
private static var sLevel11:Array = new Array(new Array());
private static var sPowerupProbabilities10:Array = new Array(0.2, 0.2, 0.2, 0.2);
private static var sPowerupProbabilities11:Array = new Array(0.4, 0.3, 0, 0.1);
private static var sPowerupID:Number = 0;
private static var sPowerupProbabilities1:Array = new Array(0.9, 0, 0);
private static var sPowerupProbabilities2:Array = new Array(0.5, 0.4, 0);
private static var sPowerupProbabilities3:Array = new Array(0.7, 0.3);
private static var sPowerupProbabilities4:Array = new Array(0.6, 0.1, 0.2);
private static var sPowerupProbabilities5:Array = new Array(0, 0.8, 0, 0.2);
private static var sPowerupProbabilities6:Array = new Array(0, 0.7, 0.2, 0.1);
private static var sPowerupProbabilities7:Array = new Array(0.4, 0.2, 0.1, 0.1);
private static var sPowerupProbabilities8:Array = new Array(0.3, 0.5, 0, 0);
private static var sPowerupProbabilities9:Array = new Array(0, 0.8, 0, 0.1);
private static var sPowerupSpawnRate1:Number = 3;
private static var sPowerupSpawnRate2:Number = 3;
private static var sPowerupSpawnRate3:Number = 3;
private static var sPowerupSpawnRate4:Number = 3;
private static var sFXID:Number = 0;
private static var sPowerupSpawnRate6:Number = 3;
private static var sPowerupSpawnRate7:Number = 1;
private static var sPowerupSpawnRate8:Number = 3;
private static var sPowerupSpawnRate9:Number = 3;
private static var sPowerupSpawnRate5:Number = 3;
private static var sExplosionID:Number = 0;
public function Game(){
= 90;
= 30;
= 6;
= 1.5;
mGameOver = false;
mPaused = false;
= new Object();
mLastUpdate = 0;
mGameRunTime = 0;
mLastGameTimeStat = 0;
mLastDifficultyChange = 0;
mDifficultyIndex = 0;
mLevelCount = 0;
= 0;
= 0;
mSpawnArray = null;
= 1;
mLastPowerupSpawn = 0;
mLastPowerupLocations = new Array();
art_mode = false;
spawnCheat = false;
cancel_actions = false;
displayPoint = false;
tutorial_container = new MovieClip();
display_tutorials = true;
= 0;
collapsing_web = false;
collapsing_precedent = 0;
collapsing_strands = new Queue();
i = 0;
testing = false;
debug_output = false;
input_tracing = false;
tutorial_tracing = false;
= false;
mAmbientSound = null;
mMusic = null;
= new Array(1, 2, 3, 4, 8, 5, 6, 9, 7, 9, 10, 11);
super();
art_mode = (root.gGameMode == 2);
mLastUpdate = getTimer();
mLastPowerupSpawn = mLastUpdate;
mLastDifficultyChange = mLastUpdate;
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
stage.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
MemoryCrypto.setValue("score", 0);
}
private function updateOwlSound(){
if (Math.random() <= 0.5){
updateOwl2Sound();
} else {
updateOwl1Sound();
};
}
public function handleKeyUp(event:KeyboardEvent):void{
var code:Number;
ioutput("^^^ KeyUp.");
code = event.charCode;
if (code == char("b")){
if (((testing) || (art_mode))){
spawnCheat = false;
};
} else {
if (code == Keyboard.SPACE){
spider.cancelActions();
};
};
ioutput("vvv KeyUp.");
}
public function ():Number{
return (sClipDepth++);
}
public function tutorialContinue(event:MouseEvent):void{
toutput((" ^ Continuing after " + current_tutorial));
tutorial_container.removeChild(current_tutorial.window);
TogglePause();
if (!current_tutorial.close(this)){
current_tutorial = null;
};
toutput((" v Continuing after " + current_tutorial));
}
private function setupSounds(){
setupOwl1Sound();
setupOwl2Sound();
updateOwlSound();
setupCricketSound();
updateCricketSound();
}
private function displayDragging():void{
var mousePoint:WebNode;
var dragging:WebNode;
if (((isDraggingDistance()) && (!((gMouse.dragging == Object(undefined)))))){
Mouse.hide();
mousePoint = getMousePoint();
dragging = WebNode(gMouse.dragging);
web.drawer.drawWebGuide(dragging, mousePoint, level_data.getWebColor(spider.webstrength));
} else {
Mouse.show();
};
}
public function
(){
collapsing_precedent--;
if (collapsing_precedent < 0){
collapsing_precedent = 0;
};
}
public function ():void{
}
public function setupAchievements(){
var achievement:Object;
unseen_achievements = new HashTable();
achievement = new Object();
achievement.id = 4;
achievement.title = "Fly Trap";
achievement.description = "Eat 25 flies.";
achievement.graphic = new AchievementIcon1();
achievement.graphic.gotoAndStop(2);
unseen_achievements.setValue(achievement.id, achievement);
Achievements.SetAchievement(achievement.id, achievement.title, achievement.description);
achievement = new Object();
achievement.id = 5;
achievement.title = "Burning Spider";
achievement.description = "Eat 10 fire flies.";
achievement.graphic = new AchievementIcon2();
achievement.graphic.gotoAndStop(2);
unseen_achievements.setValue(achievement.id, achievement);
Achievements.SetAchievement(achievement.id, achievement.title, achievement.description);
achievement = new Object();
achievement.id = 6;
achievement.title = "Godlike Invertebrate";
achievement.description = "Eat a bat.";
achievement.graphic = new AchievementIcon3();
achievement.graphic.gotoAndStop(2);
unseen_achievements.setValue(achievement.id, achievement);
Achievements.SetAchievement(achievement.id, achievement.title, achievement.description);
}
public function setupGraphics(){
environment.attachBackground(this);
this["graphics_anchor"].addChild(web.before_web);
environment.attachFrame(this);
this["graphics_anchor"].addChild(web.almost_web);
this["graphics_anchor"].addChild(web.web_pen);
spider.addGraphics(this["graphics_anchor"]);
spider.ui.attachGraphics(this);
this["graphics_anchor"].addChild(web.after_web);
this["graphics_anchor"].addChild(tutorial_container);
}
public function handleKeyDown(event:KeyboardEvent):void{
var code:Number;
ioutput("^^^ KeyDown.");
code = event.charCode;
if ((((code == Keyboard.ENTER)) || ((code == char("p"))))){
if (current_tutorial == null){
TogglePause();
TogglePauseDisplay();
};
} else {
if (code == Keyboard.SPACE){
cancel_actions = true;
} else {
if (code == char("s")){
if (testing){
spawnBug();
};
} else {
if (code == char("b")){
if (((testing) || (art_mode))){
spawnCheat = true;
};
} else {
if (code == char("d")){
if (testing){
displayPoint = true;
};
} else {
if (code == char("t")){
if (testing){
trace("... Scanning ...");
web.scan();
};
} else {
if (testing){
trace(("Key: " + code));
};
};
};
};
};
};
};
ioutput("vvv KeyDown.");
}
public function turnOffTutorialsAndContinue(event:MouseEvent):void{
turnOffTutorials();
tutorialContinue(event);
if (current_tutorial != null){
current_tutorial = null;
};
}
public function displayTutorial(tutorial_id:String){
if (unseen_tutorials.hasKey(tutorial_id)){
if (display_tutorials){
toutput((" ^ Displaying tutorial: " + tutorial_id));
TogglePause();
Mouse.show();
current_tutorial = unseen_tutorials.getValue(tutorial_id);
tutorial_container.addChild(current_tutorial.window);
toutput((" v Displaying tutorial: " + tutorial_id));
};
unseen_tutorials.deleteKey(tutorial_id);
};
}
public function doutput(message:String){
if (debug_output){
trace(message);
};
}
private function toutput(info:String){
if (tutorial_tracing){
trace(info);
};
}
private function setupOwl2Sound(){
mAmbientOwl2Timer = new Timer(4000, 0);
mAmbientOwl2Timer.addEventListener(TimerEvent.TIMER, playOwl2Sound);
}
public function
():Object{
var mousePoint:*;
var actors:Array;
var i:*;
var closest:*;
if (((!((gMouse.x == Number(undefined)))) && (!((gMouse.y == Number(undefined)))))){
mousePoint = new Point(gMouse.x, gMouse.y);
if (spawnCheat){
return (mousePoint);
};
actors = web.getCatchables();
i = 0;
while (i < actors.length) {
if ((actors[i] is Prey)){
if (mousePoint.intercepts(Prey(actors[i]).body)){
return (actors[i]);
};
};
i++;
};
closest = web.getClosest(mousePoint, false);
if (closest[2] < 0.1){
return (closest[1]);
};
} else {
return (undefined);
};
}
public function awardAchievement(id:Number){
var achievement:Object;
if (unseen_achievements.hasKey(id)){
achievement = unseen_achievements.getValue(id);
unseen_achievements.deleteKey(id);
spider.ui.displayAchievement(achievement.title, achievement.graphic);
Achievements.CompletedAchievement(achievement.id);
};
}
private function (radius:Number):Circle{
var mousePoint:WebNode;
var mouseCircle:Circle;
if (radius == Number(undefined)){
radius = 0.025;
};
mousePoint = getMousePoint();
mouseCircle = new Circle(mousePoint, radius);
return (mouseCircle);
}
public function addCollapsingStrand(web_strand:WebStrand, pivot:WebNode){
web_strand.setCollapsingPivot(pivot);
collapsing_strands.push([collapsing_precedent, web_strand]);
}
public function ioutput(message:String){
if (input_tracing){
trace(message);
};
}
private function setupCricketSound(){
mAmbientCricketTimer = new Timer(10000, 0);
mAmbientCricketTimer.addEventListener(TimerEvent.TIMER, playCricketSound);
}
public function handleMouseMove(event:MouseEvent):void{
ioutput("^^^ MouseMove.");
if (mGameOver){
return;
};
gMouse.x = level_data.unconvertX(event.stageX);
gMouse.y = level_data.unconvertY(event.stageY);
ioutput("vvv MouseMove.");
}
public function ():Number{
return (640);
}
private function prepareDrag():void{
var closest:*;
closest = web.getClosest(getMouseDownPoint(), false);
gMouse.dragging = closest[1];
}
public function TogglePauseEvent(event:MouseEvent):void{
TogglePause();
TogglePauseDisplay();
}
public function TogglePause():void{
if (mGameOver){
return;
};
mPaused = !(mPaused);
if (mPaused){
};
}
public function EndGamePaused(event:MouseEvent):void{
TogglePauseEvent(event);
EndGame();
}
public function turnOnTutorials():void{
toutput(" ^ Turning on tutorials");
display_tutorials = true;
this["msPauseOverlay"]["msHelpButton"].gotoAndPlay("on");
this["msPauseOverlay"]["msHelpButton"].removeEventListener(MouseEvent.MOUSE_UP, turnOnTutorialsEvent);
this["msPauseOverlay"]["msHelpButton"].addEventListener(MouseEvent.MOUSE_UP, turnOffTutorialsEvent);
toutput(" v Turning on tutorials");
}
public function lowerCollapsingPrecedent(){
collapsing_precedent++;
}
public function startMusic(){
mMusic = AudioEngine.PlaySound("arachnophiliaMusic", AudioEngine.MUSIC_CHANNEL, true);
mMusic.SetVolume(0.6);
}
private function updateCricketSound(){
mAmbientCricketTimer.delay = 10000;
mAmbientCricketTimer.start();
}
private function playCricketSound(event:TimerEvent){
AudioEngine.PlaySound("sfxCricket2", AudioEngine.SFX_CHANNEL, false);
}
private function playOwl1Sound(event:TimerEvent){
AudioEngine.PlaySound("sfxAmbientOwl1", AudioEngine.SFX_CHANNEL, false);
}
public function turnOffTutorialsEvent(event:MouseEvent):void{
turnOffTutorials();
}
public function spawnBug(){
var point:Point;
point = environment.generatePoint();
spawnBugLocation(point.x, point.y);
}
public function setupTutorials(){
unseen_tutorials = new HashTable();
if (art_mode){
unseen_tutorials.setValue("art_spider", new ArtSpiderTutorial(this));
unseen_tutorials.setValue("art_web", new ArtWebTutorial(this));
unseen_tutorials.setValue("art_bee", new ArtBeeTutorial(this));
} else {
unseen_tutorials.setValue("spider", new SpiderTutorial(this));
unseen_tutorials.setValue("web", new WebTutorial(this));
unseen_tutorials.setValue("caught", new CaughtTutorial(this));
unseen_tutorials.setValue("fly", new FlyTutorial(this));
unseen_tutorials.setValue("ladybug", new LadyBugTutorial(this));
unseen_tutorials.setValue("bee", new BeeTutorial(this));
unseen_tutorials.setValue("stag_beetle", new StagBeetleTutorial(this));
unseen_tutorials.setValue("fire_fly", new FireFlyTutorial(this));
unseen_tutorials.setValue("moth", new MothTutorial(this));
unseen_tutorials.setValue("dragonfly", new DragonFlyTutorial(this));
unseen_tutorials.setValue("queen_bee", new QueenBeeTutorial(this));
unseen_tutorials.setValue("butterfly", new ButterFlyTutorial(this));
unseen_tutorials.setValue("hummingbird", new HummingBirdTutorial(this));
unseen_tutorials.setValue("bat", new BatTutorial(this));
unseen_tutorials.setValue("eat_bat", new EatBatTutorial(this));
};
}
public function GetScore():Number{
return (MemoryCrypto.getValue("score"));
}
private function updateOwl1Sound(){
mAmbientOwl1Timer.delay = (15000 + (Math.random() * 5000));
mAmbientOwl1Timer.start();
mAmbientOwl2Timer.stop();
}
private function updateUI(time:Number):void{
this["smScore"].text = Math.floor(MemoryCrypto.getValue("score")).toString();
spider.ui.updateLevel(time);
spider.ui.updateAchievement(time);
spider.ui.updateWebbing(time, (spider.webbing / spider.webbing_max));
spider.ui.updateEnergy(time, (spider.energy / spider.energy_max));
spider.ui.updateBonusWebbing(time, (spider.bonus_web_strength / spider.bonus_web_strength_max));
}
public function turnOnTutorialsEvent(event:MouseEvent):void{
turnOnTutorials();
}
public function handleMouseUp(event:MouseEvent):void{
ioutput("^^^ MouseUp.");
if (mPaused){
gMouse.down = false;
gMouse.dragging = undefined;
return;
};
if (gMouse.down){
gMouse.down = false;
gMouse.up_time = getTimer();
gMouse.up_x = gMouse.x;
gMouse.up_y = gMouse.y;
if (isDraggingDistance()){
drag();
} else {
click();
};
gMouse.dragging = undefined;
};
ioutput("vvv MouseUp.");
}
public function turnOffTutorials():void{
toutput(" ^ Turning off tutorials");
display_tutorials = false;
this["msPauseOverlay"]["msHelpButton"].gotoAndPlay("off");
this["msPauseOverlay"]["msHelpButton"].removeEventListener(MouseEvent.MOUSE_UP, turnOffTutorialsEvent);
this["msPauseOverlay"]["msHelpButton"].addEventListener(MouseEvent.MOUSE_UP, turnOnTutorialsEvent);
toutput(" v Turning off tutorials");
}
public function char(s:String):Number{
return (s.charCodeAt(0));
}
public function EndGame():void{
var score:Number;
var overlay:MovieClip;
var adContainer:MovieClip;
mGameOver = true;
mPaused = false;
AudioEngine.PlaySound("sfxGameOver", AudioEngine.SFX_CHANNEL, false);
if (mAmbientSound != null){
mAmbientSound.Stop();
mAmbientSound = null;
};
turnOffSounds();
if (mMusic != null){
mMusic.Stop();
mMusic = null;
};
spider.endWarningSound();
score = Math.floor(MemoryCrypto.getValue("score"));
this["smScore"].text = score;
this["msGameOverOverlay"]["msFinalScore"].text = ("Final Score: " + score);
overlay = this["msGameOverOverlay"];
overlay.visible = true;
if (!art_mode){
this["msGameOverOverlay"]["mcAchievements"].visible = true;
Achievements.SubmitScore(root.gHighscoreGameID, GetScore());
Achievements.Display(this["msGameOverOverlay"]["mcAchievements"]);
} else {
this["msGameOverOverlay"]["mcAchievements"].visible = false;
};
adContainer = this["msGameOverOverlay"]["msAdContainer"];
if (adContainer != null){
AdServer.DisplayAd(adContainer);
};
}
private function checkSpiderEdge():void{
var edges:Array;
var ed:WebEdge;
var node:WebNode;
var closest:Array;
if (spider.edge == null){
trace("!!! Spider not on edge.");
if (!web.hasNode(spider)){
spider.forceAction(new CrawlerFlyAction(new WebNode(spider.x, (spider.y + 1)), true));
return;
};
edges = web.getNode(spider).getEdges();
if (edges.length > 0){
if ((((edges[0] == null)) || (!(spider.intercepts(edges[0]))))){
trace(("!!! (G585) Setting spider to illegal edge: " + edges[0]));
};
spider.edge = edges[0];
} else {
spider.forceAction(new CrawlerFlyAction(new WebNode(spider.x, (spider.y + 1)), true));
return;
};
};
if (!web.hasEdge(spider.edge)){
if (spider.equals(spider.edge.p1)){
node = WebNode(spider.edge.p1);
if (web.hasNode(node)){
edges = web.getNode(node).getEdges();
if (edges.length > 0){
ed = web.getNode(node).getEdges()[0];
if ((((ed == null)) || (!(spider.intercepts(ed))))){
trace(("!!! (G606) Setting spider to illegal edge: " + ed));
};
spider.edge = web.getNode(node).getEdges()[0];
return;
};
};
};
if (spider.equals(spider.edge.p2)){
node = WebNode(spider.edge.p2);
if (web.hasNode(node)){
edges = web.getNode(node).getEdges();
if (edges.length > 0){
ed = web.getNode(node).getEdges()[0];
if ((((ed == null)) || (!(spider.intercepts(ed))))){
trace(("!!! (G621) Setting spider to illegal edge: " + ed));
};
spider.edge = web.getNode(node).getEdges()[0];
return;
};
};
};
edges = web.getIntersections(spider, true).getEdges();
if (edges.length > 0){
if ((((edges[0] == null)) || (!(spider.intercepts(edges[0]))))){
trace(("!!! (G632) Setting spider to illegal edge: " + edges[0]));
};
spider.edge = edges[0];
return;
};
spider.forceAction(new CrawlerFlyAction(new WebNode(spider.x, (spider.y + 1)), true));
};
if (!spider.intercepts(spider.edge)){
closest = spider.edge.getClosest(spider, false, false);
spider.x = closest[0].x;
spider.y = closest[0].y;
};
}
public function drag():void{
var dragging:WebNode;
var mousePoint:*;
var a1:CrawlAction;
var a2:AddMultipleStrandsAction;
dragging = WebNode(gMouse.dragging);
mousePoint = getMousePoint();
if (((((!((mousePoint == WebNode(undefined)))) && (!((dragging == WebNode(undefined)))))) && (isDraggingDistance()))){
a1 = new CrawlAction(dragging);
spider.addAction(a1);
a2 = new AddMultipleStrandsAction(dragging, mousePoint, web);
spider.addAction(a2);
};
gMouse.dragging = undefined;
Mouse.show();
}
public function TogglePauseDisplay():void{
if (mGameOver){
return;
};
this["msPauseOverlay"].visible = mPaused;
}
public function click():void{
var mousePoint:*;
var actors:Array;
var prey:Prey;
var distance:Number;
var radius:Number;
var shortest_distance:Number;
var closest_point:WebNode;
var closest_prey:Prey;
var i:*;
var closest:*;
var a1:CrawlAction;
var a2:EatAction;
var sound_effect:SoundHandle;
var a:CrawlAction;
gMouse.click_time = undefined;
mousePoint = new WebNode(gMouse.up_x, gMouse.up_y);
if (displayPoint){
trace(("--> Current Point: " + getMousePoint()));
displayPoint = false;
};
if (spawnCheat){
trace("+++ Spawning a bug");
spawnBugLocation(gMouse.up_x, gMouse.up_y);
spawnCheat = false;
return;
};
actors = web.getCatchables();
i = 0;
while (i < actors.length) {
if ((actors[i] is Prey)){
if (actors[i].isCaught()){
prey = Prey(actors[i]);
distance = mousePoint.getDistanceSquared(prey.position);
radius = Circle(prey.body).radius;
if (distance <= ((radius * radius) + 0.005)){
if (((isNaN(shortest_distance)) || ((distance < shortest_distance)))){
shortest_distance = distance;
closest_point = web.getClosest(new Point(prey.position.x, prey.position.y), true)[1];
closest_prey = prey;
};
};
};
};
i++;
};
if (closest_point != WebNode(undefined)){
a1 = new CrawlAction(closest_point);
spider.addAction(a1);
a2 = new EatAction(closest_prey);
spider.addAction(a2);
sound_effect = AudioEngine.PlaySound("sfxQueueEat", AudioEngine.SFX_CHANNEL, false);
return;
};
closest = web.getClosest(mousePoint, false);
if (closest[2] < 0.05){
a = new CrawlAction(WebNode(closest[1]));
spider.addAction(a);
return;
};
}
public function handleMouseDown(event:MouseEvent):void{
ioutput("^^^ MouseDown.");
if (((mGameOver) || (mPaused))){
return;
};
if (!gMouse.down){
gMouse.down = true;
gMouse.down_time = getTimer();
gMouse.down_x = gMouse.x;
gMouse.down_y = gMouse.y;
prepareDrag();
};
ioutput("vvv MouseDown.");
}
public function ():Number{
return (480);
}
private function playOwl2Sound(event:TimerEvent){
AudioEngine.PlaySound("sfxAmbientOwl2", AudioEngine.SFX_CHANNEL, false);
}
public function
():Object{
return (mPlayer);
}
public function handleEnterFrame(event:Event):void{
var timer:Number;
var elapsedTimeMS:Number;
var elapsedTime:Number;
var actors:*;
var j:*;
var new_queue:Queue;
var old_precedent:Number;
var web_strand:WebStrand;
var strand_bundle:Array;
var edges:Array;
ioutput("^^^ Enter frame.");
doutput(" ^ Calculating elapsed time.");
timer = getTimer();
elapsedTimeMS = (timer - mLastUpdate);
elapsedTime = (elapsedTimeMS / 1000);
mLastUpdate = timer;
if (mPaused){
elapsedTime = 0;
elapsedTimeMS = 0;
};
if (elapsedTime > 1){
trace("LAG");
elapsedTime = 0;
elapsedTimeMS = 0;
};
doutput(" v Calculating elapsed time.");
doutput(" ^ Calculating FPS.");
Framerate.CalculateFPS(elapsedTime);
MemoryUsage.DisplayMemoryUsage(elapsedTime);
doutput(" v Calculating FPS.");
if (mGameOver){
return;
};
doutput(" ^ Clearning web pen.");
web.web_pen.graphics.clear();
doutput(" v Clearning web pen.");
if (collapsing_web){
new_queue = new Queue();
while (!(collapsing_strands.isEmpty())) {
strand_bundle = collapsing_strands.pop();
old_precedent = strand_bundle[0];
web_strand = WebStrand(strand_bundle[1]);
if (old_precedent > 0){
web_strand.drawCollapsing(web.drawer, old_precedent);
new_queue.push([(old_precedent - (elapsedTime * 2.5)), web_strand]);
};
};
collapsing_strands = new_queue;
if (collapsing_strands.isEmpty()){
collapsing_web = false;
} else {
elapsedTime = (elapsedTime * 0.8);
elapsedTimeMS = (elapsedTimeMS * 0.8);
};
};
doutput(" ^ Spawning enemy?");
mLastEnemyTime = (mLastEnemyTime + elapsedTimeMS);
if (((!(mPaused)) && ((mLastEnemyTime > level_data.getEnemyTime(web))))){
mLastEnemyTime = 0;
if (((!(testing)) && (!(art_mode)))){
doutput(" Spawning.");
spawnBug();
};
};
doutput(" v Spawning enemy?");
doutput(" ^ Checking spider edge.");
checkSpiderEdge();
doutput(" v Checking spider edge.");
doutput(" ^ Losing energy.");
spider.loseEnergy(elapsedTime);
if (spider.energy == 0){
EndGame();
};
if (((testing) || (art_mode))){
spider.addEnergy(spider.energy_max);
};
doutput(" v Losing energy.");
doutput(" ^ Adding web.");
if (((testing) || (art_mode))){
spider.addWebbing(elapsedTime);
};
doutput(" v Adding web.");
spider.loseBonusWebStrength(elapsedTime);
spider.loseBonusSpeed(elapsedTime);
doutput(" ^^ Handling catchables.");
actors = web.getCatchables();
j = 0;
while (j < actors.length) {
doutput((" ^ Handling catchable " + actors[j]));
actors[j].act(elapsedTime);
actors[j].actionUpdateGraphic(level_data, elapsedTime);
doutput((" v Handling catchable " + actors[j]));
j++;
};
doutput(" vv Handling catchables.");
doutput(" ^ Handling spider.");
spider.act(elapsedTime);
spider.actionUpdateGraphic(level_data, elapsedTime);
doutput(" v Handling spider.");
if (!(spider.currentAction() is CrawlerFlyAction)){
if ((((spider.edge == null)) || (!(spider.intercepts(spider.edge))))){
edges = web.getIntersections(spider, true).getEdges();
if (edges.length > 0){
trace((" !! Setting spider's edge to " + edges[0]));
spider.edge = edges[0];
} else {
trace(((("!!! SPIDER EDGE IMPERATIVE BROKEN: " + spider) + " not in ") + spider.edge));
trace((" !! Current edge: " + spider.edge));
trace((" ! Web has current edge: " + web.hasEdge(spider.edge)));
trace((" !! Current action: " + spider.currentAction()));
};
};
};
doutput(" ^ Drawing web and spider.");
web.drawPlannedStrands();
web.Draw();
spider.updateGraphic(level_data, elapsedTime);
doutput(" v Drawing web and spider.");
doutput(" ^ Drawing dragging.");
if (!mPaused){
displayDragging();
};
doutput(" v Drawing dragging.");
if (art_mode){
MemoryCrypto.setValue("score", 0);
};
doutput(" ^ Updating UI.");
updateUI(elapsedTime);
doutput(" v Updating UI.");
doutput(" ^ Updating difficulty.");
if (!art_mode){
mLastDifficultyTime = (mLastDifficultyTime + elapsedTimeMS);
if (((!(mPaused)) && (level_data.updateDifficulty(Math.floor(MemoryCrypto.getValue("score")), mLastDifficultyTime, this)))){
mLastDifficultyTime = 0;
if (mMusic == null){
startMusic();
};
};
};
doutput(" v Updating difficulty.");
doutput(" ^ Displaying initial tutorials.");
if (art_mode){
displayTutorial("art_spider");
} else {
displayTutorial("spider");
};
doutput(" v Displaying initial tutorials.");
doutput(" ^ Updating stats.");
mGameRunTime = (mGameRunTime + elapsedTime);
if (Math.floor(mGameRunTime) > mLastGameTimeStat){
mLastGameTimeStat = Math.floor(mGameRunTime);
};
doutput(" v Updating stats.");
ioutput("vvv Enter frame.");
}
private function turnOffSounds(){
mAmbientOwl1Timer.stop();
mAmbientOwl2Timer.stop();
mAmbientCricketTimer.stop();
}
public function InitializeGame(){
var i:Number;
this["msGameOverOverlay"].visible = false;
this["msPauseOverlay"].visible = false;
this["msPauseOverlay"]["msContinueButton"].addEventListener(MouseEvent.MOUSE_UP, TogglePauseEvent);
this["msPauseOverlay"]["msEndGameButton"].addEventListener(MouseEvent.MOUSE_UP, EndGamePaused);
turnOnTutorials();
mPaused = false;
if (art_mode){
level_data = new LevelData("art");
} else {
level_data = new LevelData("regular");
};
web = new Web(1, 5, level_data, this);
i = 0;
while (i < level_data.starting_nodes.length) {
web.addNode(level_data.starting_nodes[i]);
i++;
};
i = 0;
while (i < level_data.starting_edges.length) {
web.addEdge(level_data.starting_edges[i]);
i++;
};
spider = new Spider(0.5, 0.5, web, this);
spider.ui = new SpiderUI(level_data);
gMouse = new GameMouse();
mLastEnemyTime = 0;
mLastDifficultyTime = mLastEnemyTime;
environment = new MoonEnvironment();
setupGraphics();
setupTutorials();
setupAchievements();
mAmbientSound = AudioEngine.PlaySound("sfxAmbient", AudioEngine.SFX_CHANNEL, true);
if (art_mode){
startMusic();
};
setupSounds();
}
public function spawnBugLocation(x:Number, y:Number){
level_data.spawnBug(x, y, web, environment);
}
public function
():Number{
return (mLevelCount);
}
private function setupOwl1Sound(){
mAmbientOwl1Timer = new Timer(4000, 0);
mAmbientOwl1Timer.addEventListener(TimerEvent.TIMER, playOwl1Sound);
}
private function getMouseDownPoint():WebNode{
var down_point:WebNode;
if ((((gMouse.down_x == Number(undefined))) || ((gMouse.down_y == Number(undefined))))){
down_point = undefined;
} else {
down_point = new WebNode(gMouse.down_x, gMouse.down_y);
};
return (down_point);
}
private function isDraggingDistance():Boolean{
var down_point:WebNode;
var up_point:WebNode;
var root_point:WebNode;
if (gMouse.dragging != null){
root_point = WebNode(gMouse.dragging);
} else {
return (false);
};
down_point = new WebNode(gMouse.down_x, gMouse.down_y);
up_point = getMousePoint();
return ((((down_point.getDistanceSquared(up_point) > gMouse.drag_distance_squared)) && ((root_point.getDistanceSquared(up_point) > gMouse.drag_distance_squared))));
}
private function getMousePoint():WebNode{
var mousePoint:WebNode;
if ((((gMouse.x == Number(undefined))) || ((gMouse.y == Number(undefined))))){
mousePoint = undefined;
} else {
mousePoint = new WebNode(gMouse.x, gMouse.y);
};
return (mousePoint);
}
public function clearWeb(){
var action:CatchableDieAction;
var catchables:Array;
var i:*;
action = new CatchableDieAction(web);
catchables = web.getCatchables();
i = 0;
while (i < catchables.length) {
action.act(catchables[i], 0);
i++;
};
}
public function Restart():void{
sClipDepth = 10;
sEnemyID = 0;
sPowerupID = 0;
sExplosionID = 0;
sFXID = 0;
mGameOver = false;
mPaused = false;
mLastUpdate = 0;
mPlayer = null;
mLastPowerupSpawn = 0;
mLastPowerupLocations = new Array();
mGameRunTime = 0;
mLastGameTimeStat = 0;
mLastUpdate = getTimer();
mLastPowerupSpawn = mLastUpdate;
mLastDifficultyChange = mLastUpdate;
mDifficultyIndex = 0;
mSpawnArray = null;
MemoryCrypto.setValue("score", 0);
clearGraphics();
InitializeGame();
}
private function updateOwl2Sound(){
mAmbientOwl2Timer.delay = (30000 + (Math.random() * 10000));
mAmbientOwl2Timer.start();
mAmbientOwl1Timer.stop();
}
public function resetCollapsingPrecedent(){
collapsing_precedent = 0;
}
public function clearGraphics(){
if (environment != null){
environment.clearBackground(this);
environment.clearFrame(this);
};
if (web != null){
clearWeb();
this["graphics_anchor"].removeChild(web.before_web);
this["graphics_anchor"].removeChild(web.almost_web);
this["graphics_anchor"].removeChild(web.web_pen);
this["graphics_anchor"].removeChild(web.after_web);
};
if (spider != null){
spider.removeGraphics(this["graphics_anchor"]);
if (spider.ui != null){
spider.ui.removeGraphics(this);
};
};
}
public static function AwardPoints(numPoints:Number):void{
if (!isNaN(numPoints)){
MemoryCrypto.incrementValue("score", numPoints);
};
}
}
}//package game
Section 137
//LevelData (game.LevelData)
package game {
import framework.Spider.Web.*;
import framework.Spider.Levels.*;
import framework.Spider.Environments.*;
import framework.Utilities.*;
public class LevelData {
public var level_stage:Number;
public var web_color_blue:Number;// = 102
public var web_color_red:Number;// = 102
public var pen;
public var web_width:Number;// = 1
public var starting_edges:Array;
public var web_color_max_green:Number;// = 153
public var web_danger_color_red:Number;// = 0xFF
public var web_danger_color_blue:Number;// = 0
public var web_color_max_red:Number;// = 153
public var web_alpha:Number;// = 1
public var web_colors:HashTable;
public var web_color_green:Number;// = 102
public var edge_width:Number;// = 2
public var web_danger_color_green:Number;// = 0
public var level_index:Number;
public var edge_alpha:Number;// = 0.75
public var edge_color:Number;// = 0x666600
public var raw_levels:HashTable;
public var levels:Array;
public var starting_nodes:Array;
public var level_name:String;// = "peaceful_level"
public var planned_web_alpha:Number;// = 0.55
public var web_color_max_blue:Number;// = 0
public var planned_web_color:Number;// = 13209
public static var screenHeight = 400;
public static var screenOffsetX = 40;
public static var screenWidth = 400;
public static var screenOffsetY = 40;
public function LevelData(game_mode:String){
web_color_max_red = 153;
web_color_max_green = 153;
web_color_max_blue = 0;
web_color_red = 102;
web_color_green = 102;
web_color_blue = 102;
web_danger_color_red = 0xFF;
web_danger_color_green = 0;
web_danger_color_blue = 0;
web_width = 1;
web_alpha = 1;
planned_web_color = 13209;
planned_web_alpha = 0.55;
edge_color = 0x666600;
edge_width = 2;
edge_alpha = 0.75;
level_name = "peaceful_level";
super();
initializeWeb();
initializeLevels(game_mode);
web_colors = new HashTable();
if (game_mode == "art"){
level_name = "art_level";
};
}
public function convertX(x0:Number):Number{
return (((x0 * screenWidth) + screenOffsetX));
}
public function convertY(y0:Number):Number{
return (((y0 * screenHeight) + screenOffsetY));
}
public function yRatio(y0:Number):Number{
return ((y0 * screenHeight));
}
public function initializeLevels(game_mode:String){
var temp_levels:Array;
var current_level:Level;
var i:*;
raw_levels = new HashTable();
if (game_mode == "art"){
temp_levels = [new ArtLevel()];
} else {
temp_levels = [new ShortPeacefulLevel(), new PeacefulLevel(), new FlyLevel(), new LadyBugLevel(), new BeeLevel(), new StagBeetleLevel(), new StagBeetleAllLevel(), new FireFlyLevel(), new FireFlyAllLevel(), new DragonflyLevel(), new DragonflyAllLevel(), new QueenBeeLevel(), new QueenBeeAllLevel(), new ButterflyLevel(), new ButterflyAllLevel(), new HummingBirdLevel(), new HummingBirdAllLevel(), new BatLevel(), new BatAllLevel()];
};
i = 0;
while (i < temp_levels.length) {
current_level = temp_levels[i];
raw_levels.setValue(current_level.name, current_level);
i++;
};
if (game_mode == "art"){
levels = [["", "art_level"]];
} else {
levels = [["", "short_peaceful_level"], ["Flies", "short_peaceful_level", "fly_level"], ["Lady Bugs", "peaceful_level", "ladybug_level"], ["Bees", "peaceful_level", "fly_level", "bee_level"], ["Stag Beetles", "peaceful_level", "fly_level", "stag_beetle_level", "stag_beetle_all_level"], ["Fire Flies", "peaceful_level", "fly_level", "firefly_level", "firefly_all_level"], ["Dragonflies", "peaceful_level", "fly_level", "dragonfly_level", "dragonfly_all_level"], ["Queen Bees", "peaceful_level", "dragonfly_level", "queen_bee_level", "queen_bee_all_level"], ["Butterflies", "peaceful_level", "dragonfly_level", "butterfly_level", "butterfly_all_level"], ["Humming Birds", "peaceful_level", "dragonfly_level", "hummingbird_level", "hummingbird_all_level"], ["The Bat", "peaceful_level", "dragonfly_level", "bat_level", "bat_all_level"], ["", "peaceful_level", "dragonfly_level", "bat_all_level", "bat_all_level"]];
};
level_index = 0;
level_stage = 1;
}
public function unconvertX(x0:Number):Number{
return (((x0 - screenOffsetX) / screenWidth));
}
public function unconvertY(y0:Number):Number{
return (((y0 - screenOffsetY) / screenHeight));
}
private function initializeWeb(){
var p1:*;
var p2:*;
var p3:*;
var p4:*;
var p5:*;
var p6:*;
var p7:*;
var p8:*;
var p9:*;
var p10:*;
var p11:*;
var e1:*;
var e2:*;
var e3:*;
var e4:*;
var e5:*;
var e6:*;
var e7:*;
var e8:*;
var s1:*;
var s2:*;
var s3:*;
var s4:*;
var s5:*;
var s6:*;
var s7:*;
var s8:*;
p1 = new WebNode(0.01, 0.1);
p2 = new WebNode(0.01, 0.95);
p3 = new WebNode(0.99, 0.8);
p4 = new WebNode(0.75, 0.01);
p5 = new WebNode(0.01, 0.5);
p6 = new WebNode(0.5, 0.97);
p7 = new WebNode(0.99, 0.5);
p8 = new WebNode(0.5, 0.04);
p9 = new WebNode(0.85, 0.07);
p10 = new WebNode(0.5, 0.5);
p11 = new WebNode(0.92, 0.87);
starting_nodes = [p10];
e1 = new WebEdge(p1, p2);
e2 = new WebEdge(p2, p6);
e3 = new WebEdge(p6, p11);
e4 = new WebEdge(p11, p3);
e5 = new WebEdge(p3, p7);
e6 = new WebEdge(p7, p9);
e7 = new WebEdge(p9, p4);
e8 = new WebEdge(p4, p1);
s1 = new WebStrand(p1, p10, 1);
s2 = new WebStrand(p10, p11, 1);
s3 = new WebStrand(p2, p10, 1);
s4 = new WebStrand(p10, p9, 1);
s5 = new WebStrand(p5, p10, 1);
s6 = new WebStrand(p10, p7, 1);
s7 = new WebStrand(p6, p10, 1);
s8 = new WebStrand(p10, p8, 1);
starting_edges = [e1, e2, e3, e4, e5, e6, e7, e8, s1, s2, s3, s4, s5, s6, s7, s8];
}
public function getEnemyTime(web:Web):Number{
return (getStage().getEnemyTime(web));
}
public function getStage():Level{
return (Level(raw_levels.getValue(getLevel()[level_stage])));
}
private function (distance:Number){
var center_x:*;
var center_y:*;
var short_distance:*;
var p1:*;
var p2:*;
var p3:*;
var p4:*;
var p5:*;
var p6:*;
var p7:*;
var p8:*;
var s1:*;
var s2:*;
var s3:*;
var s4:*;
var s5:*;
var s6:*;
var s7:*;
var s8:*;
center_x = 0.5;
center_y = 0.5;
short_distance = (distance * Math.sin((Math.PI / 4)));
p1 = new WebNode((center_x - distance), center_y);
p2 = new WebNode((center_x - short_distance), (center_y + short_distance));
p3 = new WebNode(center_x, (center_y + distance));
p4 = new WebNode((center_x + short_distance), (center_y + short_distance));
p5 = new WebNode((center_x + distance), center_y);
p6 = new WebNode((center_x + short_distance), (center_y - short_distance));
p7 = new WebNode(center_x, (center_y - distance));
p8 = new WebNode((center_x - short_distance), (center_y - short_distance));
s1 = new WebStrand(p1, p2);
s2 = new WebStrand(p2, p3);
s3 = new WebStrand(p3, p4);
s4 = new WebStrand(p4, p5);
s5 = new WebStrand(p5, p6);
s6 = new WebStrand(p6, p7);
s7 = new WebStrand(p7, p8);
s8 = new WebStrand(p8, p1);
starting_edges = starting_edges.concat(s1, s2, s3, s4, s5, s6, s7, s8);
}
public function getLevel():Array{
if (level_index >= levels.length){
return (levels[(levels.length - 1)]);
};
return (levels[level_index]);
}
public function updateDifficulty(score:Number, timeSinceUpdate:Number, game:Game):Boolean{
if (getStage().updateDifficulty(score, timeSinceUpdate)){
level_stage++;
if (level_stage >= getLevel().length){
level_index++;
level_stage = 1;
getStage().displayLevel(game, level_index, getLevel()[0]);
};
return (true);
//unresolved jump
};
return (false);
}
public function getWebColor(strength:Number):Number{
var color:Number;
var inverse:Number;
var adjusted_strength:Number;
if (strength < 0){
return (getWebColor(0));
};
if (web_colors.hasKey(String(strength))){
return (Number(web_colors.getValue(String(strength))));
};
if (strength <= 1){
inverse = (1 - strength);
color = (Math.floor(((strength * web_color_red) + (inverse * web_danger_color_red))) * 65536);
color = (color + (Math.floor(((strength * web_color_green) + (inverse * web_danger_color_green))) * 0x0100));
color = (color + Math.floor(((strength * web_color_blue) + (inverse * web_danger_color_blue))));
} else {
adjusted_strength = (strength - 1);
inverse = (1 - adjusted_strength);
color = (Math.floor(((adjusted_strength * web_color_max_red) + (inverse * web_color_red))) * 65536);
color = (color + (Math.floor(((adjusted_strength * web_color_max_green) + (inverse * web_color_green))) * 0x0100));
color = (color + Math.floor(((adjusted_strength * web_color_max_blue) + (inverse * web_color_blue))));
};
web_colors.setValue(String(strength), color);
return (color);
}
public function xRatio(x0:Number):Number{
return ((x0 * screenWidth));
}
public function spawnBug(x:Number, y:Number, web:Web, environment:Environment){
getStage().spawnBug(x, y, web, environment);
}
}
}//package game
Section 138
//LoadingBar (loader.LoadingBar)
package loader {
import flash.events.*;
import flash.display.*;
public dynamic class LoadingBar extends MovieClip {
public var mLoadedSoFar:Number;// = 0
public var mLoadRequired:Number;// = 1
public function LoadingBar(){
mLoadedSoFar = 0;
mLoadRequired = 1;
super();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function Finished():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event):void{
parent.doLoad();
}
}
}//package loader
Section 139
//MochiAd (mochi.MochiAd)
package mochi {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public function MochiAd(){
super();
}
public static function getVersion():String{
return ("2.5");
}
public static function showClickAwayAd(options: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 = options;
DEFAULTS = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (width:Number, height: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 (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
sendHostProgress = false;
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
chk["onEnterFrame"] = function ():void{
var ad_clip:Object;
var elapsed:Number;
var finished:Boolean;
var total:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
ad_clip = this.parent._mochiad_ctr;
elapsed = (getTimer() - this.started);
finished = false;
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
finished = true;
chk.started = getTimer();
} else {
if (elapsed > chk.ad_timeout){
options.ad_failed();
finished = true;
};
};
};
if (this.root == null){
finished = true;
};
if (finished){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(server:String):String{
var hostname:String;
hostname = server.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(hostname);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(hostname);
return (hostname);
}
public static function unload(clip:Object):Boolean{
if (((clip.clip) && (clip.clip._mochiad))){
clip = clip.clip;
};
if (clip.origFrameRate != undefined){
clip.stage.frameRate = clip.origFrameRate;
};
if (!clip._mochiad){
return (false);
};
if (clip._mochiad._containerLCName != undefined){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"unload"});
};
if (clip._mochiad.onUnload){
clip._mochiad.onUnload();
};
delete clip._mochiad_loaded;
delete clip._mochiad;
return (true);
}
public static function showInterLevelAd(options: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 = options;
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 (width:Number, height: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 p:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
p = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (p > 0){
this.parent.alpha = (p * 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 (msec:Number):void{
var _chk:Object;
_chk = mc._mochiad_wait;
_chk.server_control = true;
_chk.showing = true;
_chk.started = getTimer();
_chk.ad_msec = (msec - 250);
};
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
chk["onEnterFrame"] = function ():void{
var ad_clip:Object;
var elapsed:Number;
var finished:Boolean;
var total:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
ad_clip = this.parent._mochiad_ctr;
elapsed = (getTimer() - this.started);
finished = false;
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (elapsed > chk.ad_timeout){
options.ad_failed();
finished = true;
};
};
};
if (elapsed > chk.ad_msec){
finished = true;
};
if (finished){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(options:Object, defaults:Object):Object{
var optcopy:Object;
var k:String;
var pairs:Array;
var i:Number;
var kv:Array;
optcopy = {};
for (k in defaults) {
optcopy[k] = defaults[k];
};
if (options){
for (k in options) {
optcopy[k] = options[k];
};
};
if (optcopy.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."));
};
options = optcopy.clip.loaderInfo.parameters.mochiad_options;
if (options){
pairs = options.split("&");
i = 0;
while (i < pairs.length) {
kv = pairs[i].split("=");
optcopy[unescape(kv[0])] = unescape(kv[1]);
i++;
};
};
if (optcopy.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (optcopy);
}
public static function _cleanup(mc:Object):void{
var idx:Number;
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = mc;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
lc.client = null;
lc.close();
//unresolved jump
var _slot1 = e;
};
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(options: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 = options;
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);
};
if (clip._mochiad_loaded){
return (null);
};
//unresolved jump
var _slot1 = e;
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 (ev:Object):void{
ev.target.removeEventListener(ev.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(base:Object, methodName:String, argsArray:Array):Object{
var nameArray:Array;
var i:Number;
nameArray = methodName.split(".");
i = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return (undefined);
};
base = base[nameArray[i]];
i++;
};
if (typeof(base[nameArray[i]]) == "function"){
return (base[nameArray[i]].apply(base, argsArray));
};
return (undefined);
}
public static function createEmptyMovieClip(parent:Object, name:String, depth:Number):MovieClip{
var mc:MovieClip;
mc = new MovieClip();
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
parent[name] = mc;
mc["_name"] = name;
return (mc);
}
public static function _getRes(options:Object, clip:Object):Array{
var b:Object;
var w:Number;
var h:Number;
var xy:Array;
b = clip.getBounds(clip.root);
w = 0;
h = 0;
if (typeof(options.res) != "undefined"){
xy = options.res.split("x");
w = parseFloat(xy[0]);
h = parseFloat(xy[1]);
} else {
w = (b.xMax - b.xMin);
h = (b.yMax - b.yMin);
};
if ((((w == 0)) || ((h == 0)))){
w = clip.stage.stageWidth;
h = clip.stage.stageHeight;
};
return ([w, h]);
}
public static function adShowing(mc:Object):void{
mc.origFrameRate = mc.stage.frameRate;
mc.stage.frameRate = 30;
}
public static function getValue(base:Object, objectName:String):Object{
var nameArray:Array;
var i:Number;
nameArray = objectName.split(".");
i = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return (undefined);
};
base = base[nameArray[i]];
i++;
};
return (base[nameArray[i]]);
}
public static function rpc(clip:Object, callbackID:Number, arg:Object):void{
var _local4:Object;
var _local5:Object;
switch (arg.id){
case "setValue":
MochiAd.setValue(clip, arg.objectName, arg.value);
break;
case "getValue":
_local4 = MochiAd.getValue(clip, arg.objectName);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(clip, arg.method, arg.args);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + arg.id));
};
}
public static function setValue(base:Object, objectName:String, value:Object):void{
var nameArray:Array;
var i:Number;
nameArray = objectName.split(".");
i = 0;
while (i < (nameArray.length - 1)) {
if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){
return;
};
base = base[nameArray[i]];
i++;
};
base[nameArray[i]] = value;
}
public static function showPreGameAd(options: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 = options;
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 (width:Number, height: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 (percent: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 p:Number;
p = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (p > 0){
this.parent.alpha = (p * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
f = function (ev:Event):void{
ev.target.removeEventListener(ev.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 (msec:Number):void{
var _chk:Object;
_chk = mc._mochiad_wait;
_chk.server_control = true;
_chk.showing = true;
_chk.started = getTimer();
_chk.ad_msec = msec;
};
mc.rpc = function (callbackID:Number, arg:Object):void{
MochiAd.rpc(clip, callbackID, arg);
};
mc.rpcTestFn = function (s:String):Object{
trace(("[MOCHIAD rpcTestFn] " + s));
return (s);
};
mc.regContLC = function (lc_name:String):void{
mc._containerLCName = lc_name;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (lc_name:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _clip:Object;
var ad_clip:Object;
var elapsed:Number;
var finished:Boolean;
var clip_total:Number;
var clip_loaded:Number;
var clip_pcnt:Number;
var ad_pcnt:Number;
var _inside:Object;
var pcnt:Number;
var total:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
_clip = this.parent.parent.root;
ad_clip = this.parent._mochiad_ctr;
elapsed = (getTimer() - this.started);
finished = false;
clip_total = _clip.loaderInfo.bytesTotal;
clip_loaded = _clip.loaderInfo.bytesLoaded;
if (complete){
clip_loaded = Math.max(1, clip_loaded);
clip_total = clip_loaded;
};
clip_pcnt = ((100 * clip_loaded) / clip_total);
ad_pcnt = ((100 * elapsed) / chk.ad_msec);
_inside = this._mochiad_bar._inside;
pcnt = Math.min(100, Math.min(((clip_pcnt) || (0)), ad_pcnt));
pcnt = Math.max(this.last_pcnt, pcnt);
this.last_pcnt = pcnt;
_inside.scaleX = (pcnt * 0.01);
options.ad_progress(pcnt);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:clip_pcnt});
if (clip_pcnt == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (total > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((elapsed > chk.ad_timeout)) && ((clip_pcnt == 100)))){
options.ad_failed();
finished = true;
};
};
};
if (elapsed > chk.ad_msec){
finished = true;
};
if (((complete) && (finished))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(options:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(options);
}
public static function showTimedAd(options:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(options);
}
public static function doOnEnterFrame(mc:MovieClip):void{
var f:Function;
var mc = mc;
f = function (ev:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
ev.target.removeEventListener(ev.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi
Section 140
//Framerate (performance.Framerate)
package performance {
import flash.text.*;
public class Framerate {
private static var sFPSTotalTime:Number = 0;
private static var sFPSDisplayFrequency:Number = 1;
private static var sFPSTotalFrames:Number = 0;
private static var sFPSTextField:TextField = null;
private static var sDisplayFPS:Boolean = true;
private static var sFPS:Number = 0;
public function Framerate(){
super();
}
public static function CalculateFPS(elapsedTime:Number):void{
var fpsThisFrame:Number;
fpsThisFrame = (1 / elapsedTime);
sFPSTotalTime = (sFPSTotalTime + elapsedTime);
sFPSTotalFrames++;
if (sFPSTotalTime >= sFPSDisplayFrequency){
sFPS = (sFPSTotalFrames * (1 / sFPSTotalTime));
sFPSTotalTime = 0;
sFPSTotalFrames = 0;
};
if (sFPSTextField != null){
sFPSTextField.text = (Math.round(sFPS).toString() + " fps");
};
}
public static function ShowFPS(show:Boolean, tf:TextField):void{
if (tf != null){
sDisplayFPS = show;
sFPSTextField = tf;
sFPSTextField.visible = show;
} else {
trace("No framerate text field found.");
sDisplayFPS = false;
};
}
}
}//package performance
Section 141
//MemoryUsage (performance.MemoryUsage)
package performance {
import flash.text.*;
import flash.system.*;
public class MemoryUsage {
private static var sMemoryUsageTextField:TextField = null;
private static var sDisplayMemoryUsage:Boolean = true;
public function MemoryUsage(){
super();
}
public static function InitMemoryUsageDisplay(show:Boolean, tf:TextField):void{
if (tf != null){
sDisplayMemoryUsage = show;
sMemoryUsageTextField = tf;
sMemoryUsageTextField.visible = show;
} else {
trace("No memory usage text field found.");
sDisplayMemoryUsage = false;
};
}
public static function DisplayMemoryUsage(elapsedTime:Number):void{
if (sMemoryUsageTextField != null){
sMemoryUsageTextField.text = (Math.floor((System.totalMemory / 1000)) + " KB");
};
}
}
}//package performance
Section 142
//DomainCheck (security.DomainCheck)
package security {
import flash.net.*;
public class DomainCheck {
private static var sAllowAllDomains:Boolean = false;
private static var sAdExemptList:Array;
private static var sHighscoreDomainsList:Array;
private static var sAllowedDomainsList:Array;
private static var sBlockLocalhost:Boolean = false;
public function DomainCheck(){
super();
}
public static function SetHighscoreDomains(highscoreDomains:Array):void{
sHighscoreDomainsList = highscoreDomains;
}
public static function SetAllowedDomains(allowedDomains:Array):void{
sAllowedDomainsList = allowedDomains;
}
public static function SetAdExemptDomains(adExemptDomains:Array):void{
sAdExemptList = adExemptDomains;
}
public static function IsAdExempt():Boolean{
var lc:LocalConnection;
var domain:String;
var i:Number;
lc = new LocalConnection();
domain = lc.domain;
if (sAdExemptList == null){
return (false);
};
i = 0;
while (i < sAdExemptList.length) {
if (domain == sAdExemptList[i]){
return (true);
};
i++;
};
i = 0;
while (i < sAdExemptList.length) {
if (domain.substr(-((sAdExemptList[i].length + 1))) == ("." + sAdExemptList[i])){
return (true);
};
i++;
};
return (false);
}
public static function BlockLocalhost(blockLocalhost:Boolean):void{
sBlockLocalhost = blockLocalhost;
}
public static function isCurrentDomainAllowed():Boolean{
var lc:LocalConnection;
var domain:String;
var i:Number;
lc = new LocalConnection();
domain = lc.domain;
if (domain == "localhost"){
return (!(sBlockLocalhost));
};
if (sAllowAllDomains){
return (true);
};
if (sAllowedDomainsList == null){
return (false);
};
i = 0;
while (i < sAllowedDomainsList.length) {
if (domain == sAllowedDomainsList[i]){
return (true);
};
i++;
};
i = 0;
while (i < sAllowedDomainsList.length) {
if (domain.substr(-((sAllowedDomainsList[i].length + 1))) == ("." + sAllowedDomainsList[i])){
return (true);
};
i++;
};
return (false);
}
public static function CanSubmitHighscores():Boolean{
var lc:LocalConnection;
var domain:String;
var i:Number;
lc = new LocalConnection();
domain = lc.domain;
if (sHighscoreDomainsList == null){
return (false);
};
i = 0;
while (i < sHighscoreDomainsList.length) {
if (domain == sHighscoreDomainsList[i]){
return (true);
};
i++;
};
i = 0;
while (i < sHighscoreDomainsList.length) {
if (domain.substr(-((sHighscoreDomainsList[i].length + 1))) == ("." + sHighscoreDomainsList[i])){
return (true);
};
i++;
};
return (false);
}
public static function AllowAllDomains(allowAllDomains:Boolean):void{
sAllowAllDomains = allowAllDomains;
}
}
}//package security
Section 143
//MemoryCrypto (security.MemoryCrypto)
package security {
public class MemoryCrypto {
private static var crypto:TEA = null;
private static var INCREMENT:Number = 0;
private static var initialized:Boolean = false;
private static var key:String = null;
private static var MULTIPLY:Number = 2;
private static var DECREMENT:Number = 1;
private static var dataHolder:Object = null;
private static var DIVIDE:Number = 3;
public function MemoryCrypto(){
super();
}
public static function getString(name:String):String{
var result:String;
initIfNeeded();
result = "";
if (isValueSet(name)){
result = crypto.decrypt(dataHolder[name], key);
};
return (result);
}
public static function incrementValue(name:String, amount:Number):Number{
return (processValue(name, amount, INCREMENT));
}
public static function isValueSet(name:String):Boolean{
var results:Boolean;
initIfNeeded();
results = false;
if (dataHolder[name] != null){
results = true;
};
return (results);
}
private static function processValue(name:String, amount:Number, operation:Number):Number{
var tempValue:Number;
initIfNeeded();
tempValue = getValue(name);
switch (operation){
case INCREMENT:
tempValue = (tempValue + amount);
break;
case DECREMENT:
tempValue = (tempValue - amount);
break;
case MULTIPLY:
tempValue = (tempValue * amount);
break;
case DIVIDE:
tempValue = (tempValue / amount);
break;
};
setValue(name, tempValue);
return (tempValue);
}
public static function setString(name:String, value:String):String{
initIfNeeded();
dataHolder[name] = crypto.encrypt(value, key);
return (value);
}
public static function reset():void{
initialized = false;
initIfNeeded();
}
public static function decrementValue(name:String, amount:Number):Number{
return (processValue(name, amount, DECREMENT));
}
private static function initIfNeeded():void{
var firstNumber:Number;
var firstKey:String;
var secondNumber:Number;
var secondKey:String;
if (!initialized){
firstNumber = Math.random();
firstKey = firstNumber.toString();
firstKey = firstKey.substr(2, (firstKey.length - 2));
secondNumber = Math.random();
secondKey = secondNumber.toString();
secondKey = secondKey.substr(2, (secondKey.length - 2));
key = (firstKey + secondKey);
crypto = new TEA();
dataHolder = new Object();
initialized = true;
};
}
public static function multiplyValue(name:String, amount:Number):Number{
return (processValue(name, amount, MULTIPLY));
}
public static function setValue(name:String, value:Number):Number{
initIfNeeded();
dataHolder[name] = crypto.encrypt(value.toString(), key);
return (value);
}
public static function divideValue(name:String, amount:Number):Number{
if (amount == 0){
throw (new Error("Amount can't be zero when dividing!"));
};
return (processValue(name, amount, DIVIDE));
}
public static function getValue(name:String):Number{
var results:Number;
initIfNeeded();
results = 0;
if (!isValueSet(name)){
setValue(name, results);
} else {
results = new Number(crypto.decrypt(dataHolder[name], key));
};
return (results);
}
}
}//package security
Section 144
//SHA1Hash (security.SHA1Hash)
package security {
public class SHA1Hash {
public function SHA1Hash(){
super();
}
private static function rotate_left(n, s){
var t4:*;
t4 = ((n << s) | (n >>> (32 - s)));
return (t4);
}
private static function cvt_hex(val){
var str:*;
var i:*;
var v:*;
str = "";
i = 7;
while (i >= 0) {
v = ((val >>> (i * 4)) & 15);
str = (str + v.toString(16));
i--;
};
return (str);
}
public static function SHA1(msg){
var blockstart:*;
var i:*;
var j:*;
var W:*;
var H0:*;
var H1:*;
var H2:*;
var H3:*;
var H4:*;
var A:*;
var B:*;
var C:*;
var D:*;
var E:*;
var temp:*;
var msg_len:*;
var word_array:*;
W = new Array(80);
H0 = 1732584193;
H1 = 4023233417;
H2 = 2562383102;
H3 = 271733878;
H4 = 3285377520;
msg = Utf8Encode(msg);
msg_len = msg.length;
word_array = new Array();
i = 0;
while (i < (msg_len - 3)) {
j = ((((msg.charCodeAt(i) << 24) | (msg.charCodeAt((i + 1)) << 16)) | (msg.charCodeAt((i + 2)) << 8)) | msg.charCodeAt((i + 3)));
word_array.push(j);
i = (i + 4);
};
switch ((msg_len % 4)){
case 0:
i = 2147483648;
break;
case 1:
i = ((msg.charCodeAt((msg_len - 1)) << 24) | 0x800000);
break;
case 2:
i = (((msg.charCodeAt((msg_len - 2)) << 24) | (msg.charCodeAt((msg_len - 1)) << 16)) | 0x8000);
break;
case 3:
i = ((((msg.charCodeAt((msg_len - 3)) << 24) | (msg.charCodeAt((msg_len - 2)) << 16)) | (msg.charCodeAt((msg_len - 1)) << 8)) | 128);
break;
};
word_array.push(i);
while ((word_array.length % 16) != 14) {
word_array.push(0);
};
word_array.push((msg_len >>> 29));
word_array.push(((msg_len << 3) & 4294967295));
blockstart = 0;
while (blockstart < word_array.length) {
i = 0;
while (i < 16) {
W[i] = word_array[(blockstart + i)];
i++;
};
i = 16;
while (i <= 79) {
W[i] = rotate_left((((W[(i - 3)] ^ W[(i - 8)]) ^ W[(i - 14)]) ^ W[(i - 16)]), 1);
i++;
};
A = H0;
B = H1;
C = H2;
D = H3;
E = H4;
i = 0;
while (i <= 19) {
temp = (((((rotate_left(A, 5) + ((B & C) | (~(B) & D))) + E) + W[i]) + 1518500249) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i++;
};
i = 20;
while (i <= 39) {
temp = (((((rotate_left(A, 5) + ((B ^ C) ^ D)) + E) + W[i]) + 1859775393) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i++;
};
i = 40;
while (i <= 59) {
temp = (((((rotate_left(A, 5) + (((B & C) | (B & D)) | (C & D))) + E) + W[i]) + 2400959708) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i++;
};
i = 60;
while (i <= 79) {
temp = (((((rotate_left(A, 5) + ((B ^ C) ^ D)) + E) + W[i]) + 3395469782) & 4294967295);
E = D;
D = C;
C = rotate_left(B, 30);
B = A;
A = temp;
i++;
};
H0 = ((H0 + A) & 4294967295);
H1 = ((H1 + B) & 4294967295);
H2 = ((H2 + C) & 4294967295);
H3 = ((H3 + D) & 4294967295);
H4 = ((H4 + E) & 4294967295);
blockstart = (blockstart + 16);
};
temp = ((((cvt_hex(H0) + cvt_hex(H1)) + cvt_hex(H2)) + cvt_hex(H3)) + cvt_hex(H4));
return (temp.toLowerCase());
}
private static function Utf8Encode(string){
var utftext:*;
var n:*;
var c:*;
utftext = "";
n = 0;
while (n < string.length) {
c = string.charCodeAt(n);
if (c < 128){
utftext = (utftext + String.fromCharCode(c));
} else {
if ((((c > 127)) && ((c < 0x0800)))){
utftext = (utftext + String.fromCharCode(((c >> 6) | 192)));
utftext = (utftext + String.fromCharCode(((c & 63) | 128)));
} else {
utftext = (utftext + String.fromCharCode(((c >> 12) | 224)));
utftext = (utftext + String.fromCharCode((((c >> 6) & 63) | 128)));
utftext = (utftext + String.fromCharCode(((c & 63) | 128)));
};
};
n++;
};
return (utftext);
}
private static function lsb_hex(val){
var str:*;
var i:*;
var vh:*;
var vl:*;
str = "";
i = 0;
while (i <= 6) {
vh = ((val >>> ((i * 4) + 4)) & 15);
vl = ((val >>> (i * 4)) & 15);
str = (str + (vh.toString(16) + vl.toString(16)));
i = (i + 2);
};
return (str);
}
}
}//package security
Section 145
//TEA (security.TEA)
package security {
import security.*;
class TEA {
function TEA(){
super();
}
public function encrypt(src:String, key:String):String{
var v:Array;
var k:Array;
var n:Number;
var z:Number;
var y:Number;
var delta:Number;
var mx:Number;
var e:Number;
var q:Number;
var sum:Number;
var p:Number;
v = charsToLongs(strToChars(src));
k = charsToLongs(strToChars(key));
n = v.length;
if (n == 0){
return ("");
};
if (n == 1){
var _temp1 = n;
n = (n + 1);
var _local14 = _temp1;
v[_local14] = 0;
};
z = v[(n - 1)];
y = v[0];
delta = 2654435769;
q = Math.floor((6 + (52 / n)));
sum = 0;
while (q-- > 0) {
sum = (sum + delta);
e = ((sum >>> 2) & 3);
p = 0;
while (p < (n - 1)) {
y = v[(p + 1)];
mx = ((((z >>> 5) ^ (y << 2)) + ((y >>> 3) ^ (z << 4))) ^ ((sum ^ y) + (k[((p & 3) ^ e)] ^ z)));
z = (v[p] = (v[p] + mx));
p++;
};
y = v[0];
mx = ((((z >>> 5) ^ (y << 2)) + ((y >>> 3) ^ (z << 4))) ^ ((sum ^ y) + (k[((p & 3) ^ e)] ^ z)));
z = (v[(n - 1)] = (v[(n - 1)] + mx));
};
return (charsToHex(longsToChars(v)));
}
public function decrypt(src:String, key:String):String{
var v:Array;
var k:Array;
var n:Number;
var z:Number;
var y:Number;
var delta:Number;
var mx:Number;
var e:Number;
var q:Number;
var sum:Number;
var p:Number;
v = charsToLongs(hexToChars(src));
k = charsToLongs(strToChars(key));
n = v.length;
if (n == 0){
return ("");
};
z = v[(n - 1)];
y = v[0];
delta = 2654435769;
q = Math.floor((6 + (52 / n)));
sum = (q * delta);
while (sum != 0) {
e = ((sum >>> 2) & 3);
p = (n - 1);
while (p > 0) {
z = v[(p - 1)];
mx = ((((z >>> 5) ^ (y << 2)) + ((y >>> 3) ^ (z << 4))) ^ ((sum ^ y) + (k[((p & 3) ^ e)] ^ z)));
y = (v[p] = (v[p] - mx));
p--;
};
z = v[(n - 1)];
mx = ((((z >>> 5) ^ (y << 2)) + ((y >>> 3) ^ (z << 4))) ^ ((sum ^ y) + (k[((p & 3) ^ e)] ^ z)));
y = (v[0] = (v[0] - mx));
sum = (sum - delta);
};
return (charsToStr(longsToChars(v)));
}
private static function strToChars(str:String):Array{
var codes:Array;
var i:Number;
codes = new Array();
i = 0;
while (i < str.length) {
codes.push(str.charCodeAt(i));
i++;
};
return (codes);
}
private static function charsToHex(chars:Array):String{
var result:String;
var hexes:Array;
var i:Number;
result = new String("");
hexes = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
i = 0;
while (i < chars.length) {
result = (result + (hexes[(chars[i] >> 4)] + hexes[(chars[i] & 15)]));
i++;
};
return (result);
}
private static function hexToChars(hex:String):Array{
var codes:Array;
var i:Number;
codes = new Array();
i = ((hex.substr(0, 2))=="0x") ? 2 : 0;
while (i < hex.length) {
codes.push(parseInt(hex.substr(i, 2), 16));
i = (i + 2);
};
return (codes);
}
private static function charsToStr(chars:Array):String{
var result:String;
var i:Number;
result = new String("");
i = 0;
while (i < chars.length) {
result = (result + String.fromCharCode(chars[i]));
i++;
};
return (result);
}
private static function longsToChars(longs:Array):Array{
var codes:Array;
var i:Number;
codes = new Array();
i = 0;
while (i < longs.length) {
codes.push((longs[i] & 0xFF), ((longs[i] >>> 8) & 0xFF), ((longs[i] >>> 16) & 0xFF), ((longs[i] >>> 24) & 0xFF));
i++;
};
return (codes);
}
private static function charsToLongs(chars:Array):Array{
var temp:Array;
var i:Number;
temp = new Array(Math.ceil((chars.length / 4)));
i = 0;
while (i < temp.length) {
temp[i] = (((chars[(i * 4)] + (chars[((i * 4) + 1)] << 8)) + (chars[((i * 4) + 2)] << 16)) + (chars[((i * 4) + 3)] << 24));
i++;
};
return (temp);
}
}
}//package security
Section 146
//AchievementEarned (AchievementEarned)
package {
import flash.display.*;
public dynamic class AchievementEarned extends MovieClip {
public function AchievementEarned(){
super();
}
}
}//package
Section 147
//AchievementIcon1 (AchievementIcon1)
package {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class AchievementIcon1 extends MovieClip {
public function AchievementIcon1(){
super();
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 148
//AchievementIcon2 (AchievementIcon2)
package {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class AchievementIcon2 extends MovieClip {
public function AchievementIcon2(){
super();
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 149
//AchievementIcon3 (AchievementIcon3)
package {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class AchievementIcon3 extends MovieClip {
public function AchievementIcon3(){
super();
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 150
//AchievementIncomplete (AchievementIncomplete)
package {
import flash.display.*;
public dynamic class AchievementIncomplete extends MovieClip {
public function AchievementIncomplete(){
super();
}
}
}//package
Section 151
//AdContainer (AdContainer)
package {
import flash.text.*;
import flash.display.*;
public dynamic class AdContainer extends MovieClip {
public var msText:TextField;
public var msAdArea:MovieClip;
public var msInvisibleButton:InvisibleButton;
public function AdContainer(){
super();
}
}
}//package
Section 152
//arachnophiliaMusic (arachnophiliaMusic)
package {
import flash.media.*;
public dynamic class arachnophiliaMusic extends Sound {
public function arachnophiliaMusic(){
super();
}
}
}//package
Section 153
//BonusWebbingBar (BonusWebbingBar)
package {
import flash.display.*;
public dynamic class BonusWebbingBar extends MovieClip {
public function BonusWebbingBar(){
super();
}
}
}//package
Section 154
//EnergySymbol (EnergySymbol)
package {
import flash.display.*;
public dynamic class EnergySymbol extends MovieClip {
public function EnergySymbol(){
super();
}
}
}//package
Section 155
//FactsToggle (FactsToggle)
package {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class FactsToggle extends MovieClip {
public function FactsToggle(){
super();
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 156
//FullBar (FullBar)
package {
import flash.display.*;
public dynamic class FullBar extends MovieClip {
public function FullBar(){
super();
}
}
}//package
Section 157
//GameOverOverlay (GameOverOverlay)
package {
import flash.text.*;
import flash.display.*;
import achievements.*;
public dynamic class GameOverOverlay extends MovieClip {
public var msFinalScore:TextField;
public var msAdContainer:AdContainer;
public var msMoreGamesButton:SimpleButton;
public var btnMainMenu:SimpleButton;
public var gsSoundAnchorSfx:MovieClip;
public var msViewHighscoresScoresButton:SimpleButton;
public var msSponsorButton:SimpleButton;
public var mcAchievements:AchievementsDisplay;
public var gsSoundAnchorMusic:MovieClip;
public function GameOverOverlay(){
super();
}
}
}//package
Section 158
//GraphicAnchor (GraphicAnchor)
package {
import flash.display.*;
public dynamic class GraphicAnchor extends MovieClip {
public function GraphicAnchor(){
super();
}
}
}//package
Section 159
//HungryBar (HungryBar)
package {
import flash.display.*;
public dynamic class HungryBar extends MovieClip {
public function HungryBar(){
super();
}
}
}//package
Section 160
//InvisibleButton (InvisibleButton)
package {
import flash.display.*;
public dynamic class InvisibleButton extends SimpleButton {
public function InvisibleButton(){
super();
}
}
}//package
Section 161
//InvisibleDYOGButton (InvisibleDYOGButton)
package {
import flash.display.*;
public dynamic class InvisibleDYOGButton extends SimpleButton {
public function InvisibleDYOGButton(){
super();
}
}
}//package
Section 162
//MarkedLargeGraphic (MarkedLargeGraphic)
package {
import flash.display.*;
public dynamic class MarkedLargeGraphic extends MovieClip {
public function MarkedLargeGraphic(){
super();
}
}
}//package
Section 163
//MarkedMediumGraphic (MarkedMediumGraphic)
package {
import flash.display.*;
public dynamic class MarkedMediumGraphic extends MovieClip {
public function MarkedMediumGraphic(){
super();
}
}
}//package
Section 164
//MarkedSmallGraphic (MarkedSmallGraphic)
package {
import flash.display.*;
public dynamic class MarkedSmallGraphic extends MovieClip {
public function MarkedSmallGraphic(){
super();
}
}
}//package
Section 165
//MouseCancel (MouseCancel)
package {
import flash.display.*;
public dynamic class MouseCancel extends MovieClip {
public function MouseCancel(){
super();
}
}
}//package
Section 166
//sfxAddWeb (sfxAddWeb)
package {
import flash.media.*;
public dynamic class sfxAddWeb extends Sound {
public function sfxAddWeb(){
super();
}
}
}//package
Section 167
//sfxAmbient (sfxAmbient)
package {
import flash.media.*;
public dynamic class sfxAmbient extends Sound {
public function sfxAmbient(){
super();
}
}
}//package
Section 168
//sfxAmbientOwl1 (sfxAmbientOwl1)
package {
import flash.media.*;
public dynamic class sfxAmbientOwl1 extends Sound {
public function sfxAmbientOwl1(){
super();
}
}
}//package
Section 169
//sfxAmbientOwl2 (sfxAmbientOwl2)
package {
import flash.media.*;
public dynamic class sfxAmbientOwl2 extends Sound {
public function sfxAmbientOwl2(){
super();
}
}
}//package
Section 170
//sfxBatApproach (sfxBatApproach)
package {
import flash.media.*;
public dynamic class sfxBatApproach extends Sound {
public function sfxBatApproach(){
super();
}
}
}//package
Section 171
//sfxBeeApproach (sfxBeeApproach)
package {
import flash.media.*;
public dynamic class sfxBeeApproach extends Sound {
public function sfxBeeApproach(){
super();
}
}
}//package
Section 172
//sfxButtonDown (sfxButtonDown)
package {
import flash.media.*;
public dynamic class sfxButtonDown extends Sound {
public function sfxButtonDown(){
super();
}
}
}//package
Section 173
//sfxButtonOver (sfxButtonOver)
package {
import flash.media.*;
public dynamic class sfxButtonOver extends Sound {
public function sfxButtonOver(){
super();
}
}
}//package
Section 174
//sfxCricket2 (sfxCricket2)
package {
import flash.media.*;
public dynamic class sfxCricket2 extends Sound {
public function sfxCricket2(){
super();
}
}
}//package
Section 175
//sfxDragonflyApproach (sfxDragonflyApproach)
package {
import flash.media.*;
public dynamic class sfxDragonflyApproach extends Sound {
public function sfxDragonflyApproach(){
super();
}
}
}//package
Section 176
//sfxDYOG (sfxDYOG)
package {
import flash.media.*;
public dynamic class sfxDYOG extends Sound {
public function sfxDYOG(){
super();
}
}
}//package
Section 177
//sfxEatLoop (sfxEatLoop)
package {
import flash.media.*;
public dynamic class sfxEatLoop extends Sound {
public function sfxEatLoop(){
super();
}
}
}//package
Section 178
//sfxFireFlyCaught (sfxFireFlyCaught)
package {
import flash.media.*;
public dynamic class sfxFireFlyCaught extends Sound {
public function sfxFireFlyCaught(){
super();
}
}
}//package
Section 179
//sfxFlyApproach1 (sfxFlyApproach1)
package {
import flash.media.*;
public dynamic class sfxFlyApproach1 extends Sound {
public function sfxFlyApproach1(){
super();
}
}
}//package
Section 180
//sfxFlyApproach2 (sfxFlyApproach2)
package {
import flash.media.*;
public dynamic class sfxFlyApproach2 extends Sound {
public function sfxFlyApproach2(){
super();
}
}
}//package
Section 181
//sfxFlyApproach3 (sfxFlyApproach3)
package {
import flash.media.*;
public dynamic class sfxFlyApproach3 extends Sound {
public function sfxFlyApproach3(){
super();
}
}
}//package
Section 182
//sfxGameOver (sfxGameOver)
package {
import flash.media.*;
public dynamic class sfxGameOver extends Sound {
public function sfxGameOver(){
super();
}
}
}//package
Section 183
//sfxHummingbirdHover (sfxHummingbirdHover)
package {
import flash.media.*;
public dynamic class sfxHummingbirdHover extends Sound {
public function sfxHummingbirdHover(){
super();
}
}
}//package
Section 184
//sfxLowHealthLoop (sfxLowHealthLoop)
package {
import flash.media.*;
public dynamic class sfxLowHealthLoop extends Sound {
public function sfxLowHealthLoop(){
super();
}
}
}//package
Section 185
//sfxNoWebbing (sfxNoWebbing)
package {
import flash.media.*;
public dynamic class sfxNoWebbing extends Sound {
public function sfxNoWebbing(){
super();
}
}
}//package
Section 186
//sfxQueueEat (sfxQueueEat)
package {
import flash.media.*;
public dynamic class sfxQueueEat extends Sound {
public function sfxQueueEat(){
super();
}
}
}//package
Section 187
//sfxSpiderMove (sfxSpiderMove)
package {
import flash.media.*;
public dynamic class sfxSpiderMove extends Sound {
public function sfxSpiderMove(){
super();
}
}
}//package
Section 188
//sfxStagbeetleApproach (sfxStagbeetleApproach)
package {
import flash.media.*;
public dynamic class sfxStagbeetleApproach extends Sound {
public function sfxStagbeetleApproach(){
super();
}
}
}//package
Section 189
//sfxWebBreak (sfxWebBreak)
package {
import flash.media.*;
public dynamic class sfxWebBreak extends Sound {
public function sfxWebBreak(){
super();
}
}
}//package
Section 190
//SpiderWebbingWarning (SpiderWebbingWarning)
package {
import flash.display.*;
public dynamic class SpiderWebbingWarning extends MovieClip {
public function SpiderWebbingWarning(){
super();
}
}
}//package
Section 191
//TutorialToggle (TutorialToggle)
package {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.media.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
import flash.geom.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
public dynamic class TutorialToggle extends MovieClip {
public function TutorialToggle(){
super();
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 192
//WebbingBar (WebbingBar)
package {
import flash.display.*;
public dynamic class WebbingBar extends MovieClip {
public function WebbingBar(){
super();
}
}
}//package
Section 193
//WebbingSymbol (WebbingSymbol)
package {
import flash.display.*;
public dynamic class WebbingSymbol extends MovieClip {
public function WebbingSymbol(){
super();
}
}
}//package
Section 194
//WebbingWarning (WebbingWarning)
package {
import flash.display.*;
public dynamic class WebbingWarning extends MovieClip {
public function WebbingWarning(){
super();
}
}
}//package
Section 195
//VersionWarning (VersionWarning)
package {
import flash.text.*;
import flash.display.*;
public dynamic class VersionWarning extends MovieClip {
public var tfYourVersion:TextField;
public var tfRequiredVersion:TextField;
public var btnUpdateFlash:SimpleButton;
public function VersionWarning(){
super();
}
}
}//package