PDA

View Full Version : help regarding ViewStates CurrentStateChange in flex


dhina.techno
09-26-2007, 05:41 AM
Hi,

I am a newbie in flex 2.0 and action script 3.0.

When i press the button, i need two things to happen.

one is change my view state and other one is calling a inline actionscript function.

<mx:Button x="84" y="192" label="Button" id="Button1" click="getit()"/>

(where getit() is my inline function in actionscript).

i know how to create a new state and so on. But, i need to know, how can i make these two things happen in a single button click. I heard something called CurrentStateChange which handles this functionality. Kindly let me know how to use this CurrentStateChange, or if you have anything to say!

Your help is highly appreciated!

thanks,

Dhina

flexy
09-27-2007, 03:13 PM
I think what you need to be doing is creating a function that handles these two tasks for you, once your button is clicked.


<mx:Script>
<![CDATA[

private function onButtonClick( e:Event, n:int ) :void
{
// update viewstack
myViewStack.selectedIndex = n;
// call get it function
getit();
}

]]>
</mx:Script>


<mx:Button x="84" y="192" label="Button" id="Button1" click="onButtonClick(event, 2)"/>

dhina.techno
09-28-2007, 06:37 AM
Hi,
Thanks very much for your reply. I got the solution.
<mx:Button x="84" y="192" label="Button" id="Button1" click="currentState='GridState'; getit();"/>

I think, your code will also solve my problem..
hurray,, i've got 2 solutions for my problem..
thanks very much once again..

thanks,
Dhina