![]() ![]() 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 (http://www.behaviors.com, http://www.director-online.com). 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: property anInteger on getPropertyDescriptionList
addProp thePropertyDescriptionList, #anInteger, [#default: 0, #format: #integer, #range: [#min: 0, #max: 10], #comment:'Enter an integer'] return thePropertyDescriptionList 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: -- mouseOver property pMouseOverCursor property pEnteredMouseCursor on getPropertyDescriptionList
addProp theDescriptionList, #pMouseOverCursor, [#default: 0, #format: #cursor, #comment: "de cursor"] return theDescriptionList on mouseEnter me
pEnteredMouseCursor = mySprite.cursor cursor pMouseOverCursor on mouseLeave
on getBehaviorDescription
return description 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). |