1 Reply Latest reply on Nov 19, 2008 11:29 AM by Newsgroup_User

    Accessing External Components problem

    alex-party
      Hello,
      I really stuck on this one, please help someone.
      I'm trying to create a HTTPService class to return response to the caller Component throught Application.application.(" some component ").ServerHandle() and I don't know if there is a way to find caller component "name" or "reference ID" that I could use in some way, so I can return results to the caller component, and not necessary to main application...

      ================ Server.as =======================
      package {

      public class Server{

      static public function call(action:String):void{
      srv.send(params);
      }

      static private function srvResult(evt:ResultEvent):void{

      //(A) This works only if service called from main application.

      Application.application.ServerHandle("someaction",evt);

      //(B) But I would like to return results to some "childcomponent.mxml" by it's reference in a way similar as:
      Application.application.("childcomponent").ServerHandle("someaction",evt);

      }

      }
      }


      ================ application.mxml =======================
      public function ServerHandle(evt:ResultEvent):void{
      //we can have results here if we use plan A)
      }


      ================ childcomponent.mxml =======================
      public function ServerHandle(evt:ResultEvent):void{
      //this is where we want to return results by plan B)
      }


        • 1. Re: Accessing External Components problem
          Level 7

          "alex-party" <webforumsuser@macromedia.com> wrote in message
          news:gg1nrt$hl0$1@forums.macromedia.com...
          > Hello,
          > I really stuck on this one, please help someone.
          > I'm trying to create a HTTPService class to return response to the caller
          > Component throught Application.application.(" some component
          > ").ServerHandle()
          > and I don't know if there is a way to find caller component "name" or
          > "reference ID" that I could use in some way, so I can return results to
          > the
          > caller component, and not necessary to main application...

          http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=922&produc tId=2
          http://flexdiary.blogspot.com/2008/11/more-thoughts-on-remoting.html

          Essentially, you want to use this pattern to add a responder to the token
          that has a result handler that you can specify via the argument that calls
          the function. Then the result handler that lives in whichever component
          will receive the result.

          But you might also consider abstracting it out a bit more where the
          component generates an event that lets the application know that the
          information is desired, have the application call for the information and
          update the model when it is received, then just bind to the model from the
          component.

          HTH;

          Amy