views:

56

answers:

2

I have js code:

function onFlashReady() {        
    sendToAS("sit");
}

function callJS(value) {        
    onFlashReady();
    return "Hi Flash.";
}

function thisMovie(movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
         return window[movieName];
     } else {
         return document[movieName];
     }
 }
 function sendToAS(value) {         
     thisMovie("FlashID").callAS(value);
 }

html:

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="850" Height="588" id="FlashID" tabindex="0">
      <param name="movie" value="BusFlex/BusProducts.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="allowScriptAccess" value="always" />
      <param name="swfversion" value="6.0.65.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <!--[if !IE]>-->
         <object type="application/x-shockwave-flash" data="BusFlex/BusProducts.swf" width="850" height="588">
      <!--<![endif]-->
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="allowScriptAccess" value="always" />
      <param name="swfversion" value="6.0.65.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <div>
         <h4>Установите или включите Adobe Flash Player.</h4>
         <p><a href="http://www.adobe.com/go/getflashplayer"&gt;&lt;img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
      </div>
      <!--[if !IE]>-->
         </object>
      <!--<![endif]-->
      </object>
      <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
      <script type="text/javascript">
      <!-- swfobject.registerObject("FlashID"); //-->
      </script>
      </div>

and actionscript code:

protected function application1_creationCompleteHandler(event:FlexEvent):void
{
     flash.system.Security.allowDomain("http://mysite.ru");
     flash.system.Security.allowDomain("http://localhost");
     if(ExternalInterface.available)  
     {
          ExternalInterface.addCallback("callAS", fromJS);
     }
     ExternalInterface.call("callJS", "Hello JS!");
}
public function fromJS(str:String):void 
{
   ...
}

But it works in IE only. In FF this does not work. Help me please.

+1  A: 

It looks like the issue is in your flash embed html, Mozilla browsers rely on the embed tag but you have object again. Try using something like so within your object node:

<embed type="application/x-shockwave-flash" data="BusFlex/BusProducts.swf" width="850" height="588" allowscriptaccess="always">
</embed>
Dave
How does embed work in ie do you have to keep both the object and the embed tag? [Swfobject][http://code.google.com/p/swfobject/] has kept me happily unaware of this.
Tjelle
Yep you would keep both where the embed is just nested within the object. I prefer swfobject too and overlooked that you are using its registerObject function. Now I'm not quite sure the issue, are you certain document["FlashID"] is not null in FF?
Dave
A: 

Thanks!!! I was looking for an answer for two days! This my new code:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="850" height="588" id="FlashID" tabindex="0">
    <param name="movie" value="BusFlex/BusProducts.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <param name="allowScriptAccess" value="always" />
    <param name="swfversion" value="6.0.65.0" />
    <param name="expressinstall" value="Scripts/expressInstall.swf" />

    <!--[if !IE]>-->
    <embed src="BusFlex/BusProducts.swf" type="application/x-shockwave-flash" data="BusFlex/BusProducts.swf" width="850" height="588" allowscriptaccess="always" name="FlashID">

      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="allowScriptAccess" value="always" />
      <param name="swfversion" value="6.0.65.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <!--<![endif]-->

      <!--[if IE]>
      <div>
        <h4>YCTAHOBUTE Adobe Flash Player.</h4>
        <p><a href="http://www.adobe.com/go/getflashplayer"&gt;&lt;img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
      </div>
      <![endif]-->
     <!--[if !IE]>-->
     </embed>
    <!--<![endif]-->
  </object>
GLeBaTi