0 Replies Latest reply on Sep 14, 2006 1:53 AM by avanthika

    how to show random showEffect and hideEffect when viewStack changes.

    avanthika
      Hi all ,

      i am using viewStack to show multiple pages.

      when user navigates between pages i want to show the following effects randomly
      WipeUp, WipeDown, WipeRight, WipeLeft , Dissolve etc.. for showEffect and hideEffect for each page,.

      To do this, I have taken an array to store Id of all the effects (WipeUp, WipeDown .....).
      when viewstack changes, i am assigning random value from this array to an object which is binded to the viewstack page hideEffect and showEffect.
      But this is not working, The initial value which i have assingned to object that value only it is taking . It is not changing randomly

      Anyone help me how to do this.

      I have tried in the following way.

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >
      <mx:Script >

      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.controls.Alert;

      private var hideEffectArr:Array=new Array(["myWD"],["myDsolve"],["myWU"],["myWL"],["irisOut"],["myWR"]);
      private var showEffectArr:Array=new Array(["myWU"],["myDsolve"],["myWD"],["myWR"],["irisIn"],["myWL"]);

      [Bindable]
      private var randomEffectValue:Object = {hideValue:"myWD",showValue:"myWU"};

      private function randomEffect():void{

      var r1:int=Math.round(Math.random()*10)

      if(r1<6){
      randomEffectValue.showValue=showEffectArr[r1];
      randomEffectValue.hideValue=hideEffectArr[r1];
      } else{
      randomEffectValue.showValue=showEffectArr[0];
      randomEffectValue.hideValue=hideEffectArr[0];
      }
      }


      ]]>

      </mx:Script>

      <mx:WipeUp id="myWU" duration="1000"/>
      <mx:WipeDown id="myWD" duration="1000"/>
      <mx:WipeRight id="myWR" duration="2000"/>
      <mx:WipeLeft id="myWL" duration="2000"/>
      <mx:Dissolve id="myDsolve" duration="2000"/>
      <mx:Iris id="irisOut" duration="1000" showTarget="true"/>
      <mx:Iris id="irisIn" duration="1000" showTarget="false"/>


      <mx:VBox >
      <mx:LinkBar dataProvider="{myViewStack}" borderStyle="solid"
      backgroundColor="#EEEEFF" />

      <mx:ViewStack id="myViewStack" borderStyle="solid" width="100%" creationCompleteEffect="{myWR}" change="randomEffect()">

      <mx:Canvas id=" chrysler " label=" Chrysler "
      hideEffect="{randomEffectValue.hideValue}" showEffect="{randomEffectValue.showValue}">
      <mx:VBox>


      <mx:Label text="Chrysler cars"/>
      <mx:Image source="@Embed(source='assets/town.png')" />
      </mx:VBox>
      </mx:Canvas>
      <mx:Canvas id="hondaInfo" label="Honda Info"
      hideEffect="{randomEffectValue.hideValue}" showEffect="{randomEffectValue.showValue}">


      <mx:VBox>
      <mx:Label text=" Honda Info"/>
      <mx:Image source="@Embed(source='assets/element.png')" />
      </mx:VBox>
      </mx:Canvas>
      <mx:Canvas id="fordInfo" label="Ford Info"
      hideEffect="{randomEffectValue.hideValue}" showEffect="{randomEffectValue.showValue}">
      <mx:VBox>
      <mx:Label text="Ford Info"/>
      <mx:Image source="@Embed(source='assets/fordGT.png')" />
      </mx:VBox>
      </mx:Canvas>
      </mx:ViewStack>
      </mx:VBox>
      </mx:Application>


      Thanks in advance

      Regards
      Avanthika