OK, so I have created this hello world service and then had WebOrb
create the code I see in the actionscript comments This:

(If using Model-View-Controller)
- Modify the constructor of the class below to accept the controller
object
- Modify response handlers to pass return values to the controller

(if not using MVC)
- Modify the constructor of the class below to accept your View object
- Modify response handlers to display the result directly in the View

I am not useing MVC so I have to use the 2nd commented option.  the
problem is I am not sure what to do, someone help me?

Here is my PHP code:
<?php
class HelloWorld {
        function ShowMe()
        {
                return "Tom Jones";
        }
        function ShowName($name)
        {
                return 'Hello ' . $name;
        }
}
?>
So I have 2 methods, ShowMe and ShowName.

Here is my as code:
          package comp.HelloWorld
          {
          import mx.rpc.remoting.RemoteObject;
          import mx.controls.Alert;
          import mx.rpc.events.ResultEvent;
          import mx.rpc.events.FaultEvent;
          import mx.rpc.AsyncToken;
       import mx.rpc.IResponder;
      
          import comp.HelloWorld.vo.*;
                
          public class HelloWorld
          {
          private var remoteObject:RemoteObject;
          private var model:HelloWorldModel;

          public function HelloWorld( model:HelloWorldModel = null )
          {
                  remoteObject  = new RemoteObject("GenericDestination");
                  remoteObject.source = "comp.HelloWorld.HelloWorld";

                  remoteObject.ShowMe.addEventListener("result",ShowMeHandler);
                  
remoteObject.ShowName.addEventListener("result",ShowNameHandler);
                  remoteObject.addEventListener("fault", onFault);
                  
                   if( model == null )
                          model = new HelloWorldModel();
                  
                  this.model = model;
                  
          }

      public function setCredentials( userid:String, password:String
):void
      {
        remoteObject.setCredentials( userid, password );
      }

      public function GetModel():HelloWorldModel
      {
        return this.model;
      }   

          public function ShowMe(  responder:IResponder = null):void
         {
                  var asyncToken:AsyncToken = remoteObject.ShowMe();
          
                        if( responder != null )
                                asyncToken.addResponder( responder );
                }

          public function ShowName( name:String, responder:IResponder =
null):void
         {
                  var asyncToken:AsyncToken = remoteObject.ShowName( name);
          
                        if( responder != null )
                                asyncToken.addResponder( responder );
                }
          public virtual function ShowMeHandler(event:ResultEvent):void 
          {
                  var returnValue:Object = event.result as Object;
                  model.ShowMe = event.result as Object;
          }

          public virtual function ShowNameHandler(event:ResultEvent):void 
          {
                  var returnValue:Object = event.result as Object;
                  model.ShowName = event.result as Object;
          }

         public function onFault (event:FaultEvent):void
        {
                Alert.show(event.fault.faultString, "Error");
        }
  }

  }

I get an error on: import comp.HelloWorld.vo.* (not sure what this is
or how to create it)


And here is another chunck of code that I have to modify

 public virtual function ShowMeHandler(event:ResultEvent):void 
{
     var returnValue:Object = event.result as Object;
     model.ShowMe = event.result as Object;
}

public virtual function ShowNameHandler(event:ResultEvent):void 
{
     var returnValue:Object = event.result as Object;
     model.ShowName = event.result as Object;
}

I get an error:
(Severity and Description       Path    Resource        Location        
Creation Time   Id
1119: Access of possibly undefined property ShowMe through a reference
with static type comp.HelloWorld:HelloWorldModel.
WeborbHelloworld/src/comp/HelloWorld    HelloWorld.as   line 95
1222790567712   8938) 

On these 2 lines of code:
model.ShowMe = event.result as Object;
model.ShowName = event.result as Object;

I just want to return that stuff, what do I have to do in order to fix
the errors.

Thanks,
timgerr


Reply via email to