Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In your Flash, preferably in the first frame, put this:</p> <pre><code>ExternalInterface.addCallback('callFlashFunction', null, yourFlashFunction); function yourFlashFunction (arg1, arg2) { ... } </code></pre> <p>In your Javascript, you can call it via:</p> <pre><code>var flashObj = document.getElementById ('FlashObjID'); flashObj.callFlashFunction (arg1, arg2); </code></pre> <p>If your SWF is in a different domain, remember to allow script access via:</p> <pre><code>&lt;object id="FlashObjID"&gt; ... &lt;param name="allowscriptaccess" value="always" /&gt; ... &lt;/object&gt; </code></pre> <hr> <p>Update (based on your HTML):</p> <pre><code>&lt;a href="#" onclick="return jsLoadSong('2')"&gt;Play song 2&lt;/a&gt; &lt;object id="VSPLAYER" type="application/x-shockwave-flash" data="vs_player.swf" width="280" height="90"&gt; &lt;param name="movie" value="vs_player.swf" /&gt; &lt;param name="allowscriptaccess" value="always" /&gt; &lt;/object&gt; &lt;script type="text/javascript"&gt; var flashObj = document.getElementById ('VSPLAYER'); function jsLoadSong (val) { flashObj.loadSong (val); return false; // to prevent default link action } &lt;/script&gt; </code></pre> <p>I tried to clarify the names to show which is in Javascript, and which is tied to the Flash. Also note that you'd need to wait till the DOM is loaded before calling defining <code>flashObj</code>. here, the <code>&lt;script&gt;</code> tag is after the <code>&lt;object&gt;</code>, so it will work fine.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload