开发者

flashObject 'is not a function' error only in Firefox

开发者 https://www.devze.com 2023-01-09 00:54 出处:网络
I have a page with a flash chart to display. First, I make a separate AJAX call to grab the chart data, and then process it in javascript and call the flash object functions like this:

I have a page with a flash chart to display. First, I make a separate AJAX call to grab the chart data, and then process it in javascript and call the flash object functions like this:

var flashObj = YAHOO.util.Dom.ge开发者_开发问答t(chartContainer);
if (!YAHOO.env.ua.ie) {
    flashObj = flashObj.getElementsByTagName("embed")[0];
}
flashObj.SetSettingOption(dataXml.xml);
flashObj.SetAndParseData(dataXml.xml);
flashObj.Draw();

However, in Firefox I get the error "flashObj.SetSettingOption is not a function". I do not encounter this in IE8. Is this because the flash object is not fully loaded? But then on subsequent visits to the page, the flash object should be cached, but the same error appears.

Edit: Also here part of the html

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="MyChart" width="760"
    height="455" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
    <param name="movie" value="../flash/MyChart.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="wmode" value="transparent" />
    <embed src="../flash/MyChart.swf" quality="high" bgcolor="#ffffff" width="760"
        wmode="transparent" height="455" align="middle" play="true" loop="false"
        allowscriptaccess="sameDomain" type="application/x-shockwave-flash" 
        pluginspage="http://www.adobe.com/go/getflashplayer">
    </embed>
 </object>

Thanks in advance for any help!


Is this because the flash object is not fully loaded?

Yes, that frequently happens with Flash.

But then on subsequent visits to the page, the flash object should be cached, but the same error appears.

Probably not. The flash object needs to do set up its external interface. This takes some time, no matter if the .swf file itself is cached or not.

Usually this is solved by using a callback function in ActionScript, something like

ExternalInterface.call('flashLoaded');

or similar.


Try to use "document" instead of "flashObj", like this:

if (!YAHOO.env.ua.ie) {
    flashObj = document.getElementsByTagName("embed")[0];
}

If it doesn't work, so you could try using document.embeds["YOUR_FLASH_OBJECT_ID_HERE"] only for Firefox, like this:

if (!YAHOO.env.ua.ie) {
    flashObj = document.embeds.YOUR_FLASH_OBJECT_ID_HERE;
}

Take a look at this documentation, it might help you: Referencing Flash Movie

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消