Reputation: 149
I have a viewstack in my main application
public var currentStep:int;
<mx:ViewStack id="step" selectedIndex="{currentStep}">
<comp:Choosecar id="choosecar" />
<comp:Configcar id="configcar" />
</mx>
I'm using a drag and drop inside to choosecar component, so I want to change the 'currentstep' - which is a variable of the main application - with +1 so the viewstack changes to the second component 'configcar'. The only solution I found is calling a component from the main application, I need it the other way around but I can't find it.
Can anyone help me out please?
Thanks!
Upvotes: 0
Views: 155
Reputation: 5978
In your component Choosecar, you may dispatch an event, let's say "switchToConfig". I assumed you meant dropdown instead of "drag and drop".
<mx:ComboBox change="dispatcheEvent(new Event('switchToConfig'))" />
At the beginning of your component's MXML you have to declare the dispatched event:
[Event(name="switchToConfig", type="flash.events.Event")]
Now you will be able to catch the event in the top application
[Bindable] public var currentStep:int;
<mx:ViewStack id="step" selectedIndex="{currentStep}">
<comp:Choosecar id="choosecar" switchToConfig="currentStep = 1" />
<comp:Configcar id="configcar" />
</mx>
Cheers
Upvotes: 3