3 Replies Latest reply on Sep 21, 2009 12:41 PM by shintashi

    Never Ending Function?

    shintashi Level 1

      I made this function for a submenu to change a textbox in a whitespace movieclip (called white).

       

      The problem is the onMouseDown function never turns off even if the cursor isn't in contact with a menu option. I wouldn't have noticed if I didn't have an htmltext with a jpg file in it that clearly "refreshed" every time I clicked the screen. As far as I know, something like Void or Break might work, but I don't have luck with guessing how those commands work.

       


          function react(menu_item, textFile){   
              if(menu_item.hitTest(_root._xmouse, _root._ymouse, true)){
                  onMouseDown = function(){
              asFile = new LoadVars();
      asFile.onLoad = function(){white.myText_txt.htmlText = this.content; menu_item._parent.gotoAndStop(1);}
      asFile.load(textFile);}
                  }
              }

        • 1. Re: Never Ending Function?
          webqaflash Level 3

          function react(menu_item, textFile){  

           

           

           

          function react(menu_item:MovieClip, textFile:String){

          • 2. Re: Never Ending Function?
            Ned Murphy Adobe Community Professional & MVP

            onMouseDown is a mouse event, not an object interacton event, meaning if you click down with the mouse anyewhere the onMouseDown event occurs.  If you want to have something in particular react to an onMouseDown event, then you should use the instance.onPress coding.

            1 person found this helpful
            • 3. Re: Never Ending Function?
              shintashi Level 1

              the onPress would interfere with this list that controls the main menu:

               

               

              function ck(movie, scene){movie.onPress = function(){movie.gotoAndStop(2); pl.gotoAndStop(scene);}
                  }
              function uk(movie){movie.onDragOut = movie.onRelease = function(){movie.gotoAndStop(1);}
                  }

               

              function pk(movie){movie.onRollOver = function(){movie.gotoAndStop(2);}
                  }   
              function rk(movie){movie.onDragOut = movie.onRollOut = function(){movie.gotoAndStop(1);}
                  }

               

               

              Basically, I've got three dimensions:

               

              tab1

              |

              +--- Menu1

              |+submenu1

              |+submenu2

              |

              +--- Menu2

              |+submenu1

              |+submenu2

              |

              +--- Menu3

              |+submenu1

              |+submenu2

              |

               

              tab2

              |

              +--- Menu1

              |+submenu1

              |+submenu2

              |

              +--- Menu2

              |+submenu1

              |+submenu2

              |

              +--- Menu3

              |+submenu1

              |+submenu2

               

               

              I've got 7 tabs with an average of 5-6 menu options each, and many of the Menus have submenus. The problem I ran into was the onPress not working on the submenus, because they are embedded in the menus. That's why I went with onMouseDown and tried to use a "hit test" to filter it. The problem is once the hit test is switched "on" it doesn't switch back off; only another hit test detection for another button will switch it.

              It's like I created an unseen variable that remembers the last button I moused over, but it never clears that variable. If there was a way to clear that variable when the menu screen closes (what happens when the parent goes back to frame 1) then the whole problem would be solved.

               

              There's probably some alternative way to detect my submenus, or rewrite the menu detection that I'm missing.