2 Replies Latest reply on Aug 28, 2009 12:32 AM by shrainp

    Getting Error while calling Flex function from JavaScript

    shrainp

       

      Hi,

      I have an aspx page, which shows charts as per dropdown selection,

      I am using flex charts for flex.In aspx page, i am calling an mxml function using javascript.below is the code for javascript in aspx.

      Javascript  code in aspx page:

      <script type="text/javascript">      
      function callApp(formid) {
          try {
                  var objectChart = document.getElementById("statisticsChart");
                  alert(objectChart.id);                
                  objectChart.myFlexFunction(formid,get('<%=HiddenDashboardWS.ClientID %>').value);
             }
          catch (e) {
              alert(e.message);
          }
      
      }
      
      function getDropDownListvalue() {
          var IndexValue = $get('<%=FormDropDownList.ClientID %>').selectedIndex;
          var SelectedVal = $get('<%=FormDropDownList.ClientID %>').options[IndexValue].value;
          //  alert(SelectedVal);
          callApp(SelectedVal);
      }
      </script>
      

      Html code where dropdown control is placed

       

      <asp:DropDownList CssClass="combo" ID="FormDropDownList" runat="server" AutoPostBack="false"></asp:DropDownList>
      
      <object id="statisticsChart" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
      height="220" width="680">
          <param name="src" value="../swf/DashboardStatisticChart.swf" />
          <param name="flashVars" value="" />
          <embed name="statisticsChart" src="../swf/DashboardStatisticChart.swf" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" height="220" width="680" flashvars=""></embed>
      </object>
      

       

      Mxml code:

       

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  backgroundColor="white" creationComplete="initApp();" >
      <mx:script>
        public function initApp():void {
      ExternalInterface.addCallback("myFlexFunction",myFunc);
             }  
      
        public function myFunc(s:String,wsurl:String):void {
           Formid.text = s;
           webService.wsdl = wsurl;
           Alert.show("webservice");
      //Getdata calls webservice and gets xml data     
      GetData();
      //showchart() will draw chart 
                       ShowChart();
                      }
      </mx:script>
      </mx:Application>
      

       

      Above code works perfect in ie, but in firefox, it gives An error saying “chartObject.MyFlexFunction is not a function”.

       

      I am getting the object in javascript in all the browsers, but not the functions!

       

      Does anyone has worked with this?

       

      Any help will be highly appreciated.

       

      Regards,

      Nirav Patel