component lifecycle:

http://www.macromedia.com/support/documentation/en/flex/1_5/createcomponents/createcomponents8.html

HTH,
Aldo

On 9/26/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> Depends on what you extend, and what you are creating.
>
> Extending nothing (implicit inheritance from Object), no need to have
> default properties?
>
> Then nothing.
>
> Extending nothing, but need to have customizable properties?
>
> Pass them into the constructor.  Some would argue you should utilize an init
> instead since it's easy to re-initialize a class instance with new data vs.
> recreating the whole thing.  Example:
>
> a = new Cow();
> a.init(name, dateOfBirth);
> a.init(anotherName, anotherDate);
>
> vs bad way:
>
> a = new Cow(name, dateOfBirth);
> a = new Cow(anotherName, anotherDate):
>
> Most Model classes have public properties so you don't even need a
> constructor or init function since you can just set the properties.  Others
> have public methods accomplishing the same thing.
>
> The third facet is if you are extening something that automatically calls
> your constructor or some other sub function.
>
> For example, extending mx.core.UIObject, UIComponent, or View have a bunch
> of built-in functions that run automatically.  You don't need to even define
> a constructor, although it's nice as a best practice.  For example, if you
> extend UIObject, you're init function is called for you automatically, and
> at that point, if you passed in an initialization object, those properties
> are already set.
>
> So bottom line, I rarely use constructors.  Most of the teaching programming
> books I've seen show those as examples, but I don't ever use them in the
> real-world, and if I do, it's only for intrinsic model classes (Array, Date,
> etc.).  None of my View classes ever take parameters because currently,
> Flash Player requires factory methods to create things vs. a = new
> MovieClip().
>
> Hope that helps.
>
>
> ----- Original Message -----
> From: Rick Schmitty
> To: [email protected]
> Sent: Monday, September 26, 2005 1:34 PM
> Subject: [flexcoders] When to use constructor vs init?
>
> When making a custom class, should you ever put anything in the constructor?
>
>
> class foo {
>
> function foo(){
>   // do stuff here like add event listeners?
> }
>
> function init(){
>    super.init()
>    // do stuff here like add event listeners?
> }
>
> }
>
>
> Also should super.init() be first or last inside of init()?
>
>
> I've seen examples using either, and sometimes both
>
>
> Thanks!
>
>
>  --
>  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
>
>
>  Visit your group "flexcoders" on the web.
>
>  To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
>
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>  ________________________________
>


--
::::: Aldo Bucchi :::::
mobile (56) 8 429 8300


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to