Amicuk Programming Answers

Child is detecting click even though it shouldn't

-0001-11-30   Views:0


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

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)) {
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])) {
                } else if (!stage.contains(sceneArray[2]) && stage.contains(detectArray[0]) && stage.contains(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") {
                                       // else clicks can't be heard               
                    } else if (stage.contains(sceneArray[jk])
                        && sceneGuyArray[jk].currentLabel != "guy_At"+wordArray[jk]+"Normal") {

The replay answer
Hi, tytbone;
I'm not going to sort through your logic, because, frankly, it's way too complicated. Complicated logic is hard to debug, and the way you've done it is not likely to perform well.
Try something like this:
//Not sure what class you've actually applied to the parent,
//so this name is made up
//Not applying a Class? Maybe you should start.
public class ParentClass extends MovieClip {
     //Assuming you've got these on stage an you're going to let Flash populate them
     //mainly because logic to create, add, and position things is tedious and I refuse to write it
     public var treeToChopDetect:MovieClip;
     public var guy_Bridge:MovieClip;
     public function ParentClass() {
          //added to stage doesn't bubble, use capture
          addEventListener(Event.ADDED_TO_STAGE, initNewChild, true);
     protected function initNewChild(e:Event):void {
          var newChild:MovieClip = as MovieClip;
          if (newChild) {
               switch( {
                    case 'treeToChopDetect':
                         mouseChildren = false;
                         mouseEnabled = false;
                    case 'guy_Bridge':
                         //find relevant frame
                         var frameNum:int = -1;
                         for each (var frameLabel:FrameLabel in newChild.currentFrameLabels) {
                              if ('guy_AtBridgeNormal') {
                                   frameNum = frameLabel.frame -1;
                         if (frameNum > -1) {
                              //could do this on the timeline of the child mc or with 
                              //a base class...this is just for illustration purposes
                              //tell guy at bridge to dispatch this event when he gets to the frame
                              newChild.addFrameScript(frameNum, function(){dispatchEvent(new Event('guy_AtBridgeNormal'))});
                              //listen for that event so you can unlock the tree
                              newChild.addEventListener('guy_AtBridgeNormal', unlockTree);
                    }//end case
               }//end if the child was actually a movie clip
          }//end init
          protected function unlockTree(e:Event):void {
               guy_Bridge.removeEventListener('guy_AtBridgeNormal', unlockTree);
               treeToChopDetect.mouseEnabled = true;
               treeToChopDetect.addEventListener(MouseEvent.CLICK, onTreeChop);
          protected function onTreeChop(e:Event):void {
                //do stuff

Go to See the other 6 answers

Child is detecting click even though it shouldn't

Category:DefaultRelease time:-0001-11-30Views:130

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[More]

Detecting Clicks on Lines

Category:DefaultRelease time:-0001-11-30Views:130

Hello,    I am building a canvas application that allows users to drag and drop different icons on the canvas and connect them through edges. I am using the graphics of the canvas to draw these lines. However, one of my requirements is to detect clic[More]

Detecting clicked column in JTable (with JCheckBox in column)

Category:DefaultRelease time:-0001-11-30Views:130

I am struggling with something that seems like it should be so simple, but it doesn't work as I expect; I have a table with 5 columns, the 5th column is a CheckBox. What I need to do is detect when the 5th column changes, ie. the check box is clicked[More]

Detect click and coordinates on a PDA

Category:DefaultRelease time:-0001-11-30Views:130

Hello everybody, I'm trying to detect a stylus click on a picture and the coordinates of the click on a PocketPC 2002 PDA. In the PC, this works fine with a "mouse down" event for a picture, which detects the click and the coordinates, but this[More]

Detecting Click on an MC inside an attached movieclip

Category:DefaultRelease time:-0001-11-30Views:130

I'm working with a MovieClip ("mainMenuItem") that is linked to a Class ("") that uses attachMovie to add another movieclip ("Arrow") to mainMenuItem as follows: mcArrow = this.attachMovie(prefix+"Arrow[More]

Detecting click ( single and double) on row (displayed using iterator)

Category:DefaultRelease time:-0001-11-30Views:130

Hello All, I am using jdev I am displaying a list as below.                                <trh:tableLayout>                                     <af:iterator value="#{pageFlowScope.Bean.List}" var="temp">          [More]

Detecting clicks over a particular region in the frame

Category:DefaultRelease time:-0001-11-30Views:130

Hey! I need to detect whether te user clicked over a particular region in my frame.. something delimited by a poligon... or something like that.. some ideas? thank you in advance!Thx for your attention but in this case it wont work 'cause.. I didnt m[More]

Stopping the applications main window from activating when a child window is clicked

Category:DefaultRelease time:2015-10-11Views:130

I am building a javascript based AIR application that implements a bastardized growl notifier.  When the the application is minimized or in the background you may be notified of a new message.  This part works great. The UI calls for an "X" butt[More]

Detect clicked cluster in mouse down event for clusters within multiple stacked clusters

Category:DefaultRelease time:-0001-11-30Views:130

With the help of Ben (see I could easily find out what sub-cluster had been clicked on (mouse down event) within the main cluster, by using the Label.[More]

How can i detect click on JTextField

Category:DefaultRelease time:-0001-11-30Views:130

I want do some opration on JTextField when Click on JextField how should i do that please tell me RahulQuit multi-posting and cross-posting. You've already posted this question twice in the Swing forum where it belongs.Read other 2 answers[More]

Detecting a mouse click on any (all) child components...

Category:DefaultRelease time:-0001-11-30Views:130

Hey All, I am writing a number of compound GUI elements that i want to make focusable when you click any part of them. (i.e. a JTextArea inside a JScrollPane, coupled to a JTextField to provide input to the JTextArea). Is there an easy way to detect[More]

I have a HP Photosmart 5514 whose touch screen is no longer working properly.  It doesn't recognize any selection at the bottom right of the screen.  I can touch any other place on the screen and it will respond.  Because of this I'm no longer able t [More]
You know how the letters pop up from under your finger when keys a pressed on the keyboard to let you know which key you press, well sometimes certain letters on my keyboard stop popping up. A restart fixes the key but a few minutes or hours (intermi [More]
Basically, exactly waht I said in the post. When I 'send to' final cut after correcting a video, I try to open the new sequence. Firstly the sequence doesn't have the name of the Color file, it just comes up as a timecode. And secondly when viewed in [More]
When I add a contact, and that person is also using iPhone, I can't define that. I can choose all kinds of things, like radio, fax, home, mobile,.. but not iPhone... This also means I can't use iMessage whit that person. How can I change this?Hi Blar [More]
I know how to autostart something. From - ostart_way I'm using the advanced method of the simple way (that takes 4 parameters). It's working fine, but everything starts at the first tag. I tried to use the awfu [More]
I need to determine at run time if a jar has been signed with our certificate. All the classes I've looked at are Sun classes, or are inaccessable (JarVerifier). Does someone have some code that does this, preferrably without the sun classes? I'll ta [More]
Hi I was just given my Aunt's old Creative Zen NX player, but she'd lost the disk with drivers etc on it, so i downloaded from the website the following: Drivers: Creative Zen and Jukebox Driver Upgrade version .30.03 Firmware: Creative Jukebox Zen N [More]
Dear Friends, can please anyone help me in the following Issue which i am facing ASAP? Payable Invoices( R12.1.1) created by the head office should not be accessed by other branches, but head office can see all the payable invoices created by anyone. [More]
Hi, I have situation where in I need to create dynamic sql statements based on user input. let's say user changes his last name or only first name or some comments field only those fileds changed should be updated in database leaving rest un changed. [More]
I've reinstalled it ans still receiving the same message: The application has encountered with a serious problem and must close,  if a correction is found windows will contact me. This has been going on for over two weeks.Dear Thomas558 - Depending o [More]