29.04.2013 Views

ACTIONSCRIPT 3.0

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> <strong>3.0</strong> DEVELOPER’S GUIDE<br />

Using the external API<br />

<br />

...<br />

function sendMessage(message)<br />

{<br />

if (swfReady)<br />

{<br />

...<br />

getSWF("IntrovertIMApp").newMessage(message);<br />

}<br />

}<br />

...<br />

<br />

The newMessage() ActionScript method expects one parameter, so the JavaScript message variable gets passed to<br />

ActionScript by using it as a parameter in the newMessage() method call in the JavaScript code.<br />

Detecting the browser type<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Because of differences in how browsers access content, it’s important to always use JavaScript to detect which browser<br />

the user is running and to access the movie according to the browser-specific syntax, using the window or document<br />

object, as shown in the getSWF() JavaScript function in this example:<br />

<br />

...<br />

function getSWF(movieName)<br />

{<br />

if (navigator.appName.indexOf("Microsoft") != -1)<br />

{<br />

return window[movieName];<br />

}<br />

else<br />

{<br />

return document[movieName];<br />

}<br />

}<br />

...<br />

<br />

If your script does not detect the user’s browser type, the user might see unexpected behavior when playing SWF files<br />

in an HTML container.<br />

Last updated 4/22/2013<br />

855

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!