10 Replies Latest reply on Apr 13, 2008 12:16 PM by Newsgroup_User

    Behavior keeps dying...

    Level 7
      I have a behavior on a sprite which seems to do exactly what it's supposed
      to most of the time, but after about 10-20 trial runs in Authoring mode, it
      suddenly just stops responding. To anything. I can even add a "put"
      command into its beginSprite just to see if it's responding, and it just
      doesn't do anything. The only ONLY thing that works once this happens is to
      save, quit, and reload, which is getting really annoying to have to do every
      10 minutes or so. So far it always seems to work in the Projector, but it's
      getting hard to test things on this because of the constant need to keep
      quitting and reloading. There's nothing fancy on this script:

      property my
      on beginSprite me
      my = sprite(me.spriteNum)
      end
      on mouseUp me
      --Set val based on mouse relative position on mouseUp
      sprite(my.name.word[1] && "Dropdown Act").val = (the mouseV - my.top) /
      15
      --Scroll Activator text to line to match line selected from Menu
      member(my.name.word[1] && "Dropdown Act Text").scrollTop =
      sprite(my.name.word[1] && "Dropdown Act").val * 15
      --Menu and Selector disappear on mouseUp
      my.visible = FALSE
      sprite(my.name.word[1] && "Selector").visible = FALSE
      --Execute command based on val from Activator
      case sprite(my.name.word[1] && "Dropdown Act").val of
      0: <do this command>
      1: <do another command>
      etc. (there's 20 commands total)
      end case
      end
      on mouseLeave me
      --Menu and Selector disappear on mouseLeave
      my.visible = FALSE
      sprite(my.name.word[1] && "Selector").visible = FALSE
      end
      on mouseWithin me
      --Selector follows mouse on mouseWithin
      sprite(my.name.word[1] && "Selector").locV = my.top + (((the mouseV -
      my.top) / 15)*15)
      end

      The whole "my.name.word[1]" thing is because I have several dropdown lists,
      each having 3 parts grouped by having similar sprite names. The "Dropdown
      Act" is a 20-line text member fixed-height so that only 1 line shows, which
      you click on to activate the menu, it has a property "val" which is set by
      this script. (It has a mouseDown script which just makes the other two
      visible.) The "Selector" is just a rectangle shape with a Reverse ink to
      show which command you have your mouse over. Is there anything in this
      script that stands out as a no-no that would be causing it to so royally
      screw up on such a regular basis?


        • 1. Re: Behavior keeps dying...
          a¿ex Level 1
          search all your scripts for the word "scriptinstancelist"

          once the scriptinstancelist of a sprite is accessed at a time where there is no physical sprite in that channel, the whole channel will be "dead" for the rest of the session.

          if you find the word "scriptinstancelist" in one of your scripts, that may be the reason and I'll explain in more depth, what might be happening.

          From your description I would be to 70% sure, that you will find the word "scriptinstancelist"
          :-)
          • 2. Re: Behavior keeps dying...
            Level 7
            > search all your scripts for the word "scriptinstancelist"
            >
            > once the scriptinstancelist of a sprite is accessed at a time where there
            > is
            > no physical sprite in that channel, the whole channel will be "dead" for
            > the
            > rest of the session.
            >
            > if you find the word "scriptinstancelist" in one of your scripts, that may
            > be
            > the reason and I'll explain in more depth, what might be happening.
            >
            > From your description I would be to 70% sure, that you will find the word
            > "scriptinstancelist"

            Sorry, but no. I'm aware of what the scriptinstancelist does, but I'm not
            using it at all in any of my scripts. Any other ideas?


            • 3. Re: Behavior keeps dying...
              Level 7
              "Darrel Hoffman" <no.address@all.com> posted in macromedia.director.lingo:

              > I have a behavior on a sprite which seems to do exactly what it's
              > supposed to most of the time, but after about 10-20 trial runs in
              > Authoring mode, it suddenly just stops responding. To anything. I can
              > even add a "put" command into its beginSprite just to see if it's
              > responding, and it just doesn't do anything. The only ONLY thing that
              > works once this happens is to save, quit, and reload, which is getting
              > really annoying to have to do every 10 minutes or so. So far it always
              > seems to work in the Projector, but it's getting hard to test things on
              > this because of the constant need to keep quitting and reloading.
              > There's nothing fancy on this script:
              [snip]
              > on mouseLeave me
              > --Menu and Selector disappear on mouseLeave
              > my.visible = FALSE
              > sprite(my.name.word[1] && "Selector").visible = FALSE
              > end
              [snip]

              In my version of Director, toggling the visibility of a sprite channel
              manually in the score causes the symptoms you describe - sometimes. I don't
              use the visible of sprite property in scripting, but there's a slight chance
              it may be doing the same thing. Try adding another handler to the behavior.

              on endSprite me
              my.visible = 1
              end

              This will run even if you simply hit Director's [Stop] button in Author mode.

              (Remember that this property applies to the entire sprite channel rather than
              a single sprite.)



              --
              Mark A. Boyd
              Keep-On-Learnin' :)
              • 4. Re: Behavior keeps dying...
                Level 7
                > In my version of Director, toggling the visibility of a sprite channel
                > manually in the score causes the symptoms you describe - sometimes. I
                > don't
                > use the visible of sprite property in scripting, but there's a slight
                > chance
                > it may be doing the same thing. Try adding another handler to the
                > behavior.
                >
                > on endSprite me
                > my.visible = 1
                > end

                I actually have a script on stopMovie which sets ALL sprites to visible
                whenever you stop the movie, so that might be kind of redundant. At any
                rate, almost all of the sprites on the stage (and all those involved here)
                in addition have one of two behaviors separately applied, one called "Starts
                Visible" and one called "Starts Invisible", which read, respectively:

                on beginSprite me
                sprite(me.spriteNum).visible = TRUE
                end
                on endSprite me
                sprite(me.spriteNum).visible = TRUE
                end

                and:

                on beginSprite me
                sprite(me.spriteNum).visible = FALSE
                end
                on endSprite me
                sprite(me.spriteNum).visible = TRUE
                end

                Does it matter that this happens in another behavior than the script that
                does the juicy bits? As for using the visible property, I know of the
                alternatives, but I don't like 'em. Setting blend to zero is useless, as it
                doesn't stop script from running on mouse events. Moving them off-stage
                works, but then you have to put in extra code to keep track of whether it's
                been moved or not or you end up moving it off-stage twice, or add a property
                telling it where its homeLoc is, etc. The visible property works on one
                line of code, and it's nice and simple, provided you remember to make turn
                visible again on endSprite. (I can't tell you how much I'd pay if the next
                version of Director made the visible property sprite-specific instead of
                channel-specific. If they released an 11.5 patch that did just that, I'd
                buy it on the spot.) Incidentally, I'm still using MX2004, in case that
                matters at all.


                • 5. Re: Behavior keeps dying...
                  Level 7
                  "Darrel Hoffman" <no.address@all.com> posted in macromedia.director.lingo:

                  > on endSprite me
                  > sprite(me.spriteNum).visible = TRUE
                  > end
                  >
                  > Does it matter that this happens in another behavior than the script
                  > that does the juicy bits?

                  Nope. That should be just as good, though you might want to play with the
                  order of behaviors as attached to the sprite.

                  Pure guesswork here, but maybe Director still has problems with .visible if
                  it's toggled n times in a session?

                  > As for using the visible property, I know of
                  > the alternatives, but I don't like 'em. Setting blend to zero is
                  > useless, as it doesn't stop script from running on mouse events. Moving
                  > them off-stage works, but then you have to put in extra code to keep
                  > track of whether it's been moved or not or you end up moving it
                  > off-stage twice, or add a property telling it where its homeLoc is, etc.
                  > The visible property works on one line of code, and it's nice and
                  > simple, provided you remember to make turn visible again on endSprite.
                  > (I can't tell you how much I'd pay if the next version of Director made
                  > the visible property sprite-specific instead of channel-specific. If
                  > they released an 11.5 patch that did just that, I'd buy it on the spot.)
                  > Incidentally, I'm still using MX2004, in case that matters at all.

                  Yep. I opted for the off-stage method many moons ago. Slightly more code, but
                  it's proven reliable for me.

                  Where to go from here?

                  Can you observe a pattern occuring when it begins to fail? ie: certain sprite
                  channels are visible/not visible?

                  Perhaps you can create a simple test movie with just your menu system and
                  some minimal navigation if that's what your real project does.

                  That might help eliminate some possible causes. If it still happens in the
                  test movie, see if converting to an off-stage method cures it.

                  If not, then I may have led you down the wrong path altogether and something
                  else is likely the cause.

                  /***/
                  If you're open to the off-stage method, I still have my ancient D7 example
                  (using graphics for the menus) on my site that you might use as a quick
                  starting point: http://www.mboyd.com/director/windowsui.html It uses an even
                  older version of my D7 "MAB beginOffStageGrouped" behavior shown (perhaps a
                  bit confusingly) here: http://www.mboyd.com/director/showhide.html

                  It's old, but I still use that behavior in every nearly every Director
                  project. Not so often for menus, but for artsy dialog boxes when the client
                  doesn't want the OS widgets.

                  (I still get hits on those pages. Maybe it's past time for me to upload the
                  D8+ versions of those behaviors.)

                  For more recent code, I seem to recall seeing some better written scripts
                  posted on the DOUG site some years ago. Sorry I don't have the links avail,
                  but they should be easy enough to find.


                  --
                  Mark A. Boyd
                  Keep-On-Learnin' :)
                  • 6. Re: Behavior keeps dying...
                    Level 7
                    > Pure guesswork here, but maybe Director still has problems with .visible
                    > if
                    > it's toggled n times in a session?

                    I don't think that's it. In any given run, the behavior either always
                    functions or never functions. It's only when I stop and start the playback
                    n times that it eventually stops working. If I just let it play and never
                    stop it, it works fine for the whole run. (Of course, you have to stop to
                    change anything, so that's of limited use.)

                    > Yep. I opted for the off-stage method many moons ago. Slightly more code,
                    > but
                    > it's proven reliable for me.

                    I'll do it if I have to, but I never liked that method. Just seemed like a
                    cumbersome workaround.

                    > Can you observe a pattern occuring when it begins to fail? ie: certain
                    > sprite
                    > channels are visible/not visible?

                    The three channels involved always behave as they should. And of course,
                    everything becomes visible on stopMovie, so it should ultimately work.

                    > Perhaps you can create a simple test movie with just your menu system and
                    > some minimal navigation if that's what your real project does.

                    I actually copied this menu script from an older project, and it worked
                    perfectly there. It was a much simpler project, of course, so

                    > That might help eliminate some possible causes. If it still happens in the
                    > test movie, see if converting to an off-stage method cures it.
                    >
                    > If not, then I may have led you down the wrong path altogether and
                    > something
                    > else is likely the cause.

                    This is not the first time in this project that this has happened, and in
                    other cases, it was on sprites which never have their visibile property even
                    touched. Although the other times it was always an isolated incident, while
                    this one keeps happening over and over again.

                    As for the links, I'll take a look - ultimately most of this probably WILL
                    get replaced with snazzy graphic menus rather than boring old #text members,
                    so maybe the problem will go away then, but that's down the road a bit.
                    I've got one other theory I want to look at though - I'll report back...


                    • 7. Re: Behavior keeps dying...
                      Level 7
                      Eureka! I figured it out. Though it's somewhat annoying.

                      Problem was this: The dropdown menu when visible covers up a bunch of other
                      important sprites on the stage, so I was manually turning off the sprite
                      channel in order to get at the things underneath by pushing the little box
                      on the side of the score while working. Problem is if I don't click that
                      box again before playing the movie, the script on the sprite refuses to
                      function. It's still made visible by clicking on the Activator, but it
                      doesn't do anything. Odd that once the bug occurs just once, even if I
                      toggle the visible manually prior to playback and make sure it's visible
                      before hitting Play again, it won't work anymore. I still have to
                      save/quit/reload. But it looks like I can avoid the problem provided I'm
                      careful to always make sure the thing is visible prior to hitting the Play
                      button.

                      And for the record, it looks like this particular bug would occur even if I
                      wasn't using the visible of the sprite to make it disappear. I did a quick
                      test in an otherwise-empty movie, and if you have a sprite start invisible
                      by clicking those boxes on the side of the score, any script on it
                      completely refuses to run, even if you set it visible again via another
                      script. Although in this case, I didn't have to save/quit/reload to make it
                      work again - simply clicking the box on the side of the score before the
                      next run worked. Not sure why my main project is having THAT particular
                      problem, but at least I know how to avoid it now. Mental note: Always make
                      sure that all sprites are visible before hitting Play. Check.


                      • 8. Re: Behavior keeps dying...
                        Level 7
                        When you stop and start it n times... how are you stopping it? Are you
                        using the Stop button in Director? Or are you pressing the 'esc' key on
                        the keyboard? There is a difference. The Stop button will do what you
                        expect it to. Stop the movie gracefully, allowing all the endSprite and
                        stopMovie events to happen normally. If you use the 'esc' button, it
                        simply stops playback, without allowing those cleanup scripts to run.
                        So, if you have a sprite channel's .visible set to 0, and you hit 'esc',
                        the code telling it to turn visible will never run. When you hit Play
                        again, it will start off invisible, and it's beginSprite and other evens
                        never fire.
                        • 9. Re: Behavior keeps dying...
                          Level 7
                          "Darrel Hoffman" <no.address@all.com> posted in macromedia.director.lingo:

                          > Eureka! I figured it out. Though it's somewhat annoying.
                          >
                          > Problem was this: The dropdown menu when visible covers up a bunch of
                          > other important sprites on the stage, so I was manually turning off the
                          > sprite channel in order to get at the things underneath by pushing the
                          > little box on the side of the score while working. Problem is if I
                          > don't click that box again before playing the movie, the script on the
                          > sprite refuses to function.
                          [snip]
                          > But it looks like I can avoid the
                          > problem provided I'm careful to always make sure the thing is visible
                          > prior to hitting the Play button.
                          >

                          Yes, indeed. I probably should have expanded my first reply, but that is
                          exactly the behavior/symptom I was referring to - and the method to /help/
                          prevent it that I neglected to mention.

                          That quirk has been in Director as far back as I can recall - well, at
                          least when behaviors first appeared in, what, Dir 6?

                          Hope you're able to get a better work-flow going now.



                          --
                          Mark A. Boyd
                          Keep-On-Learnin' :)
                          • 10. Re: Behavior keeps dying...
                            Level 7
                            > When you stop and start it n times... how are you stopping it? Are you
                            > using the Stop button in Director? Or are you pressing the 'esc' key on
                            > the keyboard? There is a difference. The Stop button will do what you
                            > expect it to. Stop the movie gracefully, allowing all the endSprite and
                            > stopMovie events to happen normally. If you use the 'esc' button, it
                            > simply stops playback, without allowing those cleanup scripts to run. So,
                            > if you have a sprite channel's .visible set to 0, and you hit 'esc', the
                            > code telling it to turn visible will never run. When you hit Play again,
                            > it will start off invisible, and it's beginSprite and other evens never
                            > fire.

                            Actually, that doesn't seem to be the case - the stopMovie script functions
                            either way. Not sure if the endSprite behaviors do or not, because there's
                            a bit of redundancy involving those. (Both the stopMovie and endSprite
                            scripts make the sprites become visible again, so I'd have to check to see
                            if both are functioning, but the stopMovie definitely is, even if I hit
                            Esc.) Though it's not entirely redundant to have this on both stopMovie and
                            endSprite, because the endSprite code runs when jumping between frames as
                            well. (Or at least it should, sometimes I'm not sure it's working as
                            advertised. If all my invisible sprites are setting visible to TRUE on
                            endSprite, I shouldn't ever need to use the "Starts Visible" behavior I
                            mentioned earlier, but I definitely still do.)