This content has been marked as final. Show 4 replies
I e-wrote my problem in a clearer way to see if I can get any help...
I'm creating a few simple visual components with back and next buttons and I want to use the viewstack, particularly selectedindex, which is what someone recommended, to cycle though them in the order I like.
I can access the button id from the child inside the viewstack, for example:
But how do I tell nextButton, which is the button id in the component to go to another component?
You could try something like this:
<mx:Canvas label="First Child">
.....<mx:Button label="Next" click="stack.selectedIndex=1" />
.....<mx:Button label="Back" click="stack.selectedIndex=0"/>
.....<mx:Button label="Next" click="stack.selectedIndex=2"/>
That's not a very programmatic way to it, but it gets the job done. What I would do is put the Next and Back buttons outside of the ViewStack and then you do it a bit more programmatically:
if( stack.selectedIndex+1 < stack.numChildren ) stack.selectedIndex = stack.selectedIndex +1;
Thank you very much for the reply. It did help.
What if I wanted o have an skip button in just a couple of he components hat I wanted to help me skip a step that maybe one or two screens ahead?
OK. Let's say this is one child of the ViewStack:
<mx:Canvas label="Some Child" id="someChild" >
....<mx:Button label="Skip 2">
............var index:int = stack.getChildIndex(someChild);
............index += 2;
............// make sure the index is not going to be out of bounds
............if( index >= stack.numChildren ) index -= 2;
............stack.selectedIndex = index;