I had a recent requirement to load a flex app into another using the Loader control, but I was stuck at trying to get the loaded swf to stretch to the available space.
The problem came as the Loader is a component and not a container and therfore doesnt know about percentages or flex, so it cannot size content in the way we would expect it to. There are 2 workarounds, yet i will always take the later as it allows the size to be dynamic.
There were 2 possible workarounds, but I would generally stick with the later for the sake of dynamic sizing:
1. You can set the height and width of the loaded app to be pixel values (i.e width=”800″ height=”600″).
2. You can add the following code to a script block in the root of the loaded app:
function getPreferredHeight()
{
if(_parent)
{
return _parent.layoutHeight;
}
else
{
return super.getPreferredHeight();
}
}
function getPreferredWidth()
{
if(_parent)
{
return _parent.layoutWidth;
}
else
{
return super.getPreferredWidth();
}
}
Related posts:
1 Response to Sizing apps within the Loader control
Allen Manning
August 11th, 2006 at 4:56 am
Thanks, for the tip.