At 12:15 PM -0400 9/29/00, Ryan Smith wrote:
>I am having some strange problems with property scope. I have a Multiuser
>Server ping behaviour which I attach to an offstage sprite. 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. Is
>their something I'm missing. When I change the properties to global they are
>in the scope of the handlers and everything works fine.
>Any ideas or suggestions would be much appreciated.
>Ryan
>
>Here is some of the code..
>-- Declare properties
>property pPlayerList
>property pNextPing
>property pPingInterval
>
>on beginSprite me
> -- set up initial values for properties
> pPingInterval = 60 * 20
> pNextPing = the timer + pPingInterval
> pPlayerList = []
>end
>
>on exitFrame me
> if the timer > pNextPing then
> -- do some stuff when you get pinged, properties are in scope
> end if
>end
>
>on pingHit me
> -- properties are no longer in scope in this handler???
>end
>
>
Ryan,
I hope that James Newton's explanation solves your problem. If not,
there is another approach. You mentioned that this behavior is
attached to an offstage sprite. Since you are not really affecting
something on the screen, you might want to consider changing this
code from an behavior to a global object. The main differences would
be these:
-- Declare properties
property pPlayerList
property pNextPing
property pPingInterval
on new me -- chane beginSprite to new
-- set up initial values for properties
pPingInterval = 60 * 20
pNextPing = the timer + pPingInterval
pPlayerList = []
add(the actorList, me) -- use the actorlist
return me -- return me
end
on stepFrame me -- change exitFrame to stepFrame
if the timer > pNextPing then
-- do some stuff when you get pinged, properties are in scope
end if
end
on pingHit me
-- properties are no longer in scope in this handler???
end
-- add a method to clean itself out of the actorList
on mCleanUp me
deleteOne(the actorList, me)
end
Then you need to create this object (e.g., from the startMovie handler):
global gMUMonitorObject
on startMovie
gMUMonitorObject = new(script "MUMonitorObject)
end
on stopMovie
mCleanUp(gMUMonitorObject)
gMUMonitorObject = VOID
end
Good luck,
Irv
--
Lingo / Director / Shockwave development for all occasions.
(Over two millions lines of Lingo code served!)
[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!]