1 Reply Latest reply on Apr 7, 2007 9:34 AM by kglad

    ExternalInterface.call returns null

      I am using Flash 8. I have a page that needs to make a call to JavaScript. I have the ExternalInterface.call() working. It calls my function and the function put up the standard testing script Alert window. I set the return string as defined in the Help Example but the return string comes back as null. Here is the Flash Code I am using (Straight out of the online help window):

      import flash.external.*;

      // test code for ExternalInterface.call

      var greeting:String;
      var btn:MovieClip = createButton(100, 30, 0xCCCCCC);
      btn.onPress = function() {
      greeting = String(ExternalInterface.call("ContactFormResult", "Forrest"));
      this.mcTxt.text = greeting; // >> Hi Flash.

      function createButton(width:Number, height:Number, color:Number):MovieClip {
      var depth:Number = this.getNextHighestDepth();
      var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth);
      var mcFmt:TextFormat;

      mc.lineTo(0, height);
      mc.lineTo(width, height);
      mc.lineTo(width, 0);
      mc.lineTo(0, 0);

      mcFmt = new TextFormat();
      mcFmt.align = "center";
      mcFmt.bold = true;

      mc.createTextField("mcTxt", depth, 0, 0, width, height);
      mc.mcTxt.text = "Call JS Function";

      return mc;

      Here is the WORKING JavaScript:

      <script language="JavaScript">
      function ContactFormResult(str) {
      alert(">> Hello " + str + ".");
      return ">> Hi Flash.";

      I put the JavaScript in my index.html file on my server where the SWF file is. The window pops up with the "Call JS Function" message displayed. When I click on the button it displays "null"

      I am at a loss.. The only thing I can think of is something to do with security settings. That's one of the reasons why I would receive a null.

      ANY help will be appreciated!