Kinda busy today, but here's a couple: http://msimtiyaz.wordpress.com/flex/adobe-flex-component-instantiation-life-cycle/
http://nwebb.co.uk/blog/?p=46 http://www.adobe.com/devnet/flex/quickstart/building_components_in_as/ A really good place to start is looking into the API docs for UIComponent and Canvas, and just sort of browsing around, reading up on any method that you don't understand. A lot of custom component creation is about overriding protected methods, because there's a lot of glue in UIComponent that you want to be able to rely on, so pay particular attention to the protected overrides, and to the invalidateXXX() methods. -Josh On Mon, Jun 30, 2008 at 1:45 PM, flexawesome <[EMAIL PROTECTED]> wrote: > right, I am reading the help file. :) If you could poste some > tutorials of components in AS, that would be great :) ( I didn't find > 2 much tutorials about this ) > > Thanks > > --- In flexcoders@yahoogroups.com, "Josh McDonald" <[EMAIL PROTECTED]> wrote: > > > > 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" <dznuts@> > 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 <flexawesome@> > > > 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 :: josh@ > > > > > > > > > > > > > > > > ------------------------------------ > > > > > > -- > > > 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]