22 Replies Latest reply on Nov 14, 2006 7:50 AM by kglad

    Wierd code corruption

    Bob_Robertson Level 1
      I've been working on a SCORM-compatible Flash movie for a while now, and it's almost complete. My issue is that, after clicking a button that makes the calls to the SCORM API, several different lines of AS don't work anymore. I've found that if the button is pressed, and the mouse doesn't move at all, then everything works well. However, if the button is pressed, and any mouse input (movement, clicks, or wheel movement, presumably) is sent to the movie, then the issue occurs.

      I suspect that the Player (v. 9) doesn't like taking input while waiting for a function to return a value. The SCORM function calls do take a moment to complete, as data is sent over the network and back, so that would provide the necessary window. Has anyone had a similar experience, and/or found a workaround?
        • 1. Re: Wierd code corruption
          kglad Adobe Community Professional & MVP
          are you using any components? is your button a button component?
          • 2. Wierd code corruption
            Bob_Robertson Level 1
            No and no, respectively. It's a standard button symbol, with the onRelease code below:

            • 3. Re: Wierd code corruption
              kglad Adobe Community Professional & MVP
              does flash use any return from your externalinterface calls?
              • 4. Re: Wierd code corruption
                Bob_Robertson Level 1
                Also no. The wrapper functions only send information to the API, which in turn sends it to the LMS' database. (LMS=Learning Management System)
                • 5. Re: Wierd code corruption
                  kglad Adobe Community Professional & MVP
                  if you comment out the externalinterface calls, does everything work as expected after releasing your button?
                  • 6. Re: Wierd code corruption
                    Bob_Robertson Level 1
                    Yes.
                    • 7. Re: Wierd code corruption
                      kglad Adobe Community Professional & MVP
                      give an example of code that fails after your ei calls.
                      • 8. Wierd code corruption
                        Bob_Robertson Level 1
                        Okay, for example: I've got a movie clip named "pointer". It has three frames; the first is empty, the second and third have static graphics. The same instance is used throughout the movie. Attached to the symbol instance is

                        onClipEvent(enterFrame){
                        this._x=_root._xmouse;
                        this._y=_root._ymouse;
                        }

                        Before the code executes, it works correctly. When the button is pressed, it stays in the down frame for a moment, presumably while the code executes. After the code executes, whenever the system pointer rolls over something that changes the pointer instance's frame, the system pointer becomes invisible (as it is supposed to) and the correct frame of the pointer instance appears, precisely where it was when the button was pressed. The pointer instance is therefore not executing its enterFrame code.

                        I am also no longer able to avoid this by holding the mouse still the mouse while the button has not yet returned to its over frame, for whatever reason.
                        • 9. Re: Wierd code corruption
                          kglad Adobe Community Professional & MVP
                          you use Mouse.hide() when there's a button rollOver and Mouse.show() when there's a button rollOut? and you change your custom cursor's (pointer) frame to hide it (frame 1), show its down state and show its up state on the other 2 frames?

                          and you said, "When the buttons is pressed, it stays in the down frame for a moment...". when what button is pressed? did you change your on(release) to an on(press)?
                          • 10. Re: Wierd code corruption
                            Bob_Robertson Level 1
                            Apologies-- I should have used more precise language.

                            First paragraph: the first sentence is mostly correct; the second sentence is close enough. I use two different pointer graphics in frames two and three: the one on frame two is used for the rollOver of one kind of clip; the other on frame three is used for the other kind of clip. The total effect is basically a pair of complex, pretty-looking radio menus.

                            Second paragraph: I was referring to the button with the EI calls attached to it. The code still triggers when the button is released; all buttons, though, pass through the down state before being released. When the button is released (in the technical sense- this does not occur if the button is pressed, the mouse cursor moves off of it, and the mouse is then released) it remains in its down frame for approximately a second, even though I am no longer clicking on it with the mouse. This delay led me to suppose that the button remained in its down frame while its attached code was executing.
                            • 11. Re: Wierd code corruption
                              kglad Adobe Community Professional & MVP
                              add an onReleaseOutside or your button's mouse handler.
                              • 12. Re: Wierd code corruption
                                Bob_Robertson Level 1
                                That doesn't really fix anything...

                                The issue that I'm having is not when the code executes, but the nasty side-effects that crop up when it does execute.
                                • 13. Re: Wierd code corruption
                                  kglad Adobe Community Professional & MVP
                                  what else needs to detect the mouse has moved off your button? if there some conditional on that onEnterFrame that's not detecting the mouse has moved off your button?
                                  • 14. Re: Wierd code corruption
                                    Bob_Robertson Level 1
                                    There's no other code attached to the pointer clip besides
                                    onClipEvent(enterFrame){
                                    this._x=_root._xmouse;
                                    this._y=_root._ymouse;
                                    }
                                    That's all there is. Other clips have rollOver and -Out handlers that change the pointer clips' frame, but not its position.
                                    • 15. Wierd code corruption
                                      Bob_Robertson Level 1
                                      Double posting is verboten, I know, but this deserves to be bumped.
                                      I've been able to duplicate the errant behavior, and it looks like using ExternalInterface to call anything in the html/JS wrapper breaks the pointer clip. Surfing around the web, I've found that a lot of people have apparently had bad experiences with ExternalInterface. So, I've tentatively abandoned the attempt in favor of calling a PHP page with a loadVars. Thanks very much for your support, kglad, and I wish you luck in your newbie assistance.

                                      As I understand it, there are two alternatives: fscommand and getURL. I've not been able to get fscommand to work correctly, while getURL executes the code that I want, but also sends the browser window to an entirely new location containing only the function's return text ("true", in this case). I'd like to try it with getURL, but the uncontrolled location change obviously prohibits that. My next newbie question of doom is if this can be avoided, and if so, how? I've not seen anything in the help docs.
                                      • 16. Re: Wierd code corruption
                                        kglad Adobe Community Professional & MVP
                                        i've never had any problem with ei though i've only used it to call various javascript functions.
                                        • 17. Re: Wierd code corruption
                                          Bob_Robertson Level 1
                                          Alright, then, see for yourself. I should probably try this on a different configuration anyway, just to make sure that it's not system-dependent. The components are a button symbol and three movie clips. One movie clip has three frames with a static graphic on each frame. Attached to it at the root level is
                                          onClipEvent(enterFrame){
                                          this._x=_root._xmouse;
                                          this._y=_root._ymouse;
                                          }
                                          This clip should be named 'pointer', and reside alone on the top layer.
                                          The second movie clip has the following code attached to it:
                                          onClipEvent(enterFrame){
                                          onRollOver=function(){
                                          Mouse.hide();
                                          _root.pointer.gotoAndPlay(2);
                                          }
                                          onRollOut=function(){
                                          Mouse.show();
                                          _root.pointer.gotoAndPlay(1);
                                          }
                                          }
                                          The third and final movie clip has the same code attached to it, save that its onRollOver send the pointer clip to frame 3, rather than frame 2.
                                          The button has the following code attached to it:
                                          on(release){
                                          flash.external.ExternalInterface.call("alert", "alert called");
                                          }

                                          That's the entire movie. It takes about five minutes to set up, and the resulting effect is troubling to me, to say the least.
                                          Could someone try to duplicate these results? Or, if some interested party prefers, I'll be happy to email the .fla to them.
                                          • 18. Re: Wierd code corruption
                                            kglad Adobe Community Professional & MVP
                                            your mouse handler should NOT be within onEnterFrame handlers. correct that error and see if your problem resolves:

                                            • 19. Re: Wierd code corruption
                                              kglad Adobe Community Professional & MVP
                                              p.s. i don't understand the effect of a 3 frame movie that has gotoAndPlay() statements applied to it unless you have a stop() in all the frames.
                                              • 20. Re: Wierd code corruption
                                                Bob_Robertson Level 1
                                                I first tried commenting out the onClipEvent(enterFrame) wrapper. The script checker then comes up and informs me, of all things, that "Statement must appear within on/onClipEvent handler". So, I simply replaced "enterFrame" with "load", thereby duplicating the functionality without the overhead that appears to be troubling you. As regards the pointer movie clip: you're absolutely correct. I forgot to mention that particular detail.

                                                Did you actually try the movie?
                                                • 21. Re: Wierd code corruption
                                                  Bob_Robertson Level 1
                                                  RESOLVED

                                                  It appears to be a bug in Flash Player 9. When I uninstalled 9 and installed 8r22 in its place, everything works beautifully. Needless to say, I'm going to be wearing a dippy smile for the rest of the week now.
                                                  Thanks for your time, kglad. I wish you the best of luck in your newbie assistance.

                                                  -Bob
                                                  • 22. Re: Wierd code corruption
                                                    kglad Adobe Community Professional & MVP
                                                    you're welcome.