Macromedia Director Behavior Demonstrations

You are welcome to download and use any of the following unprotected Director movies. If you want to open a movie in Director's authoring environment then right-click/control-click/click-and-hold on the link (depending on your platform and browser) and choose the "Save File As..." command (or equivalent) in the contextual menu which will appear. This will save the movie to your hard disk.
Alternatively, you can pick the movie out of your browser's cache once you have tested it in Shockwave.
A third possibility is to copy the link and paste it into Director's Message window, preceded by the "go movie" command. For example:
go movie ""


If you have any questions or comments concerning the code or other aspects of this site, please send me a message at james.newton(@)


James Newton



Using textureCoordinatesList when building a mesh: This example creates a gaming dice from a custom mesh in the form of a cube. A single texture is used. The different square areas in the texture are mapped onto the surface of the mesh using a textureCoordinatesList. (45K)

Moving a model with the mouse: This example uses spriteSpaceToWorldSpace() and a little vector mathematics (based on the fact that the dotProduct of two perpendicular vectors is zero) to move a model with the mouse, in the same plane as the camera. Use the up and down arrow keys to move towards or away from the camera. (19K)

Particle texture: Change the texture of a particle emitter to produce interesting particle shapes. (27 K)

Moving a particle system 1: Emitted particles are children of the emitter. If you move the particle model, all particles already emitted will move with it. To make a realistic animation, you can move the emitter.region of the particle resource instead. If you do this with a low frameTempo (15 fps in the example), the emitted particles appear in slices.
You can produce a more realistic effect by using a tight repeat loop with an updateStage in it while the emitter.region is being moved. Select the "modify emitter.region" button to move the emitter.region when you drag the flame around with the mouse. Press the Command Key before you click to use a tight repeat loop. Press both the Command and Shift keys before you click to force the emitter.maxSpeed and the emitter.minSpeed to coincide, and so create a more realistic trail. (44K)

Moving a particle system 2: Another example of changing the emitter.region. This time, the emitter.region is the whole of one face of a box primitive. The orientation of the face is determined by

  1. using the meshDeform modifier to gain access to the vertexList for each face of the box
  2. multiplying each item in the vertexList for face 2 by the transform of the box model

Vectors and rays: Force, acceleration, velocity, position and direction can all be expressed using vectors. The intersection between a ray and a model can be determined using modelsUnderRay(). This movie combines these techniques to simulate gravity without the use of the Havok xtra. Use the arrow keys to tilt the plane: the ball will roll under the effect of its own virtual weight. (27K)

Using interpolate(): Two D8.5 behaviors which animate a box in space towards a target. One uses interpolate() on each frame to create a straight line animation. The other uses interpolate() once to calculate a transform, which is then applied incrementally using multiply() once per frame. This creates a curved path. (29K)

Collisions: A very simple single player pong game which demonstrates the collision modifier. The resolve mode is deliberately set to FALSE and the resolution of collisions calculated on a case-by-case basis. (21K)

Rotating a shader around its center: You can rotate a texture inside a shader by altering the value of the aShader.textureTransform.rotation.z. However, this rotates the texture around its bottom left corner. This movie contains a handler that alters aShader.textureTransform.position.x and .y at the same time, so that the texture appears to rotate around its center. (29K)

More 3D examples below.

Imaging Lingo


floodFill(): Director 8.5 has a new floodFill(point, colorObject) command which did not get documented. This movie takes floodFill one step further and allows you to flood an area with a texture. (36K)

[20 October 2003]
Colored Shapes: Use copyPixels with a quad target area to create triangular and diamond-shaped sprites with a border to make them visible against a background of any color. The movie also contains an Imaging Lingo slider. (60K)

Drawing Arcs: Click and drag to draw a quarter-of-a-circle arc. A buffer image is used so that the arc can be resized and positioned in real time. (28K)

Irregular Constraint: Create an irregular shape using a 32-bit image with an alpha channel and constrain the movement of another sprite to the area of the image where the alpha channel is not transparent. (28K)

Stencil: Allow the user to paint onto an area using a stencil. (28K)

Geometry and Trigonometry


Using Trig: a demonstration of a number of trig-based behaviors. This was written to be opened in the D6 authoring environment. (103 K) The article that the behaviors illustrate first appeared in the August 1998 issue of Macromedia User Journal (33K)

Using Vectors: a demonstration of a number of behaviors using vectors. You'll find behaviors for throwing sprites and for bouncing circular sprites off straight edges, angled edges, curved edges and off other each other. (116 K) The article that the behaviors illustrate first appeared in the October 1998 issue of Macromedia User Journal (33K)

Detecting when Lines Intersect: demonstration of the handlers linesCross() and distanceFromLine() (42 K).

Fun with vectors: a D7 movie which uses the "Vector Motion" behavior provided in the D7 Studio Library Palette, plus a custom "Steering" behavior. Drive the little car round the Stage. Control it with the arrow keys:

