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]

Hi there, I moved into iCloud from the very beginning and started with one iCloud account for me and my family, making use of email aliases for family members. Now the number of personal iDevices grows and I want to create a new and separate iCloud A [More]
I created and edited a slide show in PSE7 and closed the slide show editor. I now have an image in the organizer which has a slide show icon in the upper right hand corner. When I click or double click on it, nothing happens and PSE7 stops operating. [More]
I have put a disc in the tray of my MACbook pro that was sent to me with photos on. It is making a skipping sound in the tray, will not load and more importantly wont eject. HELP! Would really appreciate any suggestions how to ejct the disc. I have t [More]
Hi, Can anybody tell me what are the API's for PO and INV modules in 11i and R12? Regards, Bharathi.Post it in this forum Discrete ManufacturingRead other 4 answers [More]
<p>We want to add link to each report which redirects user to our page.  </p><p> </p><p>So far we have found: </p><p>On InfoView page, there is listing of info objects(reports, hyperlink, programs) - listing.aspx. [More]
Hi, Running Server 2012 R2  I have a requirement to convert a vhdx to vhd. I used the builtin feature in the hyperv manager to convert the vhdx (Fixed) disk to a vhd (fixed). When i create a new server an attach this vhd disk, i get an error when the [More]
Client use SharePoint 2013. I have to develop a custom webservice for this SharePoint. Webservice will receive some information as request, will fill in a InfoPath form (on based existing infopath template from library) with this information and save [More]
i have no external hardriveBasics of File Recovery If you simply put files in the Trash you can restore them by opening the Trash (left-click on the Trash icon) and drag the files from the Trash to your Desktop or other desired location. OS X also pr [More]
My O/S is Windows 7. Recently I used Windows Installer Clean Up and it removed the Adobe Reader and other Adobe files. I have tried to download the current Adobe Reader but get a message that it is already installed on my computer. I have checked in [More]
Hi all! does the default DBCA installation creates the database with shared servers and not dedicated server? These are the parameters in this brand new installation. shares_servers =1 and dispatchers is set to something.. I have to set them to 0 and [More]