9 Replies Latest reply on Sep 14, 2006 11:42 AM by jordana309

    Multiple event handlers?

    jordana309
      I have a training simulation project, and for it my team has created some custom Flash components. Of these, there is a linkButton that is transparent on the stage, and when the user mouses over, it changes color so that they know they've moused over it. On release, it checks to see if it was a right click or not, adds 1 to the apropriate global variable (right click v. wrong click), checks a list of required clicks to see if all things were clicked on, then, if so, moves on to the next "page" in the training. With these buttons there is another component, a popup, that picks up the right/wrong click, changes color, and changes text (for a hint if wrong, <b>Correct!</b> if right).
      However, when I added the lines that put "Correct!" on the bottom of the popup, for some weird reason, the link button stopped registering it's on(Realease) function. So, it's now very broken. I have a deadline for Wednesday, and it wont work. I'm not sure why. Below is the code for both release funtions, button first.

      So, any ideas?
      Thank you very much, and sorry that this is so long! I'm trying to be as helpful as I can be so that you can be as helpful as can be.

      Jordan
        • 1. Re: Multiple event handlers?
          injpix Level 3
          I haven’t fully read your post but in the meantime I think you might be interested in this article and what it has to offer;

          http://www.adobe.com/devnet/flash/articles/eventproxy.html
          • 2. Re: Multiple event handlers?
            injpix Level 3
            In your code you posted you have;
            _level2.gotoAndStopPlay(1);

            Is this a function you or another developer built or is it intended to access Flash’s built-in methods (gotoAndPlay() or gotoAndStop())?


            Also in your second half of your code you have;
            var releaseInstance = this._parent[_rollOverInstance];

            I am not sure if this is working, if it doesn’t you might be interested using the following property;
            http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00002485.html

            But a more elegant way of doing this would be to use the Proxy class that I posted a link to earlier.

            And at the bottom of that half of code;
            this.press();

            I am unsure on what this is intended to do.
            • 3. Multiple event handlers?
              jordana309 Level 1
              Sorry. this.press() is a function written simply to fill the press event. Why my partner coded it that way i'm still scratching my head over. But those "this.press()" and "this.releaseOutise" change the opacity of the linkButton object. Again, why they're seprate functions, I'm not exactly sure. _level2.gotoAndStop() is all it should be. I'm sorry for the typo on my part.

              this._parent[_rollOverInstance] refers to the parameter on the popup that specifies the instance it will popup on. For example, a linkButton with an instance name of "cellE4" would be refrenced in the _rollOverInstance perameter, called here. I apologize for the confusion.

              Also, how would you use this proxy method across the two components? All code needs to be component-side. I apologize also for this being posted multiple times: I continued to get "server is taking too long to respond" errors, and would click back, then resubmit, and I guess they weren't failed attempts at posting after all...

              Where do I download the updated mx.utils.Delegate packages? And where do I put them? That appears to be exactly the solution I was looking for! So, that you very much!

              Jordan
              • 4. Multiple event handlers?
                jordana309 Level 1
                --ERROR DUPLICATE POSTS--
                • 5. Multiple event handlers?
                  jordana309 Level 1
                  --ERROR: DUPLICATE POSTS--
                  • 6. Re: Multiple event handlers?
                    injpix Level 3
                    If you have Flash MX 2004 version 7.2 they should already be on your computer. I am using Flash 8 so the path will be different if using Flash MX;

                    C:\Program Files\Macromedia\Flash 8\en\First Run\Classes\mx\utils

                    The article shows you how to use it.
                    • 7. Re: Multiple event handlers?
                      jordana309 Level 1
                      One final question. How would I go about putting this into implimentation across the two components? I can see for a single document, and despite the complication levels involved, I am by no means expert in the ways of Flash. Thank you again!
                      ja
                      • 8. Re: Multiple event handlers?
                        injpix Level 3
                        Well after looking at your code again, using the Proxy class will not work. The Proxy class is for Flash components.

                        You mentioned that when you add the “Correct!” text the link button onRelease event handler is no longer in use. I am thinking that second onRelease event handler, the one that uses the “_rollOverInstance” is overwriting the first event handler. I could be wrong; I am having a hard time piecing together your code and visualize the movieclip hierarchy. Try putting a couple of trace statements in the event handlers and see what Flash is executing. If needed post the file online.
                        • 9. Re: Multiple event handlers?
                          jordana309 Level 1
                          I found out my problem. I call this.release() after the popup's realse function, and this calls the button's release function. I just had to write code in the realease() function for the button, and it worked.