Ryan Smith <[EMAIL PROTECTED]> wrote:
> My properties are declared outside of any handlers in the behaviour
> so that they can all "see" them. My exitFrame and beginSprite handlers
> work fine and have the properties in their scope, but both of my MUS
> message handlers do not...
...
>on pingHit me
>  -- properties are no longer in scope in this handler???
>end

Hi Ryan,

Could it be that the instance that receives the pingHit event is not the
same as the one that receives the exitFrame and beginSprite events?

There are probably many ways to create duplicate instances, but here's
are a couple of common ones:

When you register a behavior instance with the MU xtra for a callback,
the MU xtra instance keeps a pointer to the behavior instance.  If you
then move to a frame where the sprite no longer exists, the initial
behavior instance will be cleared from the sprite... but the MU xtra
will still maintain a pointer to the instance.

When you come back to the frame, the sprite will create a new, different
instance of the behavior (which will receive beginSprite and exitFrame
events).  When the MU xtra relays the message received from the MU
Server, it will send it to the original instance, which is no longer
attached to the sprite.  The properties of the original instance will
not reflect those of the instance now attached to the sprite.

I have also seen behaviors reinitialize themselves during authoring if
the playback head reaches the lastFrame and returns to the first.  You
can prevent this from happening by placing an "on exitFrame; go 1"
behavior in the last frame.

Place a breakpoint in both the beginSprite and the pingHit handlers, and
check the value of the <me> property.  Or watch the value of
sprite(x).scriptInstanceList[y] in the Watcher window, and compare it
with the value of the <me> property in the Debugger window when pingHit
is called.
If the value of sprite(x).scriptInstanceList[y] changes spontaneously,
then something untoward is happening.

> When I change the properties to global they are in the scope of the
> handlers and everything works fine.

If you change the properties to globals, all instances everywhere can
access the same data.


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to