Presentation on theme: "Introduction to Macromedia Director 8.5 – Lingo. Scripting basics Behaviors – Scripts attached to sprites or frames in the Score, referred to as a sprite."— Presentation transcript:
Introduction to Macromedia Director 8.5 – Lingo
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. 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.
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 its own movie.
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
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. 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.
How scripts flow Director 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 else To set up statements so that they run when specific conditions exist, you use if…then, case, and repeat loop structures.
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+2 Put string (x) into member The Answer
Planning is essential Before 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.
Attaching script - Double click the behavior channel in the frame that you want to attach a behavior to. Behavior channel 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.
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.
To create a sprite behavior (script attached to a sprite) In the score or on the stage, select the sprite that youre 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.
To open a behavior for editing: Double click the behavior in the cast Window Click the Script Window icon in the Behavior inspector.
To remove a behavior from a score location: Select the location and then delete the script from the list displayed in the Property Inspector
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 youre attaching the behavior to. Then select Window, Behavior Inspector and select the existing behavior from the pop up menu.
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
Lingo terminology Arguments – Placeholders that let you pass values to scripts e.g. On addThem a,b –c = a +b End
Commands: Instruct a movie to do something while the movie is playing e.g. go the frame Constants: Elements that dont change. TAB, EMPTY and RETURN Events: Actions occur while a movie Expressions: any past of a statement that produces a value e.g 2+2
Functions: Return a value – date Handlers: Lingo statements within a script that run when a specific event occurs in a movie e.g. beep Keywords – reserved words that have a special meaning e.g. end
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 movie Operators – calculate a new value from one or more values. E.g. +, operator adds two or more values together to produce a new value
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
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
Lingo is not case sensitive – you can use uppercase letters however you want