13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Using the external API<br />

<br />

...<br />

function s<strong>en</strong>dMessage(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 differ<strong>en</strong>ces in how browsers access cont<strong>en</strong>t, 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 docum<strong>en</strong>t<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 docum<strong>en</strong>t[movieName];<br />

}<br />

}<br />

...<br />

<br />

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

in an HTML container.<br />

Last updated 6/6/2012<br />

854

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

Saved successfully!

Ooh no, something went wrong!