BTW, Timgerr asked essentially the same question early today in the
thread "Flex Compenents, how to make them talk". 

 

If your app is organized like this

 

<Application>

    <ViewStack id="myVS">

        <MyForm/>

        <SecondView id="mySecondView"/>

    </ViewStack>

</Application>

 

then from MyForm's <Script> you could do

 

    Application.application.myVS.selectedIndex = 1;

 

(You can access the Application instance from anywhere as
Application.application.) You could also do

 

    parentDocument.myVS.selectedIndex = 1;

 

However, this isn't good practice; MyForm shouldn't have that much
knowledge about the structure of things outside itself. Instead, put a
method like

 

    public function showSecondView():void

    {

        myVS.selectedChild = mySecondView;

    }

 

in Application's <Script>, and then have MyForm's <Script> call

 

    Application.application.showSecondView();

 

or

 

    parentDocument.showSecondView();

 

In other words, have MyForm request that the Application do something
without specifying how to do it.

 

Or, better yet, learn how to have MyForm send an event to which
Application can respond.

                                                       

Gordon Smith

Adobe Flex SDK Team

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Luke Vanderfluit
Sent: Wednesday, April 16, 2008 7:14 PM
To: [email protected]
Subject: Re: [flexcoders] newbie question

 

Hi Gordon.

Gordon Smith wrote:
>> How do I allow the user to navigate from one page to the next?
> 
> 
> 
> You'd generally use a ViewStack if the pages have little UI in common 
> with each other. Use states if they have a lot in common. You can also

> mix and match, using a ViewStack for part of the screen, etc.
> 
> A ViewStack shows 1 of N of its child views. You change which child it

> displays by setting its selectedChild or selectedIndex property.

Thanks very much for your reply...

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?

Kind regards.
Luke.

> 
> Gordon Smith
> 
> Adobe Flex SDK Team
> 
> 
> 
> ----------------------------------------------------------
> 
> *From:* [email protected]
<mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] 
> *On Behalf Of *Luke Vanderfluit
> *Sent:* Wednesday, April 16, 2008 5:49 PM
> *To:* [email protected] <mailto:flexcoders%40yahoogroups.com>

> *Subject:* [flexcoders] newbie question
> 
> 
> 
> Hi.
> 
> Im relatively new to flex and am writing an application at work
> using flex! Yes!
> 
> I want to get a log in page working in flex.
> Doing this in html/jsp one would create a page, submit the page
> and (if credentials are good) move to the next page.
> 
> In flex, the concept of reloading pages is non-existent, I believe.
> So I know how to connect to a server from a flex client to test
> the user credentials...
> The question is:
> How do I allow the user to navigate from one page to the next?
> (I am currently using states. Is that the way?)
> 
> My submit button will call an actionscript function that will
> test the credentials, but it should also put the user into the
> next step of the application, what is the accepted way of doing this?
> 
> Thanks.
> Kind regards.
> 
> -- 
> Luke Vanderfluit
> Analyst / Web Programmer
> e3Learning.com.au
> 08 8221 6422
> 
> 

-- 
Luke Vanderfluit
Analyst / Web Programmer
e3Learning.com.au
08 8221 6422

 

Reply via email to