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 am unable to open Hyperion web analysis studio. Probably there is some issue with Java. I've tried re-installed, updated with java but issue still persists. Following is appearing in java console: Java Plug-in 1.6.0_24 Using JRE version 1.6.0_24-b0 [More]
I have an iphone Daughter has an ipod - - both use the same itunes account for store/music purchases within each device. When using the Computer/iTunes - - for simplicity sake I want to make a new Library for my daughters iPod, she just needs to see [More]
Everytime i try to update my apps its says there is an error (20) I just bought the computer.. Is it because the person before me had them under their itunes?? Its like iphoto and igarage etc.. arent those standard on the computer? Please help. Thank [More]
When I close Firefox, I clear everything except the "Form & Search History" which is greyed-out so I can't access it. Also, the options I can choose are not saved by Firefox.Start Firefox in [[Safe Mode]] to check if one of your add-ons is c [More]
It won't start up.  Now I'm scared that that person can manage to reboot the laptop and steal all my personal information. Is that likely/ possible?  I looked at what sort of information is stored in one of my user accounts, and it's mainly applicati [More]
Having two E72 is very useful when upgrading firmware. The one I have just upgraded to firmware 054.005 only frequently has difficulty/doesn't the compass in Ovi Maps 3.04, wave as I will according to manual, in or out of my car, the house, whatever. [More]
Friends, I have purchased some woo-woo brain wave meditation CD that requires it be downloaded to my ipod in a non-compressed file format -- either .wav or aiff. I have absolutely no idea what that means or how to do it. HELP!!Change your import sett [More]
HI , can any body give reference for Powershell command for Access Service 2010 I am currently able to run powershell command for Access Service . But in sharepoint 2013,Access Service 2010 is a new service, but i am not able to see any refernce blog [More]
I'm trying to create a pie chart and would like to rotate the text in some of the wedges on the chart. If I open a new text box, it will allow me to rotate the box. For labels generated by the spreadsheet data, I cannot figure out how to do the same [More]
Today, all of a sudden I was unable to close some documents that somehow got saved as docx docs, without my doing so. They are all word docs and all related to my new office 2011 program. I tried to solve the problem by closing word, and then the col [More]