I agree with Buzz about the cause of your problem.  Here is a 
different approach.  In your begin sprite define two property 
variables, for example pMemberUp and pMemberDown (I can't really tell 
what you are trying to do with these things, but I'm guessing it's 
kind of an up/down button thing).  Then instead of doing math, just 
use the correct property.  Also keep a flag variable to remember 
state.  For example

property pMemberUp
property pMemberDown
property pfUp  -- flag, Up = TRUE, down = FALSE

In your beginSprite handler below, after of:

    sprite(curr_sp).member = disp_mem

add somethink like this:

    pMemberUp = member(disp_mem).number
    pMemberDown = pMemberUp + 1
    pfUp = TRUE  -- start in the Up position


Then your mouseUp handler could just become:
on mouseUp me
   pfUp = not(pfUp)  -- flip state
   if pfUp then
      sprite(me.spriteNum) = pMemberUp
   else
      sprite(me.spriteNum) = pMemberDown
    end if
end

Only do the math once, and remember the results in property variables.

Irv




At 11:21 PM +0100 11/16/01, Mikael Wir�n wrote:
>Hi List.
>I�ve run into this strange problem.
>I�m generating some sprites based on a list of symbols defining what member
>to put into the sprite. Like this:
>  Just to mass puppet them and attach a mouseUp script to all.
>
>   repeat with s = 50 to 105
>     puppetSprite s, TRUE
>     x = script("carg_mouse").new()
>     sprite(s).scriptInstanceList.add(x)
>   end repeat
>
>   repeat with i = 1 to lastItem
>     dispItem = pl_itemList[i]
>     case dispItem of
>       #wpn: disp_mem = member("cg_wpn_uc") --Weapons
>       #foo: disp_mem = member("cg_foo_uc") --Food
>       #dop: disp_mem = member("") --Dope
>       #jew: disp_mem = member("cg_jew_uc") --Jewels
>       #ent: disp_mem = member("") --Entertainment
>       #too: disp_mem = member("") --Tools
>       #clo: disp_mem = member("") --Clothes
>       #rob: disp_mem = member("") --Robots
>       #med: disp_mem = member("") --Medicine
>       #com: disp_mem = member("cg_com_uc") --Computers
>     end case
>     sprite(curr_sp).member = disp_mem
>     sprite(curr_sp).rect = gCargList[y_count][x_count]
>     curr_sp = curr_sp + 1
>     x_count = x_count + 1
>     if x_count > 5 then
>       y_count = y_count + 1
>       x_count = 1
>     end if
>   end repeat
>
>Works like a charm. Calling the mouseUp script works just great.
>BUT, the funny part comes here:
>
>on mouseUp me
>   mySprite = me.spriteNum
>   add_sub = 1
>   puppetSprite(mySprite), TRUE
>   if add_sub = 1 then
>     sprite(mySprite).member = sprite(mySprite).member + 1
>     add_sub = 0
>   else
>     sprite(mySprite).member = sprite(mySprite).member - 1
>     add_sub = 1
>   end if
>end
>
>if i set the property mySprite on beginSprite it�s VOID, ok.
>So i slaped it at the begining of the mouse up script.
>Ugly but it works.
>Generating a number from 50 and upwards.
>Fine, the right sprite gets called.
>But the strange part is when i try and change the member of mySprite, it
>changes to member(0) of castLib(0) no matter what i do. This code was my
>last attempt to change it by redoing step 1. Puppeting the sprite again,
>setting the member.
>But still it generates a member(0) of castLib(0). WHY??????
>
>Am i missing something here??
>
>Frustrated and bored =/
>
>TIA
>/Micke
>
>
>
>
>
>[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!]


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[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