7 Replies Latest reply on Feb 26, 2009 8:39 AM by Sar975

    HTTP Service Call in Class is working but

    whiterrabbit Level 1
      The problem is getting the returned arrayCollection from my result handler. I traced out the result from the debug perspective and I am indeed receiving data correctly to that point. From the main app. I can see the public variable I declared in the class _jobdetailsAC but I am obviously just seeing that I declared it, not accessing it correctly. I am testing in the debugger like this var returned_array_collection:arrayCollection = testclass._jobdetailsAC and the result is null at that point. Thanks for your help

        • 1. Re: HTTP Service Call in Class is working but
          whiterrabbit Level 1
          Okay ini further testing I see I am assigning the value before I actually have the data which means ... how do I fix that??
          • 2. Re: HTTP Service Call in Class is working but
            Gregory Lafrance Level 6
            You can't access the AC in the constructor as you are. Call a method from the result handler that does what you are doing in the constructor, except for getjobdetails(), which you can do in the constructor to make the request.
            • 3. Re: HTTP Service Call in Class is working but
              Try making your class bindable
              public class ParseJobDetails

              Also where are you calling the method from to make this assignment an mxml component?

              Include the client code if you can.
              • 4. Re: HTTP Service Call in Class is working but
                whiterrabbit Level 1
                I think the problem is with the overall way I am doing this.

                A double click on a datagrid calls a function which launches a popup window and assigns values to textfields and a datagrid dataprovider within that popup.

                The text fields are no problem because those values are coming from the arrayCollection that feeds the datagrid that was double clicked.

                The problem is when I assign the arraycollection to the dataprovider of the new datagrid in the popup. I set a trace statement on the resulthandler within the class and a trace statement in the main app. where I assign the new arraycollection to the popup. The one in the mainapp fires first so that.

                I think I need to put one more function in the main application that makes the call to the server and then dispatches an event that I will listen for in the main app ... and then call the function to launch the popup and assign the arrayCollection.

                Im not in the office now so I don't have the code to post.
                • 5. Re: HTTP Service Call in Class is working but
                  Sar975 Level 1
                  It seems you might benefit from defining your class that contains the arrayCollection as a singleton class this way each of your clients can access the arrayCollection through
                  public var modelLocator:BaseModelLocator = BaseModelLocator.getInstance();

                  then as your data becomes available you can access through {modelLocator.arrayCollectionName}

                  let me know if you want to try this and need help setting up the singleton class.
                  • 6. HTTP Service Call in Class is working but
                    whiterrabbit Level 1
                    Thanks Sar,
                    I'm shaky enough as it is just trying to learn all the ins and outs of regular classes.

                    Actually everything was ok in the class, I just needed to add another function in the main app. The function called after the datagrid is double clicked and looks something like this

                    public var view_jd:ViewJobDetails;
                    public function prelaunch_dv(event:ListEvent):void {

                    indxpos = event.currentTarget.selectedIndex;
                    view_jd = new ViewJobDetails(jobsArray, indxpos);

                    I add an event listener this time and wait to pop open any windows pass any data until the event fires.

                    The event fires when the result handler of the HTTPService call is called. Here is the modified result handler

                    private function getjobdetailshandler(event:ResultEvent):void {
                    _jobdetailsAC = tempArray;
                    dispatchEvent(new Event("notifyMain"));

                    Back to the main app, the opendetailview is now called poping up the window and passing a value to a label and an arraycollection as a dataprovider to a datagrid.

                    public function opendetailview(event:Event):void {


                    viewjob.dv_jobid_text.text = view_jd._jobid;
                    viewjob.dv_details_gd.dataProvider = view_jd._jobdetailsAC;

                    To anyone else having this issue, this may not be a good way to do it, I am just letting you know how I ended up getting it to work. Thanks to dimival on a post I made a while back for the idea to add the event listener.
                    • 7. Re: HTTP Service Call in Class is working but
                      Sar975 Level 1
                      Glad you figured this out. You can email me @ scott.rogers@experian.com if you want the alternative approach.