6 Replies Latest reply on Aug 14, 2008 9:58 AM by multiduck

    strange beginSprite behavior

    Level 7
      I have 5 consecutive sprites and in the first (lowest channel number) I have
      a beginsprite handler that gets the locations of the next 4. In the other 4
      (higher channels) I also have a beginSprite handler that changes the loc of
      the sprites to offstate (point (2000, 2000)). Sometimes the data that the
      first sprite grabs is made up of the actual stage locations of the next 4
      sprites and sometimes the data is all point (2000, 2000).

      I'm always starting before these sprites are instantiate so that can't be
      the problem. I was under the impression that beginSprite handlers were
      exectued consecutively by channel number. Why this strange and intermittent
      behavior?

      I know of ways around this but I find it very strange.

      Craig


        • 1. Re: strange beginSprite behavior
          Level 7
          Since your first beginSprite fires *before* all the others, it should
          *always* be grabbing the location set in the score, before the
          beginSprite handler attached to the sprites themselves have the
          opportunity to change them to whatever else. This is normal expected
          behavior.
          • 2. Re: strange beginSprite behavior
            Level 7
            Sean,

            I might not have explained myself well. What you're saying is exactly what
            I'd expect.

            In my beginSprite handler for sprite 10, I have a loop that looks at sprites
            11 to 15 and gets their rects then puts them in a list. In the beginSprite
            of 11 to 15, I have a line of code that sets the loc of those sprites only
            to point (2000, 2000).

            When I look at the list, sometimes it's filled with rect (2000, 2000, 2014,
            2014) and sometimes it's filled with the rects from the actual stage
            locations of those sprite (the latter of which I want).

            This smells of a similar issue which "no one" at Adobe seems to know about.
            That's seeing beginsprite handlers in frame 1 fire before the prepareMovie
            handler...something else which is never supposed to happen. That's why I
            never use frame 1.

            Craig


            "Sean Wilson" <webforumsuser@macromedia.com> wrote in message
            news:g7vq4q$i3m$1@forums.macromedia.com...
            > Since your first beginSprite fires *before* all the others, it should
            > *always* be grabbing the location set in the score, before the beginSprite
            > handler attached to the sprites themselves have the opportunity to change
            > them to whatever else. This is normal expected behavior.


            • 3. Re: strange beginSprite behavior
              Level 7
              Sean

              I suppose memory issues can create all sorts of strange behavior. I just
              spent an hour and a half pulling my hair out about a sprite that wasn't
              doing it's job. I finally put a conditional statement in the beginSprite
              handler so that I could put a breakpoint on a line that would execute only
              for that particular sprite.

              The debugger never opened. After wasting the hour and a half, I closed
              director and closed a few other apps I had open, restarted director and
              everything was fine. And I have 4GB of memory...

              This is a separate issue from the beginSprite issue I posted here that you
              responded to.

              Craig

              "Sean Wilson" <webforumsuser@macromedia.com> wrote in message
              news:g7vq4q$i3m$1@forums.macromedia.com...
              > Since your first beginSprite fires *before* all the others, it should
              > *always* be grabbing the location set in the score, before the beginSprite
              > handler attached to the sprites themselves have the opportunity to change
              > them to whatever else. This is normal expected behavior.


              • 4. Re: strange beginSprite behavior
                multiduck Level 1
                The reason you get old values after the first run of the movie is that at the first ones beginsprite the other sprites hasn't yet had their values reset to their starting values, that happens in their beginsprite. So they are still set to whatever position they were at the end of the last time the movie ran.

                To get around this, and it doesn't require hard coding values which is good, have a script attached to the other sprites that at their beginsprite calls a behavior in the first sprite and report whatever data you will need (rect and or position etc).
                • 5. Re: strange beginSprite behavior
                  Level 7
                  I completely disagree. If you have a behavior with a property pTest that is
                  set to 1 in the beginSprite handler, that property will be void when you
                  stop the movie, even if the playback head is still over that sprite. If you
                  have seen values persist in the property inspector when you stop a movie and
                  that's why you came to your conclusion, it's because the property inspector
                  isn't updated once the movie stops unless "autopoll" is active. You can set
                  this by right clicking on a property in the property inspector although it
                  is a global setting for all entries there.

                  Craig



                  "multiduck" <webforumsuser@macromedia.com> wrote in message
                  news:g8187g$6nl$1@forums.macromedia.com...
                  > The reason you get old values after the first run of the movie is that at
                  > the
                  > first ones beginsprite the other sprites hasn't yet had their values reset
                  > to
                  > their starting values, that happens in their beginsprite. So they are
                  > still set
                  > to whatever position they were at the end of the last time the movie ran.
                  >
                  > To get around this, and it doesn't require hard coding values which is
                  > good,
                  > have a script attached to the other sprites that at their beginsprite
                  > calls a
                  > behavior in the first sprite and report whatever data you will need (rect
                  > and
                  > or position etc).
                  >


                  • 6. Re: strange beginSprite behavior
                    multiduck Level 1
                    Default sprite properties like rect and pos do not work the same way, which is evident since you don't get a void return when accessing information in beginsprite from the first sprite. If you don't have the sprites on frame 1 in the score the way I describe is how it will read the data, the method I mentioned will solve it. Your choice if you want to use it or not.