Use the "instruments" to bring the car back onto the Stage if you happen to drive off. If you hit the red "Crash" circle, you'll have to reload the game to play again. (56K)

Bird's Eye panorama: a D7 movie which modifies the drawRect of the stage to move a sprite around an area larger than the stage itself... and yet keep it visible. An antidote behavior keeps another sprite at the same position on the screen, regardless of the drawRect of the stage. Animation is time-based: the speed of movement is independent of the computer's speed, but slower machines may give jerky animation. (17K)

Roundabout: Throw a sprite towards another one, and see it circle round the target sprite and come back the way it came. (20K)



Matching game: a drag and drop game for young children. The right mouse button works just like the left mouse button. One click makes a text sprite stick to the pointer, a second click drops the sprite which then snaps into position (or returns to its starting point). Standard drag and drop works too. To customize the game, change the images in the second internal castLib and name them appropriately. (77 K)

Slider object: a behavior attached to a sprite creates a global object as its ancestor. The object remains in the RAM even when a new movie is loaded. If the new movie contains the same behavior, it recuperates the existing ancestor object. The behavior in the new movie does not have to be in the same channel. This technique allows the same feature to be used in any number of connected movies. In this case, a mouseUp on the Stage or on the slider thumb will reopen the same movie, imitating a change of movie. (16 K)

Irregular constraint: three behaviors which constrain a sprite to a non-rectangular shape. Click and drag the circular sprites to test. The red and orange sprites will jump gaps, the orange and green sprites will move to the closest point on the edge when the mouse is outside the shape. D6 uses "on exitFrame" and requires to updateStage repeatedly (this may affect filmLoops). D7 exploits the new flexibility of the on prepareFrame handler to avoid this. (24 K)

Irregular rollover with vectorShapes: this D7 behavior allows you to create irregular rollover zones using light-weight Vector Shape members. The behavior uses an algorithm which imagines a vertical line upwards from a given point. It then calculates how many of the Vector Shape's sides cross the imaginary line. If the number of intersections is odd then the chosen point is inside the zone. (Note: the sides of the Vector Shape must be straight). (25 K)

Orbits: a demonstration of a pair of behaviors which places a group of sprites at equal distances along an oval path, and rotates them. You can drag the sprites to change their speed or direction, and you can make them react to a mouse click. (37 K)

Constrain to a circle: this behavior allows you to constrain a sprite to a circular area. You can use the regPoint, the centre, or the top left of the sprite as the point which will never leave the circle. (19 K)

Drag and drop: a set of four simple behaviors that allow you to drag sprites and drop them in particular zones. The main behavior can take on two flavours: drag from one zone to another, or constrain to within a given zone. It could be improved in a number of ways: the "repeat while mouseDown" loop, for instance is bad practice. (16 K)

Marching (red) ants: Create a selection marquee in Director... in the color of your choice. Click anywhere and drag to select the pale red squares. Click inside the circular "selection" and drag to see how reverse ink cancels itself out. (32 K)



Select a line in a field: The "Menu Field" behavior can be used to create both a static list and a contextual menu. (33K)

Hilite lines in a non-editable text member: Neither D7.0.2 nor D8 allow you to hilite text in a non-editable text member. The workaround is to place a rectangular #shape sprite with Reverse ink over the text. This movie contains two behaviors, one for the #text sprite, one for the #shape sprite. Note that if you use two shape sprites, one with Reverse ink and one with Lightest ink, you can create a colored hilite. (24 K)

Multiple Line Selection: Simulate the selection of multiple discontiguous lines in a text member by placing a bitmap in the channel above, and using the Multiple Select behavior from this movie on the text sprite. (64K)

Horizontally scrolling field: Make an editable field scroll horizontally if the user enters more text than can be displayed in the sprite. (22 K)

Custom Hyperlink Style: a D7 behavior for customizing hyperlinks. You can change the #normal, #active and #visited colors, the fontStyle of the links and the cursor as it rolls over a link. The "Hyperlink Style" behavior relies on Chris Walcott's "Hypertext - General" behavior (shipped with D7 Studio) to implement the changes. (77 K)

Folding Text behavior: a behavior for #text members which expands or collapses various paragraphs of text (63 K)



D7 Continuous squiggle: How do you create a paintbrush effect when the mouseLoc only updates 40 times a second? This movie saves each mouseLoc in a list and asynchronously interpolates a straight line between the discrete points. If you move the mouse fast the line will lag behind. (17 K)

Bowties and concavities: Quads don't display correctly if they are concave or twisted into a bowtie. Checking what state a quad is in is not simple. Here's a movie script that does it for you. The Drag Quad Points behavior is by Darrel Plant. (27 K)

Basic morph: a D7 morph behavior with no pretentions (33 K)

OOP Painter: A D6 painting program that weighs in at 3 K when shocked. It uses a short movie script and a simple painter object (parent script). Use the Shift and Option/alt keys for interesting effects. (21 K)

