Hi,
   Can anybody Please help.I am facing a problem when i am trying to access a 
Flex Function from  
a JSP/HTML page.I am at loss as to why the reference object of th swf 
obtained throws an error saying "Object doesn't support this property or 
method" when it tries to access the Flex method made callable using 
AddCallBack method of Flash's External Interface.

The mxml code as well as Jsp code is given below :-

********************JSP***********************************************


<html>
<head>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
        
        function getMyApp(movieName)
        {
          if (window.document[movieName]) 
          {
              return window.document[movieName];
          }
          if (navigator.appName.indexOf("Microsoft Internet")==-1)
          {
            if (document.embeds && document.embeds[movieName])
              return document.embeds[movieName]; 
          }
          else 
          {
            return document.getElementById(movieName);
          }
        }
                
        function callApp()
        {       var initName = document.getElementById("txtName").value;
                var initAddress = document.getElementById("txtAddress").value; 
                alert("**********In callApp()***********" );
             var flashMovie=getMyApp("mySwf");
             alert("**********After getMyApp()***********"+flashMovie);
             flashMovie.myFlexFunction(initName,initAddress);
             
//flashMovie.SetVariable("/:message",document.UserDetails.txtName.value);
        }

        <form name="UserDetails">
        <table width="60%" align="center" cellspacing="40" border="0">
        <tr>
                <td>&nbsp;</td>
                <td>
                        <input type="Button" value="Communicate to Third Party 
Application" name="btnCommunicate" OnClick="callApp()">
                </td>
        </tr>
        </table>
        </form>
        <form name="flaUserDetails">
        <object id='mySwf' name='mySwf' height='30%' width='40%'>
                <param name='src' value='TextLabel.swf'/>
                <param name='swliveconnect' value='true'/>
                <embed id='mySwf' src='TextLabel.swf' height='30%' width='40%' 
/>
        </object>
        </form>
</body>
</html>


********************************MXML******************************************



?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
initialize="initApp()">
        <mx:Script>
                <![CDATA[

                        import mx.utils.ObjectUtil;
                        import flash.display.LoaderInfo;
                        import flash.external.*;
                        
                        
                        public function initApp():void {
                                
ExternalInterface.addCallback("myFlexFunction",myFunc);
                        }
                        public function myFunc(Name:String,Address:String):void 
{
                                txtName.text=Name;
                                txtAddress.text=Address;
                        }
                ]]>

        </mx:Script>
        <mx:Form id="myForm" width="300" backgroundColor="#909090">
        <!-- Use a FormItem to label the field. -->
        <mx:FormItem label="Name">
        <mx:TextInput id="txtName" width="150"/>
        </mx:FormItem>
        <mx:FormItem label="Address">
        <mx:TextInput id="txtAddress" width="150"/>
        </mx:FormItem>
        </mx:Form>
</mx:Application>

Thanks in Advance,
Piyasha

Reply via email to