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: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of pasflex
Sent: Wednesday, November 02, 2005
2:30 PM
To: flexcoders@yahoogroups.com
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
SPONSORED LINKS
YAHOO! GROUPS LINKS