Lingo rules, conventions, concepts:
- If you start it you have to end it : example: on exitFrame me . . . end
exitFrame
- Use the "me" in the on line: it lets Director know that you mean the currently
active object (frame, sprite, cast member).
- There are NO SPACES BETWEEN THE WORDS for ANY variables (whatever that means)
or functions/handlers (whatever that means) in Lingo.
(Examples: "exitFrame" not "exit Frame", and "mouseUp" not "mouse
Up")
- The Lingo convention is to capitalize every word after the first word of
a function/handler or variable in Lingo.
(Examples: "exitFrame" , "mouseUp", "rightMouseDown".)
- There are three types of events in Lingo
- user feedback events (all mouse and keyboard interactions)
- playback events (start & stopMovie, begin & endSprite, enter
and exitFrame)
- time events (idle & timeOut)
- window events (activate move resize zoom and closeWindow)
- Events are only registered if a handler to "capture" and respond
to that event exists somewhere in a script (movie, cast, sprite, frame)
- When an event occurs, a message is sent throughout the event hierarchy and
the script at the top of the hierarchy has the final say in the response to
the message. The hierarchy, from highest to lowest, is:
- The scope of each type of script is the opposite of its hierarchy:
- movie--the entire movie
- frame--affects any sprite (incl. cast member) that is active in that
frame
- cast--affects every instance of that cast member in the score
- sprite--affects only one sprite only for the duration of that sprite.
Scripts are attached to the sprite, not the channel, so even if another
sprite occurs at a different time in that channel, that sprite is only
affected by its own sprite script
- If you want to control as sprite channel that has no sprites in the score
you need to puppet the sprite--i.e. give control to Lingo. As long as a sprite
is puppeted, anything in the score in that channel is ignored, so you may
need to unpuppet the sprite when you are done with Lingo control.
- There are two types of variables--global and local. Local variables only
exist in the context of the handler in which they are created. Global variables
can be accessed in any handler of the movie and any time in the movie.
- To use global variables, you must include the line "global gThisVariable"
before the variable is used in a script. It is best to write the global
line before the handler:
global gThisVariable, gMyBackground
on mouseUp me
sprite(gMyBackground).member = member(gThisVariable)
end mouseUp
- Lingo convention suggests that all global variable begin with a "g"
-- gMyVariable --to distiguish them from local variables
- You can create custom properties that allow you to use scripts on multiple
sprites and have different values affecting each sprite.
- To use properties, you must include the line "property pThisProperty"
before the variable is used in a script. It is best to write the global
line before the handler:
property spriteNum, pThisProperty
on mouseUp me
sprite(spriteNum).locH = pThisProperty
end mouseUp
- Lingo convention suggests that all properties begin with a "p"
-- pMyProperty --to distiguish them other variables
Programming for Interactive Mulitmedia I Home