Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Let me now review some general syntax rules that apply to both lingo and java script syntax. Now in JavaScript syntax, comments on a single line, again are preceded by a double slash, double forward slash, to be more precise. Comments that cover multiple lines are preceded with a forward slash star, and then followed by a star forward slash,so there's a multiple line comment in JavaScript. You can place a comment on its own line or after any statement, so you'll see that in most of the behavior scripts that are included with director you'll see examples of both. Here's an example of a multiple line comment but there are also comments placed after a particular line. All you would do is go to that line and type a double hyphen and then this is a comment; notice it is in red, automatically. Director knows what this double hyphen means. Let's now shift our attention to parentheses. Parentheses are required after all method and function names. For example, when calling the sound objects beep method; you must include the parenthesis after the work beep, so you're going to get a script that looks like this. There's the parenthesis after the method. If we go back and look at the behavior here, you'll see quite a number of open and closed parentheses. Often times they have arguments or parameters in there. In JavaScript, here is an example of a method. It's formatted correctly, notice the underscored sound on beep, and then I have my open and closed parentheses after that method. Now when you call a method, function or handler, from within another method, function or handler, you must include parentheses in the calling statement. In the following example, the modify Sprite method contains a call to a Sprite clicked handler. The call to the Sprite clicked handler must include parentheses, otherwise a script error occurs. So here I have my function, modify Sprite, and then within that I have my Sprite clicked line there, so notice it here when I'm calling the function Sprite clicked, I have the open and closed parentheses. Notice I have a comment there, but you would include your handler code down below, after the open and closed parentheses. You can also use parentheses to override the order of precedence in math operations, or to make your statements easier to read. For example, the first math expression here yields a result of 13; 5 x 3 Ð 2, but to make this easier to read, you can subtract the 3-2, and then multiply by 5, and that will yield 5. Notice that the order of the math execution differs. The way that this works is the lingo or JavaScript will execute the math inside the parentheses first, in this case 3-2, and then multiply the result outside of those parentheses. We can see that the first one yields 13, the second one yields 5. Now event handler syntax, which I covered in the previous movie, also varies between lingo and JavaScript syntax, and lingo handlers use the syntax on handler name. In JavaScript syntax, handlers are implemented as functions, and use the syntax function handler name, and then notice there's an open and closed parenthesis. For example, the following handler on mouse down, next line, underscore, sound dot beep, open and closed parentheses, end. This is an example of a lingo event handler. When the mouse is pressed over a Sprite, the beep, consistent beep sound will play. In JavaScript, let's go ahead and label this with a comment, this would be written function, mouse, down. Notice that the d in down is capitalized so this is easier to read; open, close parenth. Open curly brace, underscore, sound dot beep. Open, close parenth, semicolon, and then close out the curly brace. Like so, let's bring this up like so. So that's the equivalent of an event handler in JavaScript, also similar to flash ActionScript. Let me now move on to the next movie, and continue my review of important scripting syntax rules, that you'll need to learn and use when scripting in director, including line continuation symbols, semicolons, character spacing and much, much more.
| Course: | Adobe Director 11 |
| Author: | James Gonzalez |
| SKU: | 33901 |
| ISBN: | 1-934743-84-4 |
| Release Date: | 2008-07-31 |
| Duration: | 9.5 hrs / 107 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |