Hello, this is probably a very simple question fo most of
you, but I just started learning Flex and have been trying
different things. So any help would be greatly appreciated.

What I’m doing now is creating a few simple visual components
with back and next buttons and I want to use viewstack,
particularly selectedindex, which is what someone recommended, to
cycle though them in the oder I like.

What are the recommended steps to follow to do this?|||
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:

<viewstack>

<comp:component01 nextButton:”"/>

</viewstack>

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:ViewStack id=”stack”>

<mx:Canvas label=”First Child”>

…..<mx:Button label=”Next” click=”stack.selectedIndex=1″
/>

</mx:Canvas>

<mx:Canvas label=”Second”>

…..<mx:Button label=”Back”
click=”stack.selectedIndex=0″/>

…..<mx:Button label=”Next”
click=”stack.selectedIndex=2″/>

</mx:Canvas>



</mx:ViewStack>

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:

<mx:Button label=”Next”>

<mx:click><![CDATA[

if( stack.selectedIndex+1 < stack.numChildren )
stack.selectedIndex = stack.selectedIndex +1;

]]></mx:click>

</mx:Button>

|||
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″>

…….<mx:click><![CDATA[

............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;

.......]]></mx:click>

….</mx:Button>

HTH

Related posts:

  1. ViewStack shows tooltips from wrong view
  2. eventlisteners
  3. Specifying z-index
  4. Label auto size
  5. Order of objects in canvas

Related posts brought to you by Yet Another Related Posts Plugin.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 free icons download Suffusion theme by Sayontan Sinha

Featuring Recent Posts WordPress Widget development by YD