Sizing apps within the Loader control

21 Feb
2005

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. Cast a loaded Flex Application to an Interface
  2. Flex library assets – cursors
  3. Building desktop applications with HTML and JavaScript
  4. AFR Access – one of the largest public Flex apps to date
  5. Strongly type a CF return using Cairngorm


1 Response to Sizing apps within the Loader control

Avatar

Allen Manning

August 11th, 2006 at 4:56 am

Thanks, for the tip. :)

Comment Form

top