Programming In Adobe Director - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Programming In Adobe Director

Description:

'Classic' Lingo (dot syntax) (e.g., _movie.go('marker1') instead ... Lingo is not case sensitive. Dynamic data types. Loops. repeat with n = 1 to 10. end repeat ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 20
Provided by: WakeF
Category:

less

Transcript and Presenter's Notes

Title: Programming In Adobe Director


1
Programming In Adobe Director
  • CSC361/661 Digital Media
  • Spring 2007

2
Just some highlights
  • These slides are intended simply to highlight
    some things that may be useful to you, to get you
    over the learning curve more quickly.
  • Other sources
  • Director MX 2004 Training from the Source by Dave
    Mennenoh
  • Directors online Help
  • The Director Developer Center at
    http//www.adobe.com/devnet/director/

3
What is programming in Director?
  • Creating and importing raw material
  • Putting sprites on stage, arranged via a timeline
  • Adding behaviors or attaching scripts to them

4
Syntax
  • You can use three different syntaxes
  • Verbose (looks more like English, like go to the
    frame)
  • Classic Lingo (dot syntax) (e.g.,
    _movie.go(marker1) instead of
  • go to (marker1)
  • Javascript
  • A single script cast member can contain only one
    syntax or the other.
  • Lingo is not case sensitive
  • Dynamic data types

5
Loops
  • repeat with n 1 to 10
  • end repeat
  • repeat while _mouse.mouseDown
  • end repeat

6
Terminology
  • Behaviors (built-in)
  • Events
  • Messages
  • Handlers
  • Scripts

7
  • When the movie first starts, events occur in the
    following order
  • prepareMovie
  • prepareFrame Immediately after the prepareFrame
    event, Director plays sounds, draws sprites, and
    performs any transitions or palette effects. This
    event occurs before the enterFrame event. A
    prepareFrame handler is a good location for
    script that you want to run before the frame
    draws.
  • beginSprite This event occurs when the playhead
    enters a sprite span.
  • startMovie This event occurs in the first frame
    that plays.
  • When the movie encounters a frame, events occur
    in the following order
  • beginSprite This event occurs only if new sprites
    begin in the frame.
  • stepFrame
  • prepareFrame
  • enterFrame After enterFrame and before exitFrame,
    Director handles any time delays required by the
    tempo setting, idle events, and keyboard and
    mouse events.
  • exitFrame
  • endSprite This event occurs only if the playhead
    exits a sprite in the frame.
  • When a movie stops, events occur in the following
    order
  • endSprite This event occurs only if sprites
    currently exist in the movie.
  • stopMovie

8
Scripts
  • You can have more than one handler (i.e.,
    functions or procedures) in a script
  • A global variable defined at the top of the
    script will be accessible in all handlers in the
    script

9
Order of messages
  • The general order in which messages are sent to
    objects is as follows
  • Messages are sent first to behaviors attached to
    a sprite involved in the event. If a sprite has
    more than one behavior attached to it, behaviors
    respond to the message in the order in which they
    are attached to the sprite.
  • Messages are sent next to a script attached to
    the cast member assigned to the sprite.
  • Messages are then sent to behaviors attached to
    the current frame.
  • Messages are sent last to movie scripts.

10
  • Top level functions and properties
  • There are a number of top level functions and
    properties that provide direct access to the core
    objects and functionality in Director.
  • Top level functions castLib(), randomVector(),
    channel() (Top level), rect(), color(),
    script(), date() (formats), date() (System),
    showLocals(), image(), sound(), isBusy(),
    sprite(), list(), symbol(), member(), timeout(),
    point(), trace(), propList(), vector(), put(),
    window(), random(), xtra()
  • Top level properties _global_player, _key,
    _sound, _mouse, _system, _movie 

11
Where do you put the code?
  • Movie scripts
  • Cast member scripts
  • Sprite scripts
  • Frame scripts
  • Parent scripts (for object-oriented programming)

12
Useful things to know
  • _sound.beep()
  • member(castMember1).text Hello
  • put(Im here)
  • string(100)
  • integer(2.1)
  • value(3.4)
  • if _key.key_pressed() SPACE
  • BACKSPACE ENTER QUOTE RETURN TAB

13
Some useful things to know
  • global g_myGlobalVar declared outside of all
    handlers in a script (at the beginning of the
    script).
  • An alternative way to declare global variables is
    via the _global object, as in
  • _global.myGlobalVar
  • string operators and
  • mod
  • ltgt
  • not(sound_enabled)
  • sprite(2)
  • member(3)

14
Using parameters
  • on averageOfThree a, b, c
  • return (a b c)/3.0
  • end

15
Working with image files
  • Use .tiff, .bmp, or .psd (.psd if you want to
    retain an alpha channel for transparency)
  • You can link externally or imbed the image. If
    you link, the image file has to be stored with
    the movie
  • Put the setting to standard compression in the
    Publish Settings (under File menu)
  • You can copy the stage and make it an image, draw
    on images, copy an area from one image to
    another, etc. even at run-time (See Editing
    Image Objects in the Director Help.)

16
Three ways to tween
  • With keyframes
  • With built-in behaviors
  • With Lingo
  • on mouseUp me
  • sprite(3).width 4
  • sprite(3).height 3
  • _movie.startTimer()
  • currtime 0
  • repeat while sprite(3).height lt 600
  • sprite(3).width sprite(3).width 1
  • sprite(3).height sprite(3).height 1
  • sprite(3).height integer(sprite(3).width
    0.75)
  • repeat while _movie.timer - currtime lt 100
  • end repeat
  • updateStage
  • end repeat
  • end

17
Using sounds
  • on mouseEnter me
  • r random(2)
  • if r 1 then
  • sound(3).play(member("ticklingMe"))
  • else sound(3).play(member("haha"))
  • end

18
Properties
  • Properties are variables that are in scope all
    throughout a script. You declare them at the
    beginning of the script. You can access them in
    any handler in the script.
  • The getPropertyDescriptionList() handler lets you
    create a dialog box that prompts for the values
    of properties when a behavior is attached to a
    sprite. (See p. 150 of Director manual.)

19
Creating a behavior with properties
  • Why do it? So you can use the same behavior on
    different sprites, but each sprite has its own
    properties.
  • The behavior uses the properties for the sprite
    to do its thing
Write a Comment
User Comments (0)
About PowerShow.com