Child is detecting click even though it shouldn't
Hello once again,
I technically know how to make this work right, but I'm trying to figure out what I want to do won't work right.
I have a Child ("treeToChopDetect") appear when a certain other child ("sceneArray[2]") appears on stage. However, I don't want "treeToChopDetect" to be clickable until another child "guy_Bridge"/ "sceneGuyArray[2]" (the character) reaches frame "guy_AtBridgeNormal" on his own timeline.
However, "treeToChopDetect" seems to be clickable even though the "manager" function is suppose to be constantly telling the "detectArray" that mouseEnabled = false until "sceneGuyArray[2].currentLabel == "guy_AtBridgeNormal"". I keep getting a trace as output if I click on "treeToChopDetect".
I can keep it from being clickable if I set the condition to include "canClickBoo == false" (which it is until the guy reaches the right frame), but I shouldn't have to do that.
For all my other arrays I've been able to use my "manager" function to run through them (via "for" loops) and turn mouseEnabled on and off depending on if the guy is on the right frame, but something isn't working correct with this array, for some reason.
Sorry if that's confusing. I can try to clarify or add more information if necessary. (I have 600+ lines of code so of course I tried to chop out whatever I could.)
The var and array:
var treeToChopDetect:TreeToChopDetect = new TreeToChopDetect;
treeToChopDetect.x = 355;
treeToChopDetect.y = 75;
detectArray = [treeToChopDetect];
The function to detect: (if I add in canClickBoo == true to the stipulation, it runs correctly; however I don't know why I have to do this)
function detectFunction(event:MouseEvent) {
if (treeToChopDetect.hitTestPoint(mouseX, mouseY, true)) {
trace("treeToChopDetect");
}
}
These two functions are run when called in other functions, and they turn on and off the ability to click.
function canClick() {
canClickBoo = true;
canFunBoo = true;
}
function cantClick() {
canClickBoo = false;
canFunBoo = false;
}
main function that adds/removes "outside" children and defines what canClickBoo or canFunBoo means
function manager(event:Event) {
//listen to see what should appear
if (stage.contains(sceneArray[2])) {
addChild(detectArray[0]);
addChild(detectArray[1]);
} else if (!stage.contains(sceneArray[2]) && stage.contains(detectArray[0]) && stage.contains(detectArray[1])) {
removeChild(detectArray[0]);
removeChild(detectArray[1]);
}
//IF canClickBoo is true, able the mouse/turn on buttonMode
if (canClickBoo == true) {
... (various other arrays get turned on)
for (var im:uint=0; im<detectArray.length; im++) {
detectArray[im].mouseEnabled = true;
detectArray[im].buttonMode = true;
}
//ELSE IF canClickBoo is false, disable the mouse/turn off buttonMode
} else if (canClickBoo == false) {
for (var iy:uint=0; iy<detectArray.length; iy++) {
detectArray[iy].mouseEnabled = false;
detectArray[iy].buttonMode = false;
}
}
//if the scene and frame are correct, clicks can be heard
for (var jk:uint = 0; jk<sceneArray.length; jk++) {
if (stage.contains(sceneArray[jk])
&& sceneGuyArray[jk].currentLabel == "guy_At"+wordArray[jk]+"Normal") {
//trace("canClick");
canClick();
// else clicks can't be heard
} else if (stage.contains(sceneArray[jk])
&& sceneGuyArray[jk].currentLabel != "guy_At"+wordArray[jk]+"Normal") {
trace("cantClick");
cantClick();
}
}
}
}
}
}
