At 07:24 2/7/2001, R Kumar wrote:
I've put my comments after each of the handlers below:
/*** GPDL ***/
>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
1. I'm not sure if those line breaks were created by your email client, but
if not, you should either make sure each p_list.addProp line is on one line
or use the line continuation char. D8 = \, D7 = ¬ (hit Alt+Enter)
2. If you want to refer to members, don't use #format:#integer. You can use
#format:#member as the second addProp does, or limit it to a certain type
of member. #format:#text, #format:#field, #format:#bitmap, etc.
3. If you're dropping this behavior on a sprite that already has the
pdisplayText, you could have the behavior default to the current member.
Perhaps something like:
on getPropertyDescriptionList me
p_list = [:]
defMem = sprite(the currentSpriteNum).member
p_list.addprop(#pdisplayText, [¬
#format: #member,¬
#comment: "select text to Display",¬
#default: defMem])
...
/*** beginSprite ***/
>on beginSprite me
>sprite(spriteNum).member = pdislayText
>sprite(spriteNum).member = pswapText
>end
1. To use spriteNum EITHER declare it as a property at the top of the
script OR refer to it as me.spriteNum:
sprite(me.spriteNum).member ... That's what Director is trying to tell you
when an error dialog pops up with:
Script error: Variable used before assigned a value
sprite(spriteNum)?.member = pdisplayText
(Notice the strategic placement of the question mark)
2. It may just be an email typo, but pdisplayText is misspelled.
3. The second line is not needed unless you want the sprite to use the
pswapText member right away. The second line will simply replace what the
first line did before you ever get to see the pdisplayText member.
/*** mouseUp ***/
>on mouseUp me
>pdisplayText = member(pswapText)
>end
1. This just changes the property value. It will not affect the sprite in
anyway. I suspect this is where you really wanted to put line 2 of the
beginSprite handler.
/*** over all ***/
As the script is written now, you don't seem to need the pdisplayText
property at all - unless you intend to swap back to that member later.
So, having said all that, this is what I ended up with. This GPDL will
limit the choices to #Text members. Modify as needed.
property pswaptext
on getPropertyDescriptionList me
p_list = [:]
p_list.addProp(#pswapText, [¬
#format: #text,¬
#comment: "Select the text to swap with",¬
#default: 1)
return p_list
end
on mouseUp me
sprite(me.spriteNum).member = pswapText
end
If you're just starting to get into writing behaviors (or even if you've
been writing them for awhile), this would be a good time to pick up Bruce
Epstein's "Lingo in a Nutshell" There is an outstanding section in the
"Behaviors and Parent Scripts" chapter that deals with the GPDL and it has
excellent tables that help describe the dataTypes used (#format:#???).
http://www.zeusprod.com
--
Mark A. Boyd
Keep-On-Learnin' :)
[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!]