2 Replies Latest reply on Dec 3, 2007 5:28 AM by buabco

    Controling Displayed item on ViewStack

    buabco Level 1

      I've been working on a viewStack that has multiple containers. Each container is of some extended class that does stuff. Some of the stuff they do is to display a progress window while doing whatever they do.

      So the thing is that if I call the function that display the progress window, I only want it to popUp the progress window if it is the displayed item in the viewStack, if not I want it to do the process silently on the background.

      To do this I've tryed checking the visible parameter of the container, but it's always visible, I tried with the alpha parameter but it's always 1, and I tried with the stage parameter, but the item is never removed from stage, so I'm kind of puzzled on how the viewStack hides the content that's not currently visible.

      Is there anyone that would help me with this?
        • 1. Re: Controling Displayed item on ViewStack
          Garyl Woolworth
          Hey buabco,

          The property you want to check for on a Viewstack is it's selectedChild, you could also check to see an index matches but I always prefer to match things by id's / names. Here's some sample code to help you on your way.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:container="*" layout="absolute">
          <mx:Button x="10" y="10" label="Button" click="viewstack.selectedChild=container1"/>
          <mx:Button x="83" y="10" label="Button" click="viewstack.selectedChild=container2"/>
          <mx:Button x="156" y="10" label="Button" click="viewstack.selectedChild=container3"/>

          <mx:ViewStack id="viewstack" left="10" right="10" top="40" bottom="10">
          <container:Container id="container1" width="100%" height="100%" />
          <container:Container id="container2" width="100%" height="100%" />
          <container:Container id="container3" width="100%" height="100%" />

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">

          import mx.controls.Alert;

          private function checkStack():void {
          if(parentDocument.viewstack.selectedChild == parentDocument[this.id]){
          Alert.show("If statement passed, show progress loading stuff. The Viewstacks selected child is" + parentDocument.viewstack.selectedChild);

          <mx:Button label="This is {this.id}" click="checkStack()"/>

          Basically all your doing is inside of your container you need to check to see the id's match up to the viewstacks selectedChild, if they don't match up then run your code silently.
          • 2. Re: Controling Displayed item on ViewStack
            buabco Level 1

            Thanks for your reply I think I can use it, but I was looking more into a parameter within the item itself, since I needed a more general solution that can be used in a viewStack or for that matter any other container.