4 Replies Latest reply on Dec 8, 2010 2:06 AM by giba_f

    Problem involving Effect...

    giba_f

      Hello everyone!

      Well, to expose the problem I'm having, and explain, I am putting a summary of my code below.

      The problem I'm having is related to the effect that plays when clicked on the menu. This problem only happens the first time you run the Rotina010.mxml. The second time before running out. The problem that happens is that, when executed Rotina010 the Mnu1.visible = false, Mnu2 moves to the center of the screen, but when you run Rotina010 in the background, the Mnu2, back the position he was invisible and keeps Mnu1 .

      I repeat: when I run the Rotina010 the second time this problem occurs not only in the first execution, and tried, even with alerts and not found in my source where is the problem.

      I thank those who help me pouder: THANK YOU!

      Gilberto

      summarized the following code:

       

       

      1) MAIN.MXML

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application layout="absolute" horizontalAlign="center" verticalAlign="center"  creationComplete="StartApp()">

          <mx:ApplicationControlBar id="Header" top="0" width="100%" height="105"  >
          </mx:ApplicationControlBar>

          <mx:Canvas id="PlaceMenu" width="100%" height="35" left="0" top="108" >
              <mx:MenuBar id="menuBar" labelField="@label" width="100%" height="100%"
                  dataProvider="{OpcMnuBar}" click="ExecOpcMnu(event);"  itemClick="ExecOpcItemMnu(event);" >
              </mx:MenuBar>
          </mx:Canvas>

          <mx:WipeRight id="Mnu1Show" duration="1000"/>
          <mx:WipeLeft  id="Mnu1Hide" duration="1000"/>
         
          <mx:HBox top="147" width="100%" height="100%"  horizontalAlign="center" verticalAlign="middle" horizontalCenter="0">
         
              <mx:Panel x="10" y="20" width="270" height="375" layout="absolute" id="Mnu1" showEffect="{Mnu1Show}" hideEffect="{Mnu1Hide}"  >
              </mx:Panel>
             
              <mx:Panel x="288" y="20" width="640" height="375" layout="absolute" id="Mnu2" >
              </mx:Panel>

          </mx:HBox>

          <mx:Script>
              <![CDATA[
             
                  [Bindable] public  var OpcMnuBar:XMLListCollection;

                  private var menuUsuXML:XMLList =
                      <>
                          <menuitem label="Home"                          data="Mnu1" />
                          <menuitem label="Organização"                   data="Mnu2" >
                              <menuitem label="Cadastro"                  data="Mnu2_1" type="radio" />
                              <menuitem label="Solicitar"                 data="Mnu2_2" type="radio" />
                              <menuitem label="Consultar"                 data="Mnu2_3" type="radio" />
                          </menuitem>
                          <menuitem label="Entrar em Contato"             data="Mnu3" >
                              <menuitem label="Mandar e-Mail"             data="Mnu3_1" type="radio" />
                              <menuitem label="Criar Depoimento"          data="Mnu3_2" type="radio" />
                          </menuitem>
                          <menuitem label="FAQ's"                         data="Mnu4"   >
                              <menuitem label="Perguntas mais Frequentes" data="Mnu4_1" type="radio" />
                              <menuitem label="Depoimentos"               data="Mnu4_2" type="radio" />
                          </menuitem>
                      </>;

       

                  private function StartApp():void{
                      OpcMnuBar  = new XMLListCollection(menuUsuXML);
                  }


                  private function ExecOpcMnu(event:MouseEvent):void  {
                      if ( MenuBarItem(event.target).data.@data == "Mnu1") {
                      }
                      else if ( MenuBarItem(event.target).data.@data == "Mnu2") {
                      }
                      else if ( MenuBarItem(event.target).data.@data == "Mnu3") {
                      }
                      else if ( MenuBarItem(event.target).data.@data == "Mnu4") {
                      }
                      if ( !Mnu1.visible )
                          EfeitoMnus();
                  }

                  private function ExecOpcItemMnu(event:MenuEvent):void  {
                      if (
      event.item.@data == "Mnu2_1") {
                          ExecRotina010();
                      }
                      else if (
      event.item.@data == "Mnu2_2") {
                      }
                      else if (
      event.item.@data == "Mnu2_3") {
                      }
                      else if (
      event.item.@data == "Mnu3_1") {
                      }
                      else if (
      event.item.@data == "Mnu3_2") {
                      }
                      else if (
      event.item.@data == "Mnu4_1") {
                      }
                      else if (
      event.item.@data == "Mnu4_2") {
                      }
                      EfeitoMnus();
                  }

                  private function EfeitoMnus():void {
                      var nTempo:int = 1000;
                      var mover:Move = new Move();
                      mover.target = Mnu2;
                      if ( !Mnu1.visible ) {
                          nTempo = 700;
                          mover.xTo = nXTelaMnu2 ;
                          mover.easingFunction = Bounce.easeIn;
                      }
                      else {
                          mover.xTo = ( nLarWin - Mnu2.width ) / 2 ;
                          mover.easingFunction = Bounce.easeOut;
                      }
                      mover.duration = nTempo;
                      mover.play();
                      Mnu1.visible = !Mnu1.visible;
                  }

                  private function ExecRotina010():void {
                      var PopUp_ExecRot010:Rotina010 = new Rotina010();
                      PopUpManager.addPopUp(PopUp_ExecRot010,this,true);
                      //PopUpManager.centerPopUp(PopUp_ExecRot010);
                  }

              ]]>
          </mx:Script>

      </mx:Application>

       

      2) Rotina010.MXML

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx="
      http://www.adobe.com/2006/mxml" layout="absolute" width="666" height="398"
            creationComplete="Rotina010Start()" >

          <mx:VBox width="624" height="316" horizontalCenter="-1" verticalCenter="1" horizontalAlign="center">
              <mx:Canvas label="Tela9" width="100%" height="250"  >
             
              </mx:Canvas>
              <mx:HBox width="100%" height="42" horizontalAlign="center" verticalAlign="middle" y="430">
                  <mx:Button x="165" width="100"  id="ButConfRot010" label="Confirmar" labelPlacement="right" icon="@Embed(source='Recursos/ConfirmarP.png')" click="Rotina010Save()"  />
                  <mx:Button x="90"  width="100"  id="ButCancRot010" label="Cancelar"  labelPlacement="right" icon="@Embed(source='Recursos/CancelarP.png')"  click="Rotina010Quit()"  />
              </mx:HBox>

          </mx:VBox>


          <mx:Script>
              <![CDATA[

                  private function Rotina010Start():void {
                      var nAux1:int = parentDocument.Mnu2.width;
                      var nAux2:int = parentDocument.Mnu2.height;
                      var nAux3:int = parentDocument.Mnu2.x;
                      var nAux4:int = parentDocument.Mnu2.y + parentDocument.Header.height + parentDocument.PlaceMenu.height + 10;
                      var nAux5:int = parentDocument.nLarWin;
                      var nAux6:int = parentDocument.nAltWin;
                      EfeitoAbreJanela(this,nAux1,nAux2,nAux3,nAux4,nAux5,nAux6);
                  }

                  public function EfeitoAbreJanela(janela:TitleWindow,Aux1:int,Aux2:int,Aux3:int,Aux4:int,Aux5:int,Aux6:int ):void {
                      var efeito:Parallel = new Parallel();
                      var mover:Move = new Move();
                      var redim:Resize = new Resize();

                      efeito.target = janela;
                      var nLarJan:int = janela.width;
                      var nAltJan:int = janela.height

                      janela.width  = Aux1;
                      janela.height = Aux2;
                      janela.x = Aux3;
                      janela.y = Aux4;
                      redim.widthTo  = nLarJan;
                      redim.heightTo = nAltJan;
                      mover.xTo = ( Aux5 - nLarJan ) / 2 ;
                      mover.yTo = ( Aux6 - nAltJan ) / 2 ;
                      efeito.addChild(redim);
                      efeito.addChild(mover);
                      efeito.duration = 500;
                      efeito.play();
                  }

                  private function Rotina010Save():void {
                      Rotina010Quit();
                  }

                  private function Rotina010Quit():void {
                      PopUpManager.removePopUp(this);
                  }

              ]]>
          </mx:Script>

      </mx:TitleWindow>