Is now a good time to start using Event.ADDED_TO_STAGE vs. your class constructor for initialaztion?

I have always had a habit of doing all my init stuff in the class constructor as do most other people. But today I found a GOTCHA in Flash CS4 when publishing an AIR file.  I was trying to use a ProgressBar and set it’s value manually. I could not see the bar change it’s value even though there was no errors. Nothing I did made it work. This was a problem since there was no errors letting me know that there was a problem, the progress bar just did not work and that’s all I had to go off of.  Later I tried to place my document class code on the timeline which made the progress bar work,  leaving me even more confused and fustrated as to the problem.

In the End I found this had to do with the document class trying to set properties of the ProgressBar before the document class had a chance to be added to the stage.

Aside from my story, this may or may not ever be a problem for you , but it begs the question should this be a standered and would you follow it?

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • MySpace
  • Pownce
  • StumbleUpon
  • Technorati

4 Responses to “Is now a good time to start using Event.ADDED_TO_STAGE vs. your class constructor for initialaztion?”


  1. 1 jrx

    I do this regularly, and use constructor for init.

  2. 2 katopz

    Flash Develop already have template for this

  3. 3 jacob

    I have been leaning to using the constructor to set properties (not involving a stage) and having most classes have a start() function

  4. 4 Josh Chernoff

    Would you guys say it’s a standard already then? The only reason I ask is until I seen it in flashDevelop I never seen it any where in the community for flash. And you guys are the first I have ever seen say to do it this way.

    Maybe I’m just not hanging out with the cool kids, lol.

Leave a Reply