how to navigate to an state of another mxml component on clicking a button

sandeep_manne
sandeep_manne used Ask the Experts™
on
Hi,
I have requirement in Flex3 builder
when I click a button in mxml component I need to get  into  a particular state  of an another mxml component How can I do this in "click" function  of button.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
If the state you are talking about is simply a set of public variables that you want returned, you would just call and maybe store a copy of these variables into the current mxml.

What exactly is the state you are trying to get? Which components? and Why?

If you can answer these I should be able to give a clearer answer for you.

Commented:
"when I click a button in mxml component (component A) I need to get  into  a particular state  of an another mxml component (component B)"

Are you talking about GUI / layout states?
Are A & B of the same class?

If they're not, I don't see much point trying to apply the layout state of one type of component to a different type of component.

Author

Commented:
in response to mplord,
hi
yah I am talking about GUI / layout states
and ur assumption is absolutly right.can u provide me with solution.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Commented:
What have you tried so far, or are you starting from scratch?
If you have an example you're working with it might make it easier to make suggestions.

Author

Commented:
hi my  scenario is
I had 'add' state in mxml component-A I want that state to be displayed when I click a button in the mxml component-B
for this
I called   in the click" Application.application.mxmlcomponent A.currentState= 'add' "
but this is just changing the state in mxmlcomponent A ,
I want the state to be displayed on cliking the buttonin mxmlcomponentB.

Do I need to call some popup for this?
Commented:
So to confirm, you've defined a state 'add' for component A.
When you click a button (in component B) you want the 'add' state defined for component A to be applied to component B?

States can be defined for a single component class or heirarchy of child objects, and depending on how you've defined state 'add' for component A you're not necessarily going to be able to just apply that state to component B, unless (with a few exceptions) component A & B are of the same class and have the same child heirarchy (where state touches these).

I would probably:
Replace component A + B with a new component C holding the 'add' state definition and allowing for any differences in child control hierarchy (such that state 'add' doesn't try to manipulate controls that may or may not exist in either instance of the C component).
Then both instances of the C component have the same definition of the 'add' state, and you can use both a(of type C).currentState = 'add' or b(of type C).currentState = 'add' independently (but you've only defined the 'add' state once for component C).

By the way long call chains such as 'Application.application.mxmlcomponent A.currentState= 'add' "' are not recommended as you're making your component reuse inflexible and dependent on layout - do some research on events / event listeners and bubbling.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial