BEGINNING LINGO
A script is a series of instructions written in Lingo, Director’s scripting language. It can describe a simple action like sounding a beep when the user clicks a button or it can describe a complex series of actions, such as how a character moves around the stage.

Behaviours provide fast and efficient ways for you to create simple lingo scripts without having to write them yourself. Using the behaviour inspector you can choose simple scripts from the menus.

Every Lingo script is attached to an element of a director movie: a sprite on the stage, a MEMBER OF THE CAST, A FRAME OF THE SCORE, or the movie itself.

Simple lingo script exercise - create a button:
Select first frame of score, command 7 = toolbar, select the button tool, click the stage where you want the button to appear. At the blinking insertion type the word sound.

Select the sprite on the score and select new script from beside the behaviour diamond on the score. We will be creating a Sprite Script which is only in effect for as long as the sprite exists on stage. The script window appears with the default command on mouseup. Type beep directly below this. Make sure your script finishes with the word end. Click the enter key.

Beep is a lingo command that uses the system sound to make a noise.

On mouseUp is the event Handler-all event handlers begin with ON. They handle messages. Beep is the action. End completes the handler. Check your spelling always. Lingo is specific. But not in upper or lowercase: this does not matter.

(There is an alphabetical and categorized Lingo library in the script window.)

Close the script window by always pressing ENTER on the numeric keys, not the return key.

Rewind and play the movie, click on the button, you should hear a beep.

Lingo scripts are a series of instructions to director to execute specific actions in response to events in a movie. If there is a series of instructions director will execute the first instruction and then the next…

Lingo elements: categories

Commands tell a movie to do something, eg. Go to something, jumps the playback head to a specific frame.

Functions return a value, for example date returns the current date set in the computer.

Keywordsare reserved words that have special meaning in Lingo. Eg. The is necessary in many sprite scripts preceding the property name. This keyword distinguishes the property name from a variable or object name.

Propertiesare attributes of objects, eg. Ink .

Operators are terms that change or compare one or more values. > compares greater or lesser values.

Constants are elements that don’t change. TRUE always means the same thing. True is 1 False is 0.

Lingo scripts: several types of Lingo scripts. The type you choose to write depends on several factors: Where you store the script. The object-sprite or cast- you assign it to. Where you want the script to be available from —within 1 frame or an entire movie.

Primary event handlers are assigned from within other scripts. Run when a user clicks a mouse or time has elapsed.

Score scripts: behaviours - are stored in the score. You can assign a score script to a sprite or a frame. It is only available when the frame or sprite are active on the score.

Cast member scripts: attached to specific cast members and are available whenever the cast member appears in the score.

Movie scripts: are stored in the cast and are assigned to the entire movie.

  1. sprite scripts are assigned to a sprite in the score. Use if you nedd control of a members actions for a short time. A single sprite can have multiple sprites.
  2. frame scripts — assigned to specific frames on the score. Use when you want certain actions to be available everytime the playback head enters the frame.
  3. Cast member scripts — are attache dto specific cast members. Useful when you want the cast member to always execute a lingo script. Return to main menu etc.
  4. movie scripts are available through out the entire movie. Can control when a movie starts, stops and pauses.
  5. Lingo order: sprite, cast, frame, movie. How it works: On mouseup director moves through the scripts in that order looking fore the same message mouse up in the lingo scripts.

Choose the button on stage, modify>sprite>script, replace the beep with the alert

On mouseUp
Alert "this is a message"
End

--Press enter
Play the movie and click the button, an alert box should come up.

Cast script:
Click on the button in the cast window and then click the script button in the cast window. (looks like a page with writing)

on mouseUp
alert "this is cast script"
end

Play movie, notice the sprite script is over riding your new script based on Lingo’s hierarchy of command.

Select the sprite on stage, beside the diamond select clear script. Play movie again. Should exhibit the cast script.

Frame script, shorten sprite, click in frame script, erase frame script and add:

on mouseUp
alert "this is frame script"
end

Play movie — you will see the cast script. Dismiss the box and click anywhere but on the button, should see the frame script. OK

command shift>U, opens movie script:

on mouseUp
alert "this is movie script"
end

To pause the playback head on a frame while still running animations and looped sound use the following in a frame script. This allows the user to look around and explore your environment.

On exit frame
Go the frame
End

Create markers for some different sections. Place some cast members in the various sections.

Cast script, select button, click on script in cast,

on mouseUp
go to "twist"
end --will take you to twist marker

Back button: takes you to marker main - cast: select member, click script,

on mouseUp
go to "main"
end

To go to a differnt movie, use the following if the movies are in the same folder:
on mouseUp
go to movie "dull.dir"
end

To go to a specific frame of a different movie:
on mouseUp
go to frame 20 of movie "dull.dir"
end

or

on mouseUp
go to "main" of movie "dull.dir"
end
--main refers to the marker name

To quit a movie:
on mouseUp
halt
end

Halt quits your movie after you make a projector but just stops it when you are testing in a movie.

A sprite’s outer edges define the bounding rectangle/boundary edges. While the pointer stays within the bounding rect. Director receives continuous mouse within messages

On exitframe
Go loop
End

Sends the playback head back to previous marker. This is great to keep a short animation going while still offering alternatives.

Cast script:

on mouseUp
go to "main"
end

on mouseEnter
go to frame "other"
end

--this loops the frame between markers when the mouse is in the bounding box.

on mouseLeave
go to frame "main"
end

-for an animation to which you want all frames of sprites to respond the same way, shift click for multiple selection and click on the sprite script box — new script

on mouseUp
go to "main"
end

----------------------------------------------
cast script:

on mouseEnter
set the memberNum of sprite 2 to 14
end
--this switches sprite on mouse enter.

---------------------------------------------------
cast script:

on mouseEnter
repeat while the mouseDown —while mouse button is held down--
if rollover (2) = TRUE then —and the mouse is over sprite in channel2--
set the memberNum of sprite 2 to 14 —swap sprites-2 refers to channel # --
else --otherwise--
set the memberNum of sprite 2 to 12 —switch back sprites--
end if --end the if action--
updatestage --redraw changes on stage--
end repeat
end

on mouseUp
set the memberNum of sprite 2 to 12
--when mouse is released reset the sprite in channel #2 cast member to cast # 12

end

****remember that if you are having lingo trouble first check your spelling-must be american version and also check that you have used the proper syntax as well as deleting and clearing any scripts that are left in the cast that you are not using. If in doubt, comment out scripts to find out where the bugs are. adding -- before a line comments it out.
---------------------------------------------------------------------------- ------

Visibility and the variable: if, end if:
Simple toggle button. relationship between two cast members-by clicking on one the other will appear and disappear. Attach it to the sprite that is always visible.

on mouseUp
if the visible of sprite 2 = TRUE then
set the visible of sprite 2 to FALSE
else
set the visible of sprite 2 to TRUE
end if
end

LocH and locV - Horizontal and vertical location of sprite. + is up or to the right/ - is to the left or down.

on MouseUp
set the locV of sprite 1 to the locV of sprite 1-30 - - this sets the location of sprite 1 to 30 frames to the left of where it currently is.
end

The following sets turns the trails of sprite in channel 2 to on and constrains the movement of sprite in channel to to the bounding box of sprite in channel 3.

on startMovie
set the trails of sprite 2 = TRUE
set the constraint of sprite 2 to 3
end

The following constrains the moveable are of sprite in channel 2 to the boundimg box of sprite in channel1.
on mouseUp
set the constraint of sprite 2 to 1
end

Digital video can be a compelling element but the amount of space (memory) it takes up is more than many director movies. The keys to successful uses are to keep the frame rate low, and the window size small as well as compressing as much as possible. It is always a trade off between file size and quality of image. Video on television runs at approximately 30 frames a second and the size in North america is 640 x480 pixels. Think about the size of one second that uses 32 bits of colour (millions). 30 seconds would take up 35 meg. Through compression, reduction of frame rate and even changes the dimensions, it is possible to get this down to 300KB. There is loss in colour and detail but it is more manageable to load on smaller systems. Cinepak and Sorenson are popular compressors. There are many out there and Media Cleaner Pro is one of the most uxseful tools with many varieties of compressors available.

To import select type: quicktime movie.
To play the movie on a button command-ie user clicks a button:

on mouseUp
set the movieRate of sprite 1 to 1 --sprite 1 refers to sprite channel #
end

to play it backwords:

on mouseUp
set the movieRate of sprite 1 to -1
end
--Use 0 to stop

To set the sound level of the quicktime movie apply the following to a sprite or frame. ) is the lowest volume 255 the highest.

on mouseUp
set the volume of sprite 1 to 100
end

SOUND
The following turns on a puppet sound for sound cast member, sound123, without physically placing them into the score.

on mouseUp
puppetSound "sound123.aiff"
end

To play a different sound on mouse up and mouse down write the following the words in "" are the names of the sounds. This works well if they are simple, verbal commands.

on mouseUp

puppetSound "up"

end

on mouseDown

puppetSound "down"
end

to turn off all puppet sound use the 0 command. 0 means off or false.

On mouseUp
puppetSound 0
end

To fade sound in use the following which is fading in sound in sound channel 1 sor 60 seconds. The volume will increase.

on exitFrame
sound fadeIn 1,60
end

on exitFrame
sound fadeOut 1,60
end

To set the volume of the sound use the following command whcih effect the sound in sound channel 1 by using a button which the user presses to lower or increase the volume. The choices are from 0 which is silent to 255 which is the loudest settings.

on mouseUp
set the volume of sound 1 to 50
end

The following script will play randomly the 3 sounds called boing, bang and bing that exist in a cast when the mouse is relesed on a button.-sprite script.

on mouseUp
puppetSound word random(3) of "bong bing bang"
end


The following has two commands attached to a sprite on a score which moves to marker "b" but also performs a transition of the object that changes. 50 refers to a particular transition: a dissolve.

on mouseUp
puppetTransition 50
go "b"

end