4 Replies Latest reply on Jan 15, 2008 3:00 PM by jfrumar

    Instantiate MXML component in actionscript - percent sizing issues

      Hey guys,

      I'm busting my head trying to sort out this issue.

      I have a MXML custom component which is being instantiated in actionscript, e.g.:

      component:CustomComponent = new CustomComponent();

      The custom component extends Canvas (i.e. the root XML tag is a Canvas). Inside the component is another Canvas that wraps the children so they can be laid out using constraint-based measurements (e.g. top, left, right, bottom).

      The component is then added to a VBox through addChild(component).

      Here's the problem - the component doesn't appear on the screen. It's because it's not getting a width and height set correctly. If I bind the Canvas inside it to height="{parent.height}" and width="{parent.width}", then it appears correctly. The problem with this is that the compiler warns me that the binding won't be able to detect changes to the parent sizes. This sux when I launch full screen mode because it doesn't expand to fill the VBox (which sizes correctly).

      Is there something I'm missing here? How does the percentage based widths and heights get applied? Perhaps there's a breakdown in the flow or something.