Genevieve Young <[EMAIL PROTECTED]> wrote:

> I get an error with this message:
>
> Script error: Variable used before assigned value
> tPropertyList[#markerName] = [  #comment: "On mouseUp, go to marker:", \
> #format:  #marker, \   #default: #next \ ]

Hi Genevieve,

The "\" is the "line continuation" character.  If you place a carriage
return immediately after it, Director understands that the next line is a
continuation of the current line.  If you don't, Director understands it as
a character in its own right, just like "a" is a character.

Your handler should look like this...

on getPropertyDescriptionList(me)
  tPropertyList = [:]

  tPropertyList[ \
#markerName] = [ \
 #comment: "On mouseUp, go to marker:", \
 #format:  #marker, \
 #default: #next \
]
  tPropertyList[ \
#jumpMode] = [ \
 #comment: "Jump mode:", \
 #format:  #string, \
 #range:  ["Go to", "Play and Return"], \
 #default: "Go to" \
]
  return tPropertyList
end getPropertyDescriptionList

... or like this...

on getPropertyDescriptionList(me)
   tPropertyList = [:]

  tPropertyList[#markerName] = [#comment: "On mouseUp, go to marker:",
#format:  #marker, #default: #next]

   tPropertyList[#jumpMode] = [#comment: "Jump mode:", #format:
#string, #range:  ["Go to", "Play and Return"], #default: "Go to"]
   return tPropertyList
end getPropertyDescriptionList


(Caution: email software will have inserted extra carriage returns into the
latter example).

>> The getPropertyDescriptionList() handler is called at author-time only,
>  ... when are they executed?

* isOKToAttach() is called when you drag a behavior over a sprite or the
  stage
* getPropertyDescriptionList() is called when you drop a behavior over a
  sprite or the stage that isOKToAttach allows it to be attached to

* getBehaviorTooltip is called when the mouse rolls over a behavior icon
  in the Library Palette

* getBehaviorDescription is called when you select a given behavior on a
  given sprite, or when you select a behavior script.  The value returned
  is displayed in the Behavior Inspector window.

>> Other author-time only handlers will be placed in the same section >of
>> the script:
> May I clarify  that the scripts must be behavior  scripts only?
> Are you referring to different scripts or different sections of the same
> script?


For clarity, I define arbitrary sections within a behavior script, using
comments in uppercase.  I place handlers of a similar type together.
Example:

-- SPRITE EVENTS --

on beginSprite(me)
  -- some code
end beginSprite


on endSprite(me)
  -- some code
end endSprite


-- EVENT HANDLERS --

on mouseDown(me)
  me.mStartDrag()
end mouseDown


on mouseUp(me)
  me.mStopDrag()
end mouseUp


-- PRIVATE METHODS --

on mStartDrag(me)
  -- some code
end mStartDrag


on stopDrag(me)
  -- some code
end stopDrag


>> on mouseUp(me)
>>   me.mJumpToMarker()
>> end prepareFrame
> 
> I am not sure where to place this script.

This is a handler, not a script.  A script is an entire cast member: all
that you see in the Script window when you double-click on a script member
is a script.  A handler is a "paragraph": handlers starts with the keyword
"on" followed by a handler name, and end with the keyword "end".

All the handlers I described in my previous message belong in the same
behavior script.

> Are you referring to different scripts or different sections of the same
> script?


>> on me.mJumpToMarker(me) ---------------------------------------------
> I placed this  behavior script into my movie. I received this error
> message.
> 
> Script error; Symbol expected
> 
> on me.mJumpToMarker(me)

Sorry: that was a copy and paste error: the line should read:

on mJumpToMarker(me) ------------------------------------------------


> On pg 267 of Special Edition using Macromedia 8, properties in a list are
> known as symbols  and anything prefaced by # character is a symbol.  In
> this case how do I define it?  I don't understand. Aren't symbols defined
> only in lists?

A symbol is a sequence of letters, numbers and the underscore character _,
starting with the # character.  The first character after the # may not be a
number.

You can use symbols anywhere.  For example:

     case markerName of
       #previous: tFrameNumber = marker(-1)
       #loop:     tFrameNumber = marker(0)
       #next:     tFrameNumber = marker(1)
       otherwise:
         tFrameNumber = marker(markerName)
     end case

The events that trigger a handler are symbols: #mouseUp, #endSprite, and so
on.  "me" is a variable that points at the instance of the behavior script.
It is not a symbol.  Director is expecting "mJumpToMarker" (without the
quotes as a handler name.  It thinks of this handler name as a symbol,
because the event #mJumpToMarker is dealt with in the code that follows.

> Script error: name already used
> on me.mJumpToMarker(me)

Director does not allow you to have two handlers with the same name in the
same script member.  If you did, they might be different, and how would
Director know which one you meant to use?

> The GetPropertyDescriptionList handler works only for sprites on stage?
> What happens if the sprites were not on stage?  May I still use this
> handler?

The getPropertyDescriptionList() handler is called when you drop a behavior
on a sprite, or when you subsequently reopen the "Parameters for <behavior
name>" dialog through the Behavior Inspector or the Property Inspector.
It's purpose is to allow you to set up the initial conditions for the
behavior on that sprite.

If you place sprites outside the stage area, they are still sprites: they
still appear in the Score window.  If you remove sprites from Score window,
they are no longer either on or off the Stage: they no longer exist.  A
behavior's getPropertyDescriptionList() handler will work wherever the
sprite it is attached to happens to be.

A behavior that is not attached to any sprite may contain the
getPropertyDescriptionList() handler.  It will just not have any effect
until the behavior is dropped on a sprite.

Cheers,

James



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/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