jclaine
September 23rd, 2009, 03:31 PM
Ok, so I'm making a game in as3 & cs4 while coding in flashdevelop.
The game requires me to keep track of and tell robots to go to an x position and build something. There is some priority as to what robot gets selected based on their current task. So i have 3 arrays set up in a globalvars class, I then sort these arrays in order of least priority. There will be instances of the array being completely empty so I check to see if the GLOBALVARS.aBobIdle is undefined. When I exicute the code does not trace any of the trace functions and traces out a bunch of lines in the output pannel that look like this
3:debugline 19
stack:
scope: [global Object$]
locals: Scripts::BOBHandler$ Boolean int String? flash.display::MovieClip? *
5:getlocal0
stack: Scripts::BOBHandler$
scope: [global Object$]
locals: Scripts::BOBHandler$ Boolean int String? flash.display::MovieClip? *
at the end of it all is
VerifyError: Error #1030: Stack depth is unbalanced. 0 != 1.
at Scripts::BOBHandler$/BOBSort()
at Scripts.Supports_Build::Iron_Build/addBuildOBot()[C:\Documents and Settings\gd13jordan\Desktop\LOCAL HD KeepItUp\Prototypes\GamePlay\Scripts\Supports_Buil d\Iron_Build.as:121]
at Scripts::SupportMouseListener/addBuildOBot()[C:\Documents and Settings\gd13jordan\Desktop\LOCAL HD KeepItUp\Prototypes\GamePlay\Scripts\SupportMouseL istener.as:111]
Should i be doing something diffrent for the array comparison, if so how do i detect an empty array?
Here is the class, I can upload the rleated classes if needed but this seems to be isolated to this class.
package Scripts {
import flash.display.MovieClip;
import Scripts.GLOBALVARS;
/**
* ...
* @author Jordan Laine
*/
public class BOBHandler {
public static var nBOBX:int
public var main;
//public var nBOBX:int;
public function BOBHandler () {
main = this;
}
public static function BOBSort(bDouble:Boolean, nLoc:int, runState:String, mcSupport:MovieClip) {
nBOBX = mcSupport.x;
var mcBob:MovieClip;
if (GLOBALVARS.aBobIdle[0] != undefined) {
trace("Im in here 1");
GLOBALVARS.aBobIdle.sort(BOBLocationUpDate);
if (runState == "repair") {
mcBob = GLOBALVARS.aBobIdle[0];
GLOBALVARS.aBobRepair.unshift(mcBob);
GLOBALVARS.aBobIdle.splice[1, 0];
} else if (runState == "build") {
mcBob = GLOBALVARS.aBobIdle[0];
GLOBALVARS.aBobBuild.unshift(mcBob);
GLOBALVARS.aBobIdle.splice[1, 0];
}
GLOBALVARS.aBobIdle[0].Move(bDouble, nLoc, runState, mcSupport);
} else if (GLOBALVARS.aBobRepair[0] != undefined) {
trace("Im in here 2");
GLOBALVARS.aBobRepair.sort(BOBLocationUpDate);
if (runState == "repair") {
/*mcBob = GLOBALVARS.aBobIdel[0];
GLOBALVARS.aBobRepair.unshift(mcBob);
GLOBALVARS.aBobIdel.splice[1, 0];*/
trace("this BOB was repairing");
} else if (runState == "build") {
mcBob = GLOBALVARS.aBobRepair[0];
GLOBALVARS.aBobBuild.unshift(mcBob);
GLOBALVARS.aBobRepair.splice[1, 0];
}
GLOBALVARS.aBobRepair[0].Move(bDouble, nLoc, runState, mcSupport);
} else {
trace("Im in here 3");
GLOBALVARS.aBobBuild.sort(BOBLocationUpDate);
if (runState == "repair") {
mcBob = GLOBALVARS.aBobBuild[0];
GLOBALVARS.aBobRepair.unshift(mcBob);
GLOBALVARS.aBobBuild.splice[1, 0];
} else if (runState == "build") {
/* mcBob = GLOBALVARS.aBobRepair[0];
GLOBALVARS.aBobBuild.unshift(mcBob);
GLOBALVARS.aBobRepair.splice[1, 0]; */
trace("this BOB was Building");
}
GLOBALVARS.aBobBuild[0].Move(bDouble, nLoc, runState, mcSupport);
}
}
public static function BOBLocationUpDate (a:MovieClip, b:MovieClip):Number {
var aX:int = a.x;
var bX:int = b.x;
aX - nBOBX;
bX - nBOBX;
if(aX > bX) {
return -1;
} else if (aX < bX) {
return 1;
} else {
return 0;
}
}
}
}
The game requires me to keep track of and tell robots to go to an x position and build something. There is some priority as to what robot gets selected based on their current task. So i have 3 arrays set up in a globalvars class, I then sort these arrays in order of least priority. There will be instances of the array being completely empty so I check to see if the GLOBALVARS.aBobIdle is undefined. When I exicute the code does not trace any of the trace functions and traces out a bunch of lines in the output pannel that look like this
3:debugline 19
stack:
scope: [global Object$]
locals: Scripts::BOBHandler$ Boolean int String? flash.display::MovieClip? *
5:getlocal0
stack: Scripts::BOBHandler$
scope: [global Object$]
locals: Scripts::BOBHandler$ Boolean int String? flash.display::MovieClip? *
at the end of it all is
VerifyError: Error #1030: Stack depth is unbalanced. 0 != 1.
at Scripts::BOBHandler$/BOBSort()
at Scripts.Supports_Build::Iron_Build/addBuildOBot()[C:\Documents and Settings\gd13jordan\Desktop\LOCAL HD KeepItUp\Prototypes\GamePlay\Scripts\Supports_Buil d\Iron_Build.as:121]
at Scripts::SupportMouseListener/addBuildOBot()[C:\Documents and Settings\gd13jordan\Desktop\LOCAL HD KeepItUp\Prototypes\GamePlay\Scripts\SupportMouseL istener.as:111]
Should i be doing something diffrent for the array comparison, if so how do i detect an empty array?
Here is the class, I can upload the rleated classes if needed but this seems to be isolated to this class.
package Scripts {
import flash.display.MovieClip;
import Scripts.GLOBALVARS;
/**
* ...
* @author Jordan Laine
*/
public class BOBHandler {
public static var nBOBX:int
public var main;
//public var nBOBX:int;
public function BOBHandler () {
main = this;
}
public static function BOBSort(bDouble:Boolean, nLoc:int, runState:String, mcSupport:MovieClip) {
nBOBX = mcSupport.x;
var mcBob:MovieClip;
if (GLOBALVARS.aBobIdle[0] != undefined) {
trace("Im in here 1");
GLOBALVARS.aBobIdle.sort(BOBLocationUpDate);
if (runState == "repair") {
mcBob = GLOBALVARS.aBobIdle[0];
GLOBALVARS.aBobRepair.unshift(mcBob);
GLOBALVARS.aBobIdle.splice[1, 0];
} else if (runState == "build") {
mcBob = GLOBALVARS.aBobIdle[0];
GLOBALVARS.aBobBuild.unshift(mcBob);
GLOBALVARS.aBobIdle.splice[1, 0];
}
GLOBALVARS.aBobIdle[0].Move(bDouble, nLoc, runState, mcSupport);
} else if (GLOBALVARS.aBobRepair[0] != undefined) {
trace("Im in here 2");
GLOBALVARS.aBobRepair.sort(BOBLocationUpDate);
if (runState == "repair") {
/*mcBob = GLOBALVARS.aBobIdel[0];
GLOBALVARS.aBobRepair.unshift(mcBob);
GLOBALVARS.aBobIdel.splice[1, 0];*/
trace("this BOB was repairing");
} else if (runState == "build") {
mcBob = GLOBALVARS.aBobRepair[0];
GLOBALVARS.aBobBuild.unshift(mcBob);
GLOBALVARS.aBobRepair.splice[1, 0];
}
GLOBALVARS.aBobRepair[0].Move(bDouble, nLoc, runState, mcSupport);
} else {
trace("Im in here 3");
GLOBALVARS.aBobBuild.sort(BOBLocationUpDate);
if (runState == "repair") {
mcBob = GLOBALVARS.aBobBuild[0];
GLOBALVARS.aBobRepair.unshift(mcBob);
GLOBALVARS.aBobBuild.splice[1, 0];
} else if (runState == "build") {
/* mcBob = GLOBALVARS.aBobRepair[0];
GLOBALVARS.aBobBuild.unshift(mcBob);
GLOBALVARS.aBobRepair.splice[1, 0]; */
trace("this BOB was Building");
}
GLOBALVARS.aBobBuild[0].Move(bDouble, nLoc, runState, mcSupport);
}
}
public static function BOBLocationUpDate (a:MovieClip, b:MovieClip):Number {
var aX:int = a.x;
var bX:int = b.x;
aX - nBOBX;
bX - nBOBX;
if(aX > bX) {
return -1;
} else if (aX < bX) {
return 1;
} else {
return 0;
}
}
}
}