User Guide

ADOBE ATMOSPHERE 245
User Guide
dir(object)
Displays a hierarchical list of the object’s children in the chat output window.
obj = theStage.getSolidObject(0);
prim = obj.rootPrimitive;
dir(prim);
path(object)
Returns the absolute path of an object based on parent links.
prim = theStage.getPrimitive(“somePrimitive”);
primPath = path(prim);
chat.print(primPath);
PluginCommand(stringCommand, 0, 0)
This method allows Webpage Javascript to communicate with Atmosphere Javascripts. Any Javascript code
that Atmosphere can process can also be triggered from an Webpage script. Functions can be called, properties
changed, and variables updated.
In the Webpage, the Atmosphere Player is loaded using the <object> tag, which also allows for an “id” value in
the tag. (If you are using the AtmosphereInterface.js” provided by Adobe, the “id” value will automatically be
assigned to “MetaCtl0”.) Once the page has been processed and Atmosphere is loaded, you may reference the
Atmosphere object using the document object SceneGroup (DOM) in HTML. The “PluginCommand” described
here becomes a method of the Atmosphere object, and is called in this manner:
document.all.MetaCtl0.PluginCommand(stringCommand, 0, 0);
To send a command to from the Webpage javascript to Atmosphere Javascript, embed the identical Atmosphere
command into a string as the “stringCommand” argument. Because the command is sent as a string, pay
careful attention to how embedded strings within your command are represented, since it is possible that they
may incorrectly terminate the command. As a reminder, there are two methods in Javascript for ensuring that
multiple string quotations do not cancel each other out. The fi rst is easier to visualize for syntax compliance, but
as your command string gets longer the second method will become useful.
First Method: alternate the use of quotation types, as in “ . Here’s an example of a short command which is
easy to recognize as having correct syntax, and easy to send:
document.all.MetaCtl0.PluginCommand(“chat.print(‘Hello Atmosphere User!’);”, 0, 0);
Second Method: use the backslash character “ \ “ prior to the embedded quotations. Using the backslash
character will instruct Javascript that the next character in line should be processed as part of the string, and
not a control character. The example shown here uses the same command example as above, but with different
formatting to help clarify the backslash use:
document.all.MetaCtl0.PluginCommand(“chat.print(\”Hello Atmosphere User!\”);”, 0, 0);
Both examples above will produce the same result in the Atmosphere Chat window (a string message). Again,
depending upon the length of your command, both methods will be useful, with longer command strings being
more easily created with the second method.