Link to home
Start Free TrialLog in
Avatar of chuckbeats
chuckbeats

asked on

Flash Remoting and Actionscript

The following code, according to the debug window, connects successfully and gets an array back from amfphp. However, the responder onResult does not load the array into the combobox. This code is a simplified form of coed in O'reilley's Flash Remoting: The Definitive Guide with a php "northwind" database. The amfphp service browser also works fine. Basically, the only thing in my flash movie is a combobox w/ the instance name of countries_cb... I added the last line at the end to make sure I could write a value/label pair to the combobox...and it works...so for some reason the responder is not getting invoked...The code is below.

Obviously I'm new and this should be simple...I just am not sure how to make sure actionscript is invoking the onResult responder...and I've searched until my heart's content...thanks in advance...

import mx.remoting.Service;

   import mx.rpc.RelayResponder;
   import mx.remoting.PendingCall;
   import mx.remoting.debug.NetDebug;
   import mx.services.Log;

//-------------------------------------------------------------------
// Define the URLs
//-------------------------------------------------------------------
gatewayURL = "http://dfwhomesales.com/flashservices/gateway.php";
serviceURL = "CustomersAdmin";

countryResponder = new Object( );
countryResponder.onResult = function (countries_rs) {
  var max = countries_rs.getLength( );

  countries_cb.setEnabled(true);
  countries_cb.addItem("All", 0);

  for (var i=0; i<max; ++i) {
    countries_cb.addItem(countries_rs.getItemAt(i).Country, i+1);
  }
  countries_cb.setSelectedIndex(0);

 
};

//-------------------------------------------------------------------
// Create the gateway and service objects
//-------------------------------------------------------------------

this.service = new Service(this.gatewayURL, new Log(), "CustomersAdmin", null, null);
service.getCountries(countryResponder);
countries_cb.addItem("All", 0);
Avatar of chuckbeats
chuckbeats

ASKER

Also, I'm not sure about the countries_cb.setEnabled(true);...so I have tried it w/out this line as well. If I remove the last line in the code..the "all" never gets put into the combobox from the responder function...so if there is a problem w. the array logic, I can deal with that when it comes...thanks
Avatar of Aneesh Chopra
Hi,

seems like issue in the following code:
----------------
var max = countries_rs.getLength( );
--------------

if "countries_rs" is an array, then you should try this:
--------------
var max = countries_rs.length;
----------

Rgds
Aneesh
or,

you should first try tracing out to confirm that you are getting data in dataset object
----------
trace(countries_rs.getLength( ));
-----------
countryResponder.onResult = function(countries_rs)

where is countries_rs object

anji
Tried all this...still nothing...I have also tried for the OnResult function just to add a line to the combobox...

If I take ou the function () .. then a one line works like below...

countryResponder.onResult =countries_cb.addItem("I'm working!!", 1);

but if I try to add that to a function () is doesn't work...something is wrong with the code and the function definition.

I have determined the responder call is working...but still can't seem to get it to work invoking a function.
Anycode help would work...even if it doesn't have to do with the results...

How do I get a function constructed and working??
i.e.

countryResponder.onResult = function () {
countries_cb.additem("I'm working!!",1);
};

does not work...WHY?
try this:
----------
myfunction = function () {
    countries_cb.additem("I'm working!!",1);
    countries_cb.additem("still working!!",2);
};

//
countryResponder.onResult = myfunction;
-------------

Rgds
Aneesh

still nothing... :-(
are you using above code in a AS 2.0 class or on FLA frame....?
FLA frame.
can you provide the sample source files, it will help it to resolve it faster...

you may also send it to mail...  (mail is in profile)


I assure that i will provide the solution and provided source will be used only to provide assitance to your problem and will be deleted completely later on...

Rgds
Aneesh


ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you...thank you...thank you...This is by far the best experts-exchange encounter I have ever had...BRAVO...I just wish I could give you higher than an A and about 50000000000000000 points!!!
you are welcome :)