Director Manual
[] intro windows concepts tools howto lingo advanced summary resources

Behaviors

Behaviors are most of the time little scripts which can be added easily to a sprite or frame to increase the functionality.

There are a lot of behaviors out there, either in director like 'mouse-over-change-cursor' or on the internet:

As mentioned before, behaviors can have properties. These properties are declared outside the hanlders at the top of the screen. When a behavior is dragged from the library palette and released on a sprite a pop-up box can appear to set these properties to specific values for that sprite. The handlers which makes this possible is on getPropertyDescriptionList. In this handler you can define what and how properties are set.

Example:

properties



  property anInteger
  
  on getPropertyDescriptionList
    set thePropertyListDescription = [:]
    addProp thePropertyDescriptionList, 
    #anInteger, [#default: 0, #format: #integer, #range:   
    [#min: 0, #max: 10], #comment:'Enter an integer']
    return thePropertyDescriptionList
  end
  
The property anInteger gets filled in by the method specified by the addProp command. In this case a slider is used with possible values 0 to 10. The handler on getBehaviorDescription gives a description of the behavior when the mouse roll overs the behavior in the library cast.

Note:

To add a behavior to the library, add or create a new external cast and put the cast in the libs folder of the macromedia directory.

Note:

To view the library choose window library palette.

Next to do is just write the behavior.

Example:

behavior



                                                -- mouseOver
  property pMouseOverCursor
  property pEnteredMouseCursor
  
  on getPropertyDescriptionList
    set theDescriptionList = [:]
    addProp theDescriptionList, #pMouseOverCursor,
      [#default: 0, #format: #cursor, #comment: "de cursor"]
    return theDescriptionList
  end
  

example (cont'nd)



  on mouseEnter me
    mySprite = sprite (me.spriteNum)
    pEnteredMouseCursor = mySprite.cursor
    cursor pMouseOverCursor
  end
  
  on mouseLeave
    cursor pEnteredMouseCursor
  end
  
  on getBehaviorDescription
    set description = "defines de mouse over cursor"
    return description
  end
  
This behavior let's you select a cursor which appears when the mouse enters the sprite and turns the mouse to it's normal cursor when the mouse leaves the sprite.

Note:

To make behaviors fast, you can use a program which makes the basic behavior for you in which you only have to type the specific code. Such a program is available at. (behavior_writer).


[] intro windows concepts tools howto lingo advanced summary resources
eliens@cs.vu.nl

draft version 0.5 (12/3/2001)