Search code examples
apache-flexactionscript-3flex4air

Resizing container on resize of application window in Adobe Flex/AIR Application


I am working on an Adobe AIR Application. The size on Application window is 800X600 and is contains border container and border container contains many controls.

What I want is to if user re-sizes the application then that container should also be re-sized according to scale. i.e If user maximizes or minimizes the window then that border container should also be maximized or minimized respectively.


Solution

  • If you don't want to (or can't for some reason) use percentage based widths then you can always just do the following in MXML:

    <s:BorderContainer 
        xmlns:mx = "http://www.adobe.com/2006/mxml"
        xmlns:s = "library://ns.adobe.com/flex/spark"
    
        width = "{parentApplication.width / 2}"
        height = "{parentApplication.height / 2}">
    

    You are just getting a reference to the component's parentApplication and directly binding to its width and height. Throw whatever math you want on the end.