A general rule in Flex layout management is that children get positioned and sized by their parents. I suspect that the reason you don't see anything is that item_button has a width and height of 0 by default.

 

If you extend UIComponent, then it is your responsibility to position and size all of your component's children (in this case, item_button) in an override of updateDisplayList().

 

When you extend HBox, HBox's override of updateDisplayList() implements the horizontal box layout algorithm for the children.

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of sinacapho
Sent: Tuesday, August 15, 2006 1:18 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Custom UIComponent creating problem

 

Dear all,
i have the followig problem , i have using AS3 to created a
custom component (extends from UIComponent) , i find that the custom
component cannot display on the screen. But if the component extends
from HBox , it will show correctly . Can someone tell me why?
The code is attached.

thx
capho

// Mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:gp="test_comp.*">
<mx:Panel width="100%" height="100%">
<gp:test_item/>
</mx:Panel>
</mx:Application>

// ActionScript file

package test_comp{

import mx.core.UIComponent;
import mx.controls.Button;
import mx.containers.HBox;

public class test_item extends HBox{

private var item_button:Button;

public function test_item(){
super();
}

override protected function createChildren():void {

super.createChildren();

if (!item_button){
item_button = new Button();
item_button.label = "As";
addChild(item_button);
}

}

override protected function measure():void{
super.measure();
measuredWidth = measuredMinWidth = 410;
measuredHeight = measuredMinHeight = 30;
}


}
}

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





YAHOO! GROUPS LINKS




__,_._,___

Reply via email to