Discussion Board

ask questions, discuss topics, solve problems

This is a public Discussion Area  publicRSS

Thread

    • stage.loaderInfo.parameters funciona no...
      Thread posted Jun 17 by c.c.o
      483 Views, 5 Comments
      Title:
      stage.loaderInfo.parameters funciona no init()?
      Content:

      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?

    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