Salve a tutti.
Sto cercando di creare un applicazione web in flex collegata ad un database tramite php.
Il tutto è strutturato così più o meno:
-Applicazione principale-
codice:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" 
			   xmlns:components="components.*" 
			   minWidth="760" minHeight="560">
	<fx:Declarations>
		<components:Com_Db_Users id="com_db_users"/>
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			protected function start():void
			{
				txtarea_debug.text = com_db_users.getId();
			}
		]]>
	</fx:Script>
	<s:states>
		<s:State name="test"/>
	</s:states>
	<s:TextArea id="txtarea_debug" x="10" y="10" width="365" height="600"/>
	<s:Button id="btn_start" x="419" y="513" label="Load" click="start()"/>
</s:Application>
-Componente-
codice:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
		 xmlns:s="library://ns.adobe.com/flex/spark" 
		 xmlns:mx="library://ns.adobe.com/flex/mx" width="760" height="560">
	<fx:Declarations>
		<s:HTTPService id="userRequest" url="database/test.php" useProxy="false" method="POST"
					   result="resultHandler(event)" fault="faultHandler(event)"/>
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			// component core
			import mx.controls.Alert;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			
			// db
			[Bindable] protected var id:int = 0;
			[Bindable] protected var get_id:Boolean = false;
			
			private function faultHandler(fe:FaultEvent):void
			{
				Alert.show(fe.fault.message);
			}
			
			private function resultHandler(re:ResultEvent):void
			{
				//Alert.show(String(re.result.query));
				if (get_id)
				{
					get_id = false;
					
					if (re.result.query == "loaded")
					{
						id = re.result.id;
					}
					else if (re.result.query == "empty")
					{
						id = 0;
					}
				}
			}
			
			public function getId():Boolean
			{
				var tmp_nick:String = val;
				
				get_id = true;
				
				var params:Object = {};
				params.get_id = get_id;
				
				userRequest.send(params);
				
				if (id > 0)
					return true;
				else
					return false;
			}
		]]>
	</fx:Script>
</s:Group>
Il problema è che vorrei che la funzione getId() presente nel componente ritornasse il valore in base al dato letto dal file php in maniera da passarlo al modulo/componente/applicazione che lo ha richiesto. Questo però non accadrà mai perchè la parte
codice:
	if (id > 0)
		return true;
	else
		return false;
viene letta prima che il dato venga letto dal file php. Come posso fare? Non c'è un modo per dirgli di aspettare finchè il dato non è stato caricato?