1 Reply Latest reply on Jan 14, 2008 8:09 AM by stherrien

    ExternalIneterface problem

    stherrien
      I have a flex app that calls ExternalInterface but on one that calls js that is loaded last in the page last it doesn't work.

      // ActionScript file
      package com.scripps.npo
      {
      import flash.external.ExternalInterface;
      public class Apptap{

      // retarget when new video is played
      public function retap( path:String, title:String):void{
      if(ExternalInterface.available){
      try{
      var params:Array = new Array(path,title);
      ExternalInterface.call( "retarget", params);

      trace( "[Apptap] retargeting : " + params.toString());
      }catch(err:Error){
      trace(err.message);
      }
      }
      }
      // record events for last retapped video
      public function recordEvent( event_name:String, value:String):void{
      if(ExternalInterface.available){
      try{
      var params:Array = new Array(event_name, value);
      ExternalInterface.call( "video_event", params);

      trace("[Apptap] recording event : " + params.toString() );
      }catch(err:Error){
      trace(err.message);
      }
      }
      }

      }
      }
      // end AS code

      There is no error being sent but outer function is not being called because i can call it from firebug and i get the results i want.

      I cannot put the html in here but here is what it looks like as far as loading wise and how the js is placed in the page.
      <script language="JavaScript" type="text/javascript" src=" http://shawn:8000/static/swfobject.js"></script>
      <script language="JavaScript" type="text/javascript" src=" http://shawn:8000/static/MochiKit/MochiKit.js"></script>
      <script language="JavaScript" type="text/javascript" src=" http://shawn:8000/static/htmlcomponent.js"></script>
      <script language="JavaScript" type="text/javascript" src=" http://shawn:8000/static/ad_manager.js"></script>
      swf is loaded with swobject
      some more html tags no forms or nothing just plain html

      <script language="JavaScript" type="text/javascript" src=" http://javascriptcodelocation"></script>


      here is the js code:

      function retarget( path, title ) {
      alert( path, title ) ; // actually sends the data
      }

      function video_event( event_name, value ) {
      alert( event_name, value ) ; // actually sends the data
      }
        • 1. Re: ExternalIneterface problem
          stherrien Level 1
          This was really a security problem the js was not on the same domain as the flex app so this wouldn't work i worked around this by creating a js file in the same domain to call the other js function that was brought into the page. I couldn't get the security param to work not sure if this is a bug or not.