0 Replies Latest reply on May 5, 2008 1:41 PM by luke14free

    How to pass variables from JavaScript to Flex

      Dear Flex comunity,
      Is there anyone who knows why isn't this code working?
      --FLEX 3--
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="440" height="440" initialize="initApp()">
      import flash.external.*;
      import mx.controls.Alert;
      public var movie:String="";
      public function initApp():void
      if (ExternalInterface.available)
      ExternalInterface.addCallback("setSource", setSource);
      public function setSource(source:String):void


      private function formatPositionToolTip(value:int):String{

      // do only handle minuts.

      var result:String = (value % 60).toString();
      if (result.length == 1){
      result = Math.floor(value / 60).toString() + ":0" + result;
      } else {
      result = Math.floor(value / 60).toString() + ":" + result;
      return result;
      <mx:VideoDisplay id="videoDisplay" source="{movie}" width="390" height="303" left="10" top="10" initialize="setSource('')"/>
      ---END OF FLEX 3---

      and this is how i call my setSource function from JavaScript

      function getFlexApp(appName) {
      if (navigator.appName.indexOf ("Microsoft") !=-1) {
      return window[appName];
      } else {
      return document[appName];
      --END OF JavaScript--

      When I run the page in local I get
      "SecurityError: Error #2060: Security Violation in sandbox: the caller ExternalInterface file:///C:/Documents and Settings/WebDesign/Desktop/td_flex/media.swf cannot access to file:///C:/Documents and Settings/WebDesign/Desktop/td_flex/media.html."
      When I run the page online my player just doesn't work.

      Thanks in advance for your help,