It might work, but you really should look into reading some tutorials on the lifecycle of Flex components. Here's a few brief things:
* You want to create child components in the createChildren() method, not in your constructor. Your component may be instantiated long before it needs to have its children created. * Override the measure() function to set measuredWidth and measuredHeight, but the actual size will be set by your container * Override updateDisplaylist() to size and move your child components. Get their preferred sizes using child.getExplicitOrMeasuredWidth / Height in measure(), but set them using setActualSize(), not by setting the width and height. Position them with move() * There's a lot of good tutorials out there, google is your friend :) -Josh On Mon, Jun 30, 2008 at 12:03 PM, flexawesome <[EMAIL PROTECTED]> wrote: > thank you Josh, I am give a try. > > --- In flexcoders@yahoogroups.com, "Josh McDonald" <[EMAIL PROTECTED]> wrote: > > > > A few things: > > > > You'll need to override measure(), like so: > > > > protected override function measure() : void { > > measuredWidth = _txt.measuredWidth; > > measuredHeight = _txt.measuredHeight; > > } > > > > and updateDisplayList(), like so: > > > > protected override function updateDisplayList(w:Number, h:Number) : > void { > > _txt.move(0,0); > > _txt.setActualSize(Math.min(_txt.measuredWidth, w), > > Math.min(_txt.measuredHeight, h)); > > } > > > > That should do it. But this is typed in gmail, not Flex so it's > probably got > > typos in it :) > > > > -Josh > > > > On Mon, Jun 30, 2008 at 9:50 AM, flexawesome <[EMAIL PROTECTED]> > wrote: > > > > > > > > Hey there, > > > > > > I was trying to create a very simple component in as, there was > no error > > > in compiling. However, I was unable to see the text. :( can you > take a > > > quick look? thank you > > > > > > =================== AS ==================== > > > > > > package > > > { > > > import mx.controls.Text; > > > import mx.core.UIComponent; > > > > > > public class Footer extends UIComponent > > > { > > > public var title:String; > > > private var _txt:Text; > > > > > > public function Footer() > > > { > > > super.setActualSize(50 , 20 ); > > > > > > _txt= new Text(); > > > _txt.text = title; > > > addChild( _txt ); > > > } > > > } > > > } > > > > > > ============ in main.mxml =========== > > > > > > <local:newText title="asdfasdfa" /> > > > > > > > > > > > > ------------------------------------ > > > > > > -- > > > Flexcoders Mailing List > > > FAQ: > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > > Search Archives: > > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! > Groups > > > Links > > > > > > > > > > > > > > > > > > -- > > "Therefore, send not to know For whom the bell tolls. It tolls for > thee." > > > > :: Josh 'G-Funk' McDonald > > :: 0437 221 380 :: [EMAIL PROTECTED] > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]