A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Calling a flash method from Jscript

  1. #1
    Registered User
    Join Date
    Oct 2008

    Calling a flash method from Jscript


    I'm working on a firefox extension. This extensions has a pop-up window (XUL window) that contains an iframe. The iframe's source is pointing to an html that contains a flash object.

    The flash object contains a single external method as follows:

    function internalPlaySound(path:String):void

    ExternalInterface.addCallback("playSound", internalPlaySound);

    I am trying to call this method from a jscript function located on the same html as the flash object itself. Here is how the jscript looks like:


    function getSWF(movieName)
    if (navigator.appName.indexOf("Microsoft") != -1)
    return window[movieName];
    if (document[movieName].length != undefined)
    return document[movieName][1];
    return document[movieName];

    The embedded flash looks like this:

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100" height="50" id="tts" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
    <param name="movie" value="tts.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />
    <embed src="tts.swf" quality="high" bgcolor="#ffffff" width="100" height="50" name="tts" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

    When I try to access the actionscript method from the Jscript method, I get a null reference ('undefined') as if there is no "playSound" method.
    This happens only when I run the page as a firefox extension (from within the XUL popup window). When I run this from a standalone html page on the browser (FF 3.0) I have no problem accessing the actionscript method.

    The flash object is loaded, since I can actually see it on the page.

    Can someone shed some light on this one ?

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Oregon, USA
    You need to use the "id" attribute on your embed to target the swf...take a look at swfObject or else inside your swf you could trace out ExternalInterface.objectID to see what it's called on the page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center