Object-oriented programming


Inter-Sprite Communication: Inspired by Brennan Young's tutorials, here's a very simple D7 Space Invader game. Use the mouse to move your cannon and the spacebar to fire. My personal contribution lies in the way the sprites communicate with each other. (60 K)

Moving a sprite: A mouse click on the stage is used to add a temporary behavior to a sprite. Once the behavior has done its work, it automatically removes itself. This particular behavior can be set to move a chosen sprite from one point to another, using either frame-based, step-based or time-based movement. (29 K)

D7 Flush buffered clicks: During a time-consuming process, any mouse clicks are stored in a buffer. They are then executed all at once as soon as the time-consuming process has finished... to the user's surprise. This movie uses a self-destructive object to prevent this from happening. (12 K)



Email archives: A zipped file containing a movie which uses the Multiuser Xtra in text mode to connect to a POP3 server, download any emails that are waiting for it, strip the header, any HTML formatting and attachments from the messages and save them in a castLib as #field members, plus a movie which demonstrates the effect of the official POP3 protocol commands (pop3.dir). (30 K)

You can find the official specifications of the POP3 protocol at

Cascading Checkboxes behavior: A behavior for a hierarchical group of checkboxes, which allows you to enable certain checkboxes depending on the hilite value of others. For instance, in an connection password dialog, the "Remember password?" box must be checked before the "Connect automatically?" checkbox can be selected. Enabling/disabling is done via #shape sprites which uses the same behavior. (42 K)

Sprite Names Behavior: Drop this behavior on any sprites that you wish to address it by name. You can then move the sprite to a different channel in the score, and it will still respond. You can attach the behavior to the same sprite more than once, and thus give it more than one name. You can also give the same name to several sprites thus creating a group of sprites. You can also name sprites on the fly. Sneaky trick: the scriptType of the behavior is set to #movie when it is instanciated so that its methods are available globally. (50 K)

Customizable Shockwave Dialog with Flash 4: In a projector, you can use the Mui Xtra to show dialogs with Yes/No answers. However, the Mui Xtra is not Shockwave save and so it cannot be used in a browser. Here is a solution that uses a customizableFlash 4 member and a behavior which calls flashSprite.setVariable() (47 K). The original .fla file (16 K) is available in the parent folder

Object and list utility handlers: This D7 external cast contains three handlers: reportProps(), findIlk() and findValue(). Use the reportProps() handler to display the properties and values of any list or object instance in the Message window. Use the findIlk() and findValue() functions to perform a comprehensive search of all the places where Director could have stored data with a given ilk or value. For example, if you issue the command "forget(window 1)" and your MIAW fails to close, you can use findIlk(#window) to discover where any remaining pointers to window 1 are stored. (19 K)

Navigation Behaviors (96 K): The "History Button" and "Resume Button" behaviors allow you to retrace your steps in any set of movies... without having to use any particular behavior for the initial navigation. In addition, you will find a "Mouse States" behavior which controls the rollover and mouseDown states of any button including the relevant cursor changes. In the associated movie(97 K), you will also find improved "Go Marker ... " and "Go Movie Button" behaviors.
(These behaviors can be used as alternatives to the set shipped in the D7/D8 Library Palettes: "Jump to Marker Button", "Jump to Movie Button", "Jump Back Button", "Jump Forward Button" and certain uses of the "Push Button" behavior).

Touch typing: A couple of behaviors for entering text on a touch screen. The movie also includes a "Scan Keys" feature to enable disabled users to type (160 K). To see the virtual keyboard in action (without being able to see the code), test the 20 K shocked version. The difference in size is due to the way Shockwave compacts images.

Pass and stopEvent: A demonstration of how the "pass" and "stopEvent" commands work. (17 K)

Lists, Loops and Things: a miscellaneous collection of D6 behaviors, including a dropdown menu that automatically lists the markers in a movie, a magic-typing list for use with help systems, a clock that draws itself, an intersection detector and a very simple one-armed bandit. (94 K)

Protected movies

(Top) Education:

Trig Tutorial: Pythagoras' own proof of his Theorem, the value of pi and of the radian, and what a sine, cosine and tangent look like. (25 K)

Vector Tutorial: An interactive demonstration of vectors and line slopes, followed by the geometrical derivation of one of the formulae used in the Using Vectors behaviors (see above). (25 K)


Tetris: A Tetris game where you can cheat. If you pause the game you can still move the pieces, using the keys SDF, JKL or 456 (number pad). Use the space bar or the zero on the number pad to drop the pieces into place. (47 K)

Articles published on other sites


The following tutorials are available at Director Online:

Interactive filmLoops

Hot under the color: writing a hypertext behavior

Inter-Sprite Communications: avoiding hard-coding

Look, no sprites: using D8's imaging Lingo to simulate sprites

The following article was published in MX Developer's Journal:

Multiple Undo: improved paintbox behaviors, and a set of scripts that provides a customizable multiple undo feature.