I have an issue where using MXML, the height and width properties of myBox is correctly acquired but using ActionScript the correct height and width acquired is not correct.
my:Tab extends NavigatorContent (This is NOT the tab in a Tab Bar)
com:myBox extends BorderContainer.
<mx:ViewStack id="viewstack_main" width="100%" height="100%" creationPolicy="all">
<my:Tab label="My Tab">
<s:Scroller height="100%" width="100%">
<s:Group height="100%" width="100%">
<com:myBox>
</com:myBox>
</s:Group>
</s:Scroller>
</my:Tab>
</mx:ViewStack>
In the constructor of myBox I set the percentWidth
and percentHeight
to both 100.
In the creationComplete
event of the same myBox, I need to access the height
and width
.
This works all ok with the MXML.
However using ActionScript I need to add another tab.
var navContainer:Tab = new Tab();
viewstack_main.addElement(navContainer);
var scroller:Scroller = new Scroller();
scroller.percentHeight = 100;
scroller.percentWidth = 100;
navContainer.addElement(scroller);
var grp:Group = new Group();
grp.percentHeight = 100;
grp.percentWidth = 100;
scroller.viewport = grp;
var box:myBox = new myBox();
grp.addElement(box);
But unfortunately, in the creationComplete event of box, the height and width properties are NOT what is expected (the height & width after setting 100%). It is 112.
Any ideas as to why this works with MXML but NOT ActionScript?
The answer was simple. All I had to do was call validateSize(false)
before requesting for the height and width.