|
|||
| week 10b - director basics, director scripting basics | |||
director scripting: |
Director uses the Lingo language for scripting, which is similar to Flash ActionScript in that it uses an event model and object properties. It is different from ActionScript in terms of syntax. For example, it does not use the ";" at the end of each statement line.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| kinds of scripts : |
Cast scripts are created by selecting the desired cast member, and then clicking on the script icon to open the script editor. movie: A kind of global place to put code, similar to the way the first frame of Flash movies are used. These scripts can handle events such as on prepareMovie, on startMovie, on stopMovie, as well as defining the equivalent of user defined Flash functions. behavior: These scripts are designed to be attached to sprites or frames in the movie. They are generic code that can be attached to many different objects. We will use these kinds of scripts most. parent: These are special scripts used for object oriented programming, enabling code centralized in one place to be "inherited" by other scripts. The parent script's handlers can be used by "child" scripts that are derived from the parent. cast: A script that is associated with a specific cast member. The code goes with every instance of the cast member that's placed on the stage.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| identifying sprites : | In Director, sprites are always identified by their current channel number. Unlike Flash, there is no naming system for sprites in Director as there is with movieClip instances in Flash. To move a sprite that's in the third channel to an X,Y position of (200, 100), the code would look like this:
To make code more generic, it is possible to identify the current sprite without naming the actual channel number of the current sprite. This technique is similar to use the "this" keyword in Flash.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| properties : | Sprites and other objects in Director have properties that are similar to Flash properties. Some commone ones are:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| event handlers : | Director has event handlers the operate in the same manner as those in Flash. The Director event handlers always have the form: on handlerName optional arguements For example, code to move a sprite across the screen might be written as: In Flash:
In Director:
Another example would be code to keep the main timeline in Director on the same frame. Frame code in Director uses events, where code in frames in Flash does not.
Please see the Director Help system for detailed explanations of these frequenty used events. Mouse related events: Frame related events: Keyboard related events: Example use of the keyboard event handler
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if statements : | If statements handle decision making in Director in a very similar way to Flash. The primary difference is the user of "then" and "end if" in place of the open and closing currly braces "{", "}". Flash:
Director:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| put vs. trace() : | For debugging purposes, Director has a feature that prints text in the "message" window. The "put" command is similar to the Flash trace() function. Flash:
Director:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| comments : | Comments allow you to put in descriptive text in your code, or temporarily
remove code so it doesn't run, but leave it in the script. A nice feature
in Director enables you to select a set of code, and click on the comment
button in the script window to instantly comment out all of the selected
text. Flash:
Director:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| sample director movie : | show firstDirector.dcr, download firstDirector.dir & quicktime movie (1.5meg) behavior code on 1st and 10th frames:
behavior code on left sprite:
behavior code on right sprite:
|
| all materials on this web site © copyright 2003, Philip van Allen |
top |