web scripting for designers - CGR C/092 - fall 2003
Philip van Allen - v a n a l l e n @ a r t c e n t e r . e d u

room 133, Monday 4:00pm-7:00pm
room 133, Monday 7:00pm-10:00pm
all materials on this web site © copyright 2003, Philip van Allen
 
week 11a - director navigation code, exercise

navigation : 

score frames as scenes : 


 

It is common to use the frames of the score to make different scenes made up of sprites together on the stage together--this is similar to the way we've used frames in the Flash timeline. For example, an informational application could use one frame for the title page, and other frames for the interface to each set of content.

Below is the score from such a Director project, a gallery of projects from the Media Design Program. The channels in frame one, labeled "start," have several text sprites for the title page, frame 6 ("page1") have sprites for the content of the first gallery, and frame 12 ("page2") have sprites for the second gallery.



loop on frame : 

keep the play head on one frame

Normally, Director would play from the first frame of the movie through to the last frame that has content, and then loop back to the beginning. To prevent this, you must put some code in the script channel (above the numbered frames). In Flash, you would put a simple "stop();" in the frame. In Director, you use an event handler just as you would on a sprite.

To put code in the script channel:

  • opening the script editor and use the plus sign button on the left to create the script
  • type in the below code
  • drag the code from the cast to the appropriate frame in the script channel

The following code will prevent the play head from advancing beyond the current frame:

on exitFrame me
    go to the frame
end

 

 
markers : 

navigate to different frames by name

As with Flash, it's possible to label frames with "markers" and use them in the code. Frame markers are better than using frame numbers, because they enable you to move the content of the scene and the marker without affecting the code.

To create markers:

  • click in the marker channel on the approriate frame
  • type in the name of the new marker

Code on a sprite to move to a specific marker would look like this:

on mouseUp me
    go to "page1"
end

 

 
change member : 

change information within a scene

To make rollovers and change the content of a scene you often use the member property of a sprite. The member property points to a particular entry in the cast, and can be changed.

The following code changes the member of the current sprite and other sprites to different cast members. Note that the names on the right side of the equals sign are the names of the cast members. Set cast member names by clicking on the cast member, and typing in the name in the name box at the top of the cast window.

on mouseEnter me
    sprite(the currentSpriteNum).member = "1orange"
    sprite(5).member = "2black"
    sprite(3).member = "sean_04"
end

 

 

exercise : 

write the code for a gallery application

gallery.dir (7.3 meg with code, includes quicktime movie), gallery_no_code.dir (2.4 meg without the code)
view application in a web page

As a class exercise, reproduce the behavior of the above director movie. We'll view the working version first, and then you will work with the version that has all the assets but no code.

 

 

all materials on this web site © copyright 2003, Philip van Allen

top