Reputation: 1
I have created a swf project with flex and i have some checkboxes on it and whenever the checkbox seleced it will call the checkbox handler:
function checkBoxHandler() {
//call resultHandling
var obj:myObjectType = new myObjectType();
resultHandling(obj)
}
function resultHandling(myObject:myObjectType) {
//implementation code to send a request to server side
}
is it possible to make the "resultHandling(...)" to be a synchronized function? So there will be a que whenever we make a call to that function especially when there are multiple function calls
Upvotes: 0
Views: 1069
Reputation: 131
Most Flash I/O is asynchronous and there is no way to change that. Consider using inline nested handlers
function checkBoxHandler() {
var obj:myObjectType = new myObjectType();
var resultHandling:Function = function():void {
//you can just reference obj here
var resultHandling2:Function = function():void {
};
};
//implementation code to send a request to server side
}
or use a task scheduler such as the Parsley Command Framework.
Upvotes: 0
Reputation: 2365
As Flex is Flash the limitations to Flash apply to Flex too. One of these is (Actually in newer Flash versions this no longer is 100% valid) that Flash has only one thread. This thread does everything from updating/drawing the ui, processing the application logic, handling IO, etc. Therefore a synchronous call would be a blocking call and in Client-Server communication this block can be quite long. Therefore Flash doesn't support blocking calls to a server and you won't be able to find a solution for this ... unfortunately.
But be assured, actually you will start creating more robust applications this way. I have noticed creating more and more asynchronous solutions even in places I could use synchronous calls :-)
Upvotes: 2
Reputation: 61
you can create an arraycollection and store all your myObjectType objects in it. Then do something like-
var arr:ArrayCollection = new ArrayCollection();
function checkBoxHandler() {
//call resultHandling
var obj:myObjectType = new myObjectType();
arr.addItem(obj);
}
function resultHandling(myObject:myObjectType) {
//implementation code to send a request to server side
}
function webServiceResponseHandler(){
//receive the response from server
sendWSRequest();
}
function sendWSRequest(){
if(arr.length > 0)
{
resultHandling(arr.getItemAt(0));
arr.removeItemAt(0);
}
}
Upvotes: 0