Oi Pessoal,
nao estou conseguindo carregar um parametro no meu metodo init chamando stage.loaderInfo.parameters.xx. Mas quando eu chamo isso de outro método,
acionado por um botao, por exemplo, consigo carregar.
Alguem pode ajudar?
Be the first to rate this Post
|
Joa o código que facilita!
=]
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="600" height="400" showCloseButton="true" creationComplete="init()" >
<mx:Form width="100%" height="100%" defaultButton="{btSet}"> <mx:Text text="{identif}" /> </mx:Form> <mx:ControlBar horizontalAlign="center"> <mx:Button label="Set" id="btSet" click="setValues()" textAlign="center"/> </mx:ControlBar> <mx:RemoteObject id="xxService" fault="onFault(event)" destination="xxService"> <mx:method name="getProperty" result="onResult(event)" fault="onFault(event)" /> </mx:RemoteObject> <mx:Script> <![CDATA[ import com.art.JavaFlex.view.entity.Properties; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.controls.Alert; [Bindable] private var st:Properties; [Bindable] public var identif:String; private function init():void { identif = stage.loaderInfo.parameters.ident; xxService.getProperty(stage.loaderInfo.parameters.ident); } public function setValues():void { identif = stage.loaderInfo.parameters.ident; xxService.getProperty(stage.loaderInfo.parameters.ident); } public function onFault(event:FaultEvent):void { Alert.show(event.fault.message); } private function onResult(event:ResultEvent):void{ st = event.result ? event.result as Properties : new Properties(); } ]]> </mx:Script> </mx:TitleWindow>
Quando acionado pelo botao set está ok.. mas no init() nao acontece nada.
Não está sendo chamado o init() ? Você testou com um trace() ?
Tenta por no creationComplete da Application
Abraços!
Oi Thiago,
o método init() está sendo chamado pois coloquei um creationComplete no TitleWindow.
Se eu substituir:
private function init():void { xxService.getProperty(stage.loaderInfo.parameters.ident); }
por:
private function init():void { Alert.show(""oi"); }
O alert é mostrado!
Copyright © 2009 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-08-2008).
Powered by HiveLive
Comments
Joa o código que facilita!
=]
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" width="600" height="400" showCloseButton="true"
creationComplete="init()" >
<mx:Form width="100%" height="100%" defaultButton="{btSet}">
<mx:Text text="{identif}" />
</mx:Form>
<mx:ControlBar horizontalAlign="center">
<mx:Button label="Set" id="btSet" click="setValues()" textAlign="center"/>
</mx:ControlBar>
<mx:RemoteObject id="xxService" fault="onFault(event)" destination="xxService">
<mx:method name="getProperty" result="onResult(event)" fault="onFault(event)" />
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import com.art.JavaFlex.view.entity.Properties;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
[Bindable]
private var st:Properties;
[Bindable]
public var identif:String;
private function init():void {
identif = stage.loaderInfo.parameters.ident;
xxService.getProperty(stage.loaderInfo.parameters.ident);
}
public function setValues():void {
identif = stage.loaderInfo.parameters.ident;
xxService.getProperty(stage.loaderInfo.parameters.ident);
}
public function onFault(event:FaultEvent):void {
Alert.show(event.fault.message);
}
private function onResult(event:ResultEvent):void{
st = event.result ? event.result as Properties : new Properties();
}
]]>
</mx:Script>
</mx:TitleWindow>
Quando acionado pelo botao set está ok.. mas no init() nao acontece nada.
Não está sendo chamado o init() ? Você testou com um trace() ?
Tenta por no creationComplete da Application
Abraços!
Oi Thiago,
o método init() está sendo chamado pois coloquei um creationComplete no TitleWindow.
Se eu substituir:
private function init():void {
xxService.getProperty(stage.loaderInfo.parameters.ident);
}
por:
private function init():void {
Alert.show(""oi");
}
O alert é mostrado!
Tenta por no creationComplete da Application