At 7:24 AM -0800 2/7/01, R Kumar wrote:
>Hi All,
>
>I am writing a reusable behavior to switch cast
>members selected by the
>users.
>
>property pdisplayText, pswaptext
>on getPropertyDescriptionList me
> p_list = [:]
> p_list.addprop(#pdisplayText, [#format: #integer,
>#comment: "select
>text to Display", #default: 43])
> p_list.addProp(#pswapText, [#format: #member,
>#comment: "Select the
>text to swap with", #default: void])
> return p_list
>end
>on beginSprite me
>sprite(spriteNum).member = pdislayText
>sprite(spriteNum).member = pswapText
>end
>
>on mouseUp me
>pdisplayText = member(pswapText)
>end
>
>For some reason this code does not work. any help
>would be appreciated.
>
A couple of problems here. In your getPropertyDescriptionList, you
are allowing the user to select the "display" and "swap" cast member.
Then in your beginsprite handler, you tell the sprite to show the
display member and immediately override it by setting it to show the
swap member. So, what will happen is that the swap member will show
at beginSprite, then on mouseUp, you will again show the swap member.
You need to make a choice - do you want to use the text member in the
score as the starting member, or do you want the user to choose the
text member from the getPropertyDescriptionList? If you want to use
the member in the score, then don't define pDisplayText in the getPDL
and do this:
on beginSprite me
pDisplayText = sprite(spriteNum).member -- grab it from the score
end
If however you want the user to choose the right one, then define it
in the getPDL and do this:
on beginSprite me
sprite(spriteNum).member = pDisplayText
end
Next problem. I would strongly suggest that you not use numbers
(like 43) in your getPDL. This stops you from moving things around
in the cast. Instead, use names:
p_list.addprop(#pdisplayText, [#format: #member,#comment: \
"selecttext to Display", #default:
"SomeDefaultTextMember"])
Lastly, your default choice for your swap member is VOID. If the
user leaves this as the default, the when you mouseUp on the display
member, the swap member will just appear to vanish. Is this really
what you want? I would suggest "SomeDefaultSwapMember" in your cast.
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!]