5 Replies Latest reply on Oct 17, 2007 1:59 PM by ntsiii

    Call something like a createComplete when viewStack change.

    thiagoaos
      I have a viewStack and between this viewStack i have 3 components like the code below.
      In <telas:Box> i call init() on createComplete, but when i change the model.viewAmbiente to change the viewStack to another screen and come back to a <telas:Box>, the createComplete isn't called again.

      how do i do to call the init function always when a change model.viewAmbiente to 1 (telas:box)?


      <mx:ViewStack x="0" y="40"
      id="viewstack_ambiente"
      width="100%"
      height="100%"
      selectedIndex="{model.viewAmbiente}">

      <mx:Canvas label="Ambiente" width="100%" height="100%">
      </mx:Canvas>

      <mx:Canvas label="Box" width="100%" height="100%">
      <telas:Box id="tela_box" x="0" y="0" width="100%" height="100%"/>
      </mx:Canvas>

      <mx:Canvas label="Caixa" width="100%" height="100%">
      <telas:Caixa id="tela_box" x="0" y="0" width="100%" height="100%"/>
      </mx:Canvas>


      </mx:ViewStack>

      I actually do this

      i put this function and a added in telas:box show="init()" and added viewstate change="activateState();" , but this is very ugly.

      private function activateState():void {
      if(view_stack_principal.selectedIndex == 2) {
      if(tela_venda.initialized) {
      tela_venda.setVisible(false);
      tela_venda.setVisible(true);

      }
      }
      }

      thx,
      Thiago