Since it hasn't been noted in this thread, using creationPolicy="all"
defeats a very important feature for many Flex components by forcing the
entire application to be rendered before the user can interact with it.
In a complex app, this will seriously degrade the percieved
responsiveness of your application.  It might not seem like much at
first, but as the app grows it will.  It is an easy fix, but is habit
forming, and will hurt you eventually.

 

Tracy

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ben Marchbanks
Sent: Monday, November 19, 2007 12:56 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Viewstack problems

 

I found that using a bound Model component is a great solution to
populating and 
updating data displayed on viewstack children.

You can update the Model and when the viewstack child is visible the
modified 
data will be present.

for example:

Create a Model

<mx:Model id="myModel">
<record>
<FirstName>Homer</FirstName>
</record>
</mx:Model>

Add a text input to a viewstack child canvas

<mx:TextInput text="{myModel.FirstName}" />

Then modify model using AS

myModel.FirstName = "Bart"

You can also bind your Model to an ArrayCollection, XML, or
XMLListCollection 
data source to populate it initially.

<mx:Model id="myModel">
<record>
<FirstName>{myDataSource.FirstName}</FirstName>
</record>
</mx:Model>

Ben Marchbanks

::: alQemy ::: transforming information into intelligence
http://www.alQemy.com <http://www.alQemy.com> 

::: magazooms ::: digital magazines
http://www.magazooms.com <http://www.magazooms.com> 

Greenville, SC
864.284.9918

johantrax wrote:
> 
> 
> First lets explain the problem:
> A viewstack normally doesn't create all it's children, but only the
> visible ones. This has been done in an ateempt to minimize the
> startuptime of your application.
> 
> Possible solution:
> 1. Ask yourself if you really need to write data on something that is
> not visible. It's not like someone is going to notice it...
> Try if you could use the initialize/show-events of the child itself to
> do this.
> 2. If you can't delegate the writing, and you do have to write to an
> invisible component. Do as Josh suggested and set the creationPlicy of
> the viewstack and its children to "all". This should let the viewstack
> create it's children, even if they're not visible.
> 
> --jeetee
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>, 
> "Rafael Faria"
> <[EMAIL PROTECTED]> wrote:
> >
> > Hello all,
> >
> > I'm having a big trouble with a viewstack.
> >
> > I have this code
> >
> > <mx:ViewStack id="vstack" width="800" height="400">
> >
> > <mx:Canvas id="step1" label="donor information">
> > <mx:HBox>
> > <mx:Canvas id="step1_1" width="390" />
> > <mx:Canvas id="step1_2" width="375" />
> > </mx:HBox>
> > </mx:Canvas>
> >
> > <mx:Canvas id="step2" label="call status">
> > <mx:HBox>
> > <mx:Canvas id="step2_1" width="390" />
> > <mx:Canvas id="step2_2" width="375" />
> > </mx:HBox>
> > </mx:Canvas>
> >
> > <mx:Canvas id="step3" label="contribution information">
> > <mx:HBox>
> > <mx:Canvas id="step3_1" width="390" />
> > <mx:Canvas id="step3_2" width="375" />
> > </mx:HBox>
> > </mx:Canvas>
> >
> > </mx:ViewStack>
> >
> > and an init actionscript which i'm just trying to trace the elements
> > to see what happens and ends up getting null for some elements that
i
> > need to work with.
> >
> > private function init():void {
> > trace(step1); // return the object
> > trace(step1_1); // return the object
> > trace(step1_2); // return the object
> > trace(step2); // return the object
> > trace(step2_1); // return NULL
> > trace(step2_2); // return NULL
> > trace(step3) // return the object
> > trace(step3_1); // return NULL
> > trace(step3_2); // return NULL
> > }
> >
> > The problem is that i really need to work with the canvas on the
> > initialization. I can write dynamically on the canvas (step2 and
> > step3) but weirdly i can't get the objects inside them.
> >
> > Any guru to help me out with that?!
> >
> > Raf
> >
> 
> 

-- 
Ben Marchbanks

::: alQemy ::: transforming information into intelligence
http://www.alQemy.com <http://www.alQemy.com> 

::: magazooms ::: digital magazines
http://www.magazooms.com <http://www.magazooms.com> 

Greenville, SC
864.284.9918

 

Reply via email to