It’s a bug. Seems like
<mx:Text> doesn’t like getting created dynamically with a percentage
width on a container that isn’t visible? It’s very confusing.
When I used a hardcoded number instead of a % things worked themselves out.
Sorry about the bug, guess it’s fixed in 2.0 J
Matt,
Thanks for the semi-useful suggestion ;)
Tried to set creationPolicy="all" on the
view stack and it has the
same behavior. For kicks, I also tried
moving the call to
initLayout to the creationComplete event on the
second VBox, this
did not help either. Any other ideas?
--- In [email protected],
"Matt Chotin" <[EMAIL PROTECTED]>
wrote:
>
> What happens if you set
creationPolicy="all" on the view stack?
Maybe
> the height it messed up because the VBox was
not really ready to
accept
> children?
>
>
>
> ________________________________
>
> From: [email protected]
[mailto:[email protected]]
On
> Behalf Of pasflex
> Sent: Wednesday, November 02, 2005 2:30 PM
> To: [email protected]
> Subject: [flexcoders] Problem dynamically
creating text controls
>
>
>
> We have an application where we are
dynamically creating various
> controls in containers in a viewstack.
If a text control is
created
> in a non-visible layer of the viewstack, the
height of the control
> is not correct. This only happens for
text controls in 1.5. It
> does not seem to happen in 2.0. Is this
a bug or is there
something
> we are missing?
>
> Thanks
>
> Here is some code that demonstrates the
problem:
>
> <?xml version="1.0"
encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
> creationComplete="initLayout()">
>
<mx:Panel width="250" height="300">
>
<mx:ViewStack id="vs" width="100%"
height="100%">
>
<mx:VBox id="vb1" width="100%"
> height="100%"></mx:VBox>
>
<mx:VBox id="vb2" width="100%"
> height="100%"></mx:VBox>
>
</mx:ViewStack>
>
</mx:Panel>
>
<mx:Script>
>
<![CDATA[
>
var textArray = new Array("The quick brown fox
> jumped over the lazy dog",
>
>
"The quick brown fox jumped over the lazy dog",
>
>
"The quick brown fox jumped over the lazy dog");
>
function initLayout():Void {
>
for (var i=0; i<textArray.length; i++) {
>
vb1.createChild
> (mx.controls.Text, "",
{text:textArray[i], width:"100%"});
>
vb2.createChild
> (mx.controls.Text, "",
{text:textArray[i], width:"100%"});
>
}
>
var vb1Button = vb1.createChild
> (mx.controls.Button,"",
{label:"vbox 2", id:"button1"});
>
vb1Button.addEventListener("click", this);
>
var vb2Button = vb2.createChild
> (mx.controls.Button,"",
{label:"vbox 1", id:"button2"});
>
vb2Button.addEventListener("click", this);
>
}
>
>
function handleEvent(event:Object):Void {
>
if( event.type == "click" ) {
>
if (event.target.id = "button1") {
>
vs.selectedIndex = 1;
>
}
>
if (event.target.id = "button2") {
>
vs.selectedIndex = 0;
>
}
>
}
>
}
> ]]>
>
</mx:Script>
> </mx:Application>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
>
>
>
>
> ________________________________
>
> YAHOO! GROUPS LINKS
>
>
>
> * Visit your
group "flexcoders
> <http://groups.yahoo.com/group/flexcoders>
" on the web.
>
> * To
unsubscribe from this group, send an email to:
>
[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
subject=Unsubscribe>
>
> * Your use of
Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>
.
>
>
>
> ________________________________
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS