2 Replies Latest reply on Jun 26, 2006 10:51 PM by Newsgroup_User

    RemoteObject works in mxml, fails in AS

    Level 7
      If I use:

      <mx:RemoteObject id="svc" destination="ColdFusion"
      source="myDir.myCFC"//where myCFC is the name of the cfc file
      (omitting .cfc) and myDir is the path to the cfc under wwwroot
      showBusyCursor="true" />

      and then call svc.methodName(), I get the result of myCFC.

      If I use (after importing all the required packages):

      public class MyClass{
      private var svc:RemoteObject = new RemoteObject();

      public function myMethod():void{
      svc.destination = "ColdFusion";
      svc.source = "myDir.myCFC";
      svc.addEventListener("result", resultHandler);
      svc.addEventListener("fault", faultHandler);

      private function resultHandler(event:ResultEvent):void{
      //my code
      private function faultHandler(event:FaultEvent):void{
      Alert.show( ObjectUtil.toString(event.fault) );

      and then invoke an instance of MyClass() and call myMethod() on the
      instance, I get an error:

      One of the parameters is invalid. (What does parameter mean? There are
      no parameters passed to any of the functions and none are required.)

      If I say continue anyway, the faultHandler reports that the connection
      was not made.

      Can anyone see what I've done wrong?

        • 1. Re: RemoteObject works in mxml, fails in AS
          Level 7
          One odd thing I've found is that if I change the line:



          var anyvar:String = "methodName_or_anything";

          where the variable name itself 'anyvar' is any name other than the name
          of a real method in myCFC, the error changes to:

          The method 'anyvar' could not be found in the component.

          • 2. Re: RemoteObject works in mxml, fails in AS
            Level 7
            The problem has something to do with there needing to be some object
            related to the remote call for the data to be returned to.

            I can generate the same problem in the mxml version by removing the
            datagrid component. Though I can see no explicit connection between the
            remote call and the datagrid object, when the mxml is converted to AS it
            must connect the two using the object specified for the returned result
            in the result event handler!! If you remove the Bindable property for
            this object, the data disappears from the datagrid, but the datagrid
            still contains the correct number of lines!!

            My lack of understanding of oop is my biggest problem however.

            If I have a variable in a class file and import its associated package
            into an mxml file, how do I get that variable to just be the same
            variable in both files?