Search code examples
memoryapache-flex

Disappearing components?


I have a canvas which contains a single myComponentA. A myComponentA contains a MyComponentB. The myComponentB contains a number of myComponentA's giving a tree structure...Ok so far.

The structure is stored as an XML file.

  1. When I load a big (60 or so components), the components are not visible... When I change the player quality to low or medium they appear...!?

  2. Towards the bottom of the diagram a component is clipped through the middle as though it has been cut off...(The containing canvas continues on empty...)


Solution

  • This is probably an issue with the flex measuring mechanism. Your myComponentA should probably report its measuredHeight and measuredWidth to the parent container. This will likely be done, in your case, in an override of the measure function. e.g,

    override protected function measure():void {
           measuredWidth = //x position + width of rightmost child
           measuredHeight = //y position + height of bottommost child
           super.measure();
    }
    

    If you do something like this in both myComponentA and myComponentB, and you inherit from a Container (e.g., canvas) then things should work mostly. If your components inherit from UIComponent, you might have more trouble (i.e., there won't be any scrollbars).

    Keep in mind that the measure function only sets the measuredHeight and measuredWidth. Depending on your situation, you may need to overide updateDisplayList as well to properly set the actual height/width/positions of the children.