|
Free Open Book
Sams Teach Yourself JavaScript in 24 Hours |
JavaScript and FlashAdobe (formerly Macromedia) Flash is the Web's most popular format for movies and interactive content that require a bit more graphical splendor than HTML and JavaScript can provide. Flash's programming language is similar to JavaScript, and JavaScript can work with Flash. ActionScriptIf you program scripts for a Flash movie, you use a language called ActionScript. You may find that ActionScript has a strong similarity to JavaScript, and for good reasonthe version of ActionScript used in Flash 5.0 and later is based on the same ECMAScript standard that specifies the syntax for JavaScript. Although the language is the same, Flash programming is quite different from writing JavaScript for the Webyou are scripting Flash objects rather than working with the DOM. However, you'll find that the basic syntax of the language is the same, which makes it easy for a JavaScript programmer to work with Flash when its capabilities are needed. JavaScript and Flash CommunicationJavaScript and Flash can communicate and work together. Adobe's Flash/JavaScript Integration Kit, available as a free download, enables JavaScript to call ActionScript functions within Flash objects, and also enables Flash scripts to call JavaScript functions within the page that contains them. The Flash/JavaScript Integration Kit works best with Flash Player 6.0 or later, although it also includes basic support for earlier versions of Flash. If you are developing a Flash application and need it to communicate with JavaScript, you can download the kit from http://weblogs.macromedia.com/flashjavascript/. If you're using an existing Flash object, the author might have already set it up to work with JavaScript, in which case it will have a list of methods available like other plug-in objects. Embedding Flash with JavaScriptOne other common use of JavaScript with Flash is to use JavaScript to generate the <object> or <embed> tag to embed a Flash object. Although you could use HTML directly, using JavaScript enables you to sidestep Internet Explorer's warning dialog that pops up whenever an embedded object is in use. JavaScript can also pass parameters, such as the user's screen size, to Flash by writing them into the <embed> or <object> tag. Did you Know? Microsoft added the warning dialog for embedded objects in response to a patent dispute. See the Try It Yourself section later this hour for an example that uses JavaScript to embed objects in a page and avoid this warning. |
Main Menu |
| 500 Juegos Gratis | 500 Giochi Gratis | 500 Jeux Gratuits | 500 Jogos Gratis | 500 Kostenlose Spiele |