Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-23-2009, 07:29 AM   PM User | #1
victor8080
New to the CF scene

 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
victor8080 is an unknown quantity at this point
Unhappy Please help me with XMLList upgrade...

Hi all, I need Your help with something in my code....

Here is my code:
******************************************
Code:
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;

public class Controler{

[Bindable]
public var lista:XMLList;

public function consult():XMLList{
     var service:HTTPService = new HTTPService();
     service.url="http://localhost/Something.php";
     service.useProxy=false;
     service.resultFormat="e4x";
     service.addEventListener(ResultEvent.RESULT, met);
     service.send();	
     Alert.show(lista.length()); 	//prints 0 =S
     return this.lista;
}

     private function met(event:ResultEvent):void{
     lista = event.result.option as XMLList;
     Alert.show(this.lista.length()); //prints the real value, actually: 6	
     }
}
**********************************************

The thing is: I got data from a database, working fine, in the function met I got the data and the alert.show shows the length of the var lista:XMLList wich is [Bindable] but when i used again in the consult function I got a big 0 (zero) and I dont know what the problem is, some help please...

well I know the problem is that the var lista:XMLList dont make the upgrade but I dont know why...
victor8080 is offline   Reply With Quote
Old 11-28-2009, 04:49 PM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
It seems like you're running into a race condition. Flex is asynchronous -- it will continue to execute your function while the event fires. So, don't handle the list in your consult() function. Have ] your met() function trigger the next step for your logic.
Inigoesdr is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:09 AM.


Advertisement
Log in to turn off these ads.