Javascript – Flex: make height of SWF == height of content


I am going to embed a Flex app on an html page. The html page is already going to have a scroll bar to scroll up and down. The contents of the flex app are very dynamic, and I don't want to have an extra scroll bar when there is already one. So is there a way to make the height of the swf match the height of the contents of the swf?


Best Solution

Have the SWF make an ExternalInterface call to resize itself in JavaScript.

  1. The SWF loads waits for all of its content to load and layout.
  2. Once everything is laid out, the SWF makes an ExternalInterface call to a function you write in JavaScript to resize the SWF
  3. The SWF adds a resize event listener on the main content in case anything changes down the road.