Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:20:06+00:00 2026-05-24T07:20:06+00:00

I’m a Flex newbie and I’ve searched both StackOverflow and Google’d but can’t seem

  • 0

I’m a Flex newbie and I’ve searched both StackOverflow and Google’d but can’t seem to figure out this (simple) problem with Flex/ActionScript 3 Asynchronous programming. I have a PHP service (Zend) that inserts a row into the table. What I would like to do is be able to call the service twice consecultively with different row values, and get back the new IDs (primary keys) returned by the service. Then I display the new IDs as 2 Alerts.

The problem is when I can the service twice in a row, I only get an Alert.show() for the last and most recent service call. I don’t know how to access the result of the first.

I recognize I can reconfigure my Flex code and PHP service to accept an array of objects and just send a single PHP service call for both and receive back an array object with the results, but I’m also trying to get a better understanding in general how AsyncToken is working and how to access old results that I need. Is each use of {serviceResult}.token overwriting my previous result?

<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
   // ...

Here is my related code where I want to set up 2 default folders for new users “Home” and “temp”:

 // imports
 import mx.collections.ArrayCollection;
 import mx.controls.Alert;
 import mx.events.CloseEvent;
 import mx.events.FlexEvent;
 import mx.rpc.AsyncToken;
 import mx.rpc.IResponder;
 import mx.rpc.events.FaultEvent;
 import mx.rpc.events.ResultEvent;
 import mx.rpc.remoting.mxml.RemoteObject;
 import mx.rpc.Responder;
 import spark.events.IndexChangeEvent;

import valueObjects.Folders;


// When the user clicks "Save" button, 2 new folders are created for a new user:
protected function pendingUserSaveButton_clickHandler(event:MouseEvent):void 
{
       // Create 2 initial user folders: Home and temp-taiwan
       var t1Folders:Folders = new Folders();

   t1Folders.users_email = tempUser.email;
   t1Folders.name = t1Folders.description = "Home";

   createFoldersFunction( t1Folders ); // assume returns folder ID = 100

   var t2Folders:Folders = new Folders();
   t2Folders.users_email = tempUser.email;
   t2Folders.name = t2Folders.description = "temp";

   createFoldersFunction( t2Folders ); // assume returns folder ID = 101
}

and here are my event handlers, and I want an Alert box for each new ID to pop up:

protected function createFoldersFunction(item:Folders):void
{
    createFoldersResult.token = foldersService.createFolders(item);
}

protected function createFoldersResult_resultHandler(event:ResultEvent):void
{
    Alert.show("Folder #" + ((event.result as int) as String) + " created");
            // Currently, I only get Alert saying "Folder #101 created".
            // I want to see 2 Alerts - one for #100 and another for #101

}

and here are my mx codes for callresponder and service:

<s:CallResponder id="createFoldersResult"
    result="createFoldersResult_resultHandler(event)"/>
<foldersservice:FoldersService id="foldersService"
    fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
    showBusyCursor="true"/>

Only ‘101’ (the result of second service call) is triggering an Alert. Why is this?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:20:08+00:00Added an answer on May 24, 2026 at 7:20 am

    Your code is overriding the token that createFoldersResult should respond to. A proper code would be:

    protected function createFoldersFunction(item:Folders):void
    {
        var token:AsyncToken = foldersService.createFolders(item);
        var responder:Responder = new Responder(createFoldersResult_resultHandler, someFaultHandler)
        token.addResponder(responder);
    }
    

    another option would be set up the result handler for createFolders directly in the mxml, so your foldersservice:FoldersService would be:

    <foldersservice:FoldersService id="foldersService"
        fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
        showBusyCursor="true">
        <mx:method name="createFolders" result="createFoldersResult_resultHandler(event)"/>
    </foldersservice:FoldersService>
    

    then you don’t need createFoldersFunction, you can call foldersService.createFolders directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.