Hey Luke,

Luke Vanderfluit wrote:
> 
> I have a component that displays a form (currently in 
> selectedIndex 0), from this component I want the click to send me 
> to ViewStack.selectedIndex 1.
> 
> Is there something like parent.selectedIndex?
> Access the ViewStack (that contains the component as one of its 
> children) directly from the component doesnt work.
> 
> <mx:Button label="Button" click="myVS.selectedIndex='1';"/>
> 
> How would I do that?

If i understand correctly, off the top of my head you could do something 
like:


//inside parent containing VS.
addEventListener("NextEvent", handleNext);

function handleNext(e:Event):void{
  var c:MyFormComponent = e.currentTarget as MyFormComponent;
  next(c);
}

function next(c:MyFormComponent){
    //something.
    myVs.selectedIndex < maxIndex ? myVs.selectedIndex++ : null ;
}


//inside child component within vs.
function handleClick(e:Event):void{
   if (e.currentTarget == next)
        dispatchEvent(new Event("NextEvent", true));
   else
        dispatchEvent(new Event("PreviousEvent", true));

}
<mx:Button id="next" label="Next" click="handleClick(event);"/>

<mx:Button id="back" label="Back" click="handleClick(event);"/>


HTH.
cheers,
  - shaun






Reply via email to