Adobe atmosphere builder 1 用户手册

下载
页码 84
61
Creating effects with JavaScript
About working with JavaScript
If you know how to write JavaScript, you can add effects to your world using the 
Atmosphere JavaScript API (Application Program Interface). These effects can be simple 
or complex—ranging from adding a sound effect to creating an interactive animation. 
The possibilities are limited only by your ability to implement your ideas in JavaScript.
Keep in mind that this documentation doesn’t explain how to write JavaScript code—you 
can find a wealth JavaScript resources on the Web and in print. This documentation does 
provide information about how to incorporate scripts into a world and gives you some 
ideas for what you can do with the Atmosphere JavaScript API. For more information, see 
the Atmosphere JavaScript API documentation. This documentation is installed with 
Atmosphere Builder and is accessible from the Atmosphere folder in the Windows Start 
menu.
Attaching a script to a world
You can attach a script to an object, a group of objects, or a whole world. If you attach a 
script to an object or group, you can use the keyword this to refer to the current object. 
Alternately, you can attach a script to the world and refer to objects by name. The world 
script is always run before any of the other scripts; therefore, you can use the world script 
to do initializations and provide methods that are required by other scripts.
To attach a script to an object or group:
1
Select a wireframe view: Top, Side, or Isometric.
2
Select the object or group to which you want to attach the script. 
3
In the Object Inspector palette, enter the location of the JavaScript source file in the 
JavaScript URL text box. 
To attach a script to a world:
In the World Settings palette, enter the location of the JavaScript source file in the JavaS-
cript URL text box.
atmosphere.book  Page 61  Wednesday, March 21, 2001  6:14 PM