2 Scripting basics Behaviors – Scripts attached to sprites or frames in the Score, referred to as a sprite behavior or frame behavior. This differs from the behaviors that are in the library palette.All behaviors that have been added to the cast appear in the Behaviors inspector Pop up menu. You can attach the same behavior to more than one location in the score. When you edit a behavior, the edited version is applied everywhere the behavior is attached in the score.
3 Scripting basics Movie Scripts – These respond to events such as key presses, mouse clicks and your own custom events, and can control what happens when a movie, starts, stops or pauses. Handlers in a movie can be called from other scripts on the movie as the movie plays.Movie scripts are available to the entire movie, regardless of which frame the movie is in or which sprites the user is interacting with. When a movie plays a window or as a linked movie, a movie script is available only to it’s own movie.
4 Scripting basics Parent scripts These contain Lingo used to create child objects. You can use parent scripts to generate script objects that behave and respond similarly yet can still operate independently of each other.Scripts attached to cast members
5 Script basics Scripts attached to cast members These are attached directly to a cast member, independent of the Score. Whenever the cast member is assigned to a sprite, the cast members script is available.
6 How scripts flowDirector always executes Lingo statements starting with the first statement and continuing in order until it reaches the final statement or a statement that instructs Lingo to go somewhere elseTo set up statements so that they run when specific conditions exist, you use if…then, case, and repeat loop structures.
7 The order in which statements are executed affects the order in which you should place statements. If you write a statement that requires some calculated value, you need to put the statements that calculates the value first.X = 2+2Put string (x) into member “The Answer”
8 Planning is essentialBefore writing reams of scripts, formulate your goals and understand what you want to achieve.Scripting and testing will take time so be patient!The best approach is start simple and test frequently.
9 Attaching script -Most common frame behaviors – keeps playback head looping a single frame. This is useful when you want your movie to keep playing in a single frame while waiting for the user to click a button or for a digital video or sound to finish playing.Behavior channelDouble click the behavior channel in the frame that you want to attach a behavior to.
10 The lingo expression….“the frame” always refers to the frame currently occupied by the playhead. This statements essentially tells the playback head to “go back to the frame you are currently in”.
11 To create a sprite behavior (script attached to a sprite) In the score or on the stage, select the sprite that you’re attaching the behavior to. Then select Window, Behavior Inspector and select New Behavior from the pop up menu.Inputs – on mouse up and end – making it easy to attach a common behavior.
12 To open a behavior for editing: Double click the behavior in the cast WindowClick the Script Window icon in the Behavior inspector.
13 To remove a behavior from a score location: Select the location and then delete the script from the list displayed in the Property Inspector
14 To attach existing behaviors to sprites or frames: Drag a behavior from a cast to a sprite or frame in the score or (for sprites) to a sprite on the stage.In the score select the sprites or frames that you’re attaching the behavior to. Then select Window, Behavior Inspector and select the existing behavior from the pop up menu.
15 To create a movie script: (script attached to a movie) If the current script in the script window is a movie script, click the New Script button in the Script window
16 Lingo terminology Arguments – Placeholders that let you pass values to scripts e.g.On addThem a,bc = a +bEnd
17 Commands:Instruct a movie to do something while the movie is playing e.g. go the frameConstants: Elements that don’t change. TAB, EMPTY and RETURNEvents: Actions occur while a movieExpressions: any past of a statement that produces a value e.g 2+2
18 Functions:Return a value – dateHandlers:Lingo statements within a script that run when a specific event occurs in a movie e.g. beepKeywords – reserved words that have a special meaning e.g. end
19 Lists – ordered sets of values used to track and update an array of data, such as a series of names or the values assigned to a set of variables. E.g. [1,4,2]Messages – notices that Director sends to scripts when specific events occur in a movieOperators – calculate a new value from one or more values. E.g. +, operator adds two or more values together to produce a new value
20 Properties are attributes that define an object. Variables – elements to store and update values. To assign values to variables or change the values of many properties you use the = operator or the set commanding set startValue == 0 places a value of 0 into a variable named startValue
21 Lingo supports a variety of data types, including references to sprites and cast members, TRUE and FALSE or 1 and 0 (Boolean) values, strings, constants, integers, floating point numbers, points, reacts, colors and dates
22 Lingo is not case sensitive – you can use uppercase letters however you want