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(tr ue);
countries_cb.addItem("All" , 0);
for (var i=0; i<max; ++i) {
countries_cb.addItem(count ries_rs.ge tItemAt(i) .Country, i+1);
}
countries_cb.setSelectedIn dex(0);
};
//------------------------ ---------- ---------- ---------- ---------- ---
// Create the gateway and service objects
//------------------------ ---------- ---------- ---------- ---------- ---
this.service = new Service(this.gatewayURL, new Log(), "CustomersAdmin", null, null);
service.getCountries(count ryResponde r);
countries_cb.addItem("All" , 0);
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(tr
countries_cb.addItem("All"
for (var i=0; i<max; ++i) {
countries_cb.addItem(count
}
countries_cb.setSelectedIn
};
//------------------------
// Create the gateway and service objects
//------------------------
this.service = new Service(this.gatewayURL, new Log(), "CustomersAdmin", null, null);
service.getCountries(count
countries_cb.addItem("All"
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
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.getLeng th( ));
-----------
you should first try tracing out to confirm that you are getting data in dataset object
----------
trace(countries_rs.getLeng
-----------
countryResponder.onResult = function(countries_rs)
where is countries_rs object
anji
where is countries_rs object
anji
ASKER
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?
If I take ou the function () .. then a one line works like below...
countryResponder.onResult =countries_cb.addItem("I'm
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("stil l working!!",2);
};
//
countryResponder.onResult = myfunction;
-------------
Rgds
Aneesh
----------
myfunction = function () {
countries_cb.additem("I'm working!!",1);
countries_cb.additem("stil
};
//
countryResponder.onResult = myfunction;
-------------
Rgds
Aneesh
ASKER
still nothing... :-(
are you using above code in a AS 2.0 class or on FLA frame....?
ASKER
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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 :)
ASKER