As Johanness already mentioned, __hasInitialized is used to check if the instance "has initialized".
This is to avoid unnecessary method calls from the setter, as the setter is called before the constructor. Without the check, "set bgColor" would call SetBgColor before anything else. regards, Muzak ----- Original Message ----- From: "Alexander Farber" <[EMAIL PROTECTED]> To: <flashcoders@chattyfig.figleaf.com> Sent: Wednesday, March 21, 2007 6:04 PM Subject: Re: [Flashcoders] Entering hex number (a color) as component parameter > Thank you and sorry - I've missed the "Color" type in Flash help. > > But what is the role of __hasInitialized in your example? Why can't I just: > > [Inspectable(defaultValue="#FFFF66",type="Color")] > public function get bgcolor():Number { > return __bgcolor; > } > > public function set bgcolor(val:Number):Void { > __bgcolor = val; > invalidate(); > } > > (full source code in Bubble.* files @ http://preferans.de/flash/ )? > > On 3/20/07, Muzak <[EMAIL PROTECTED]> wrote: >> [Inspectable(defaultValue="#FFFF66",type="Color")] >> public var bgcolor:Number = 0xFFFF66; >> >> You might be better off using a getter/setter since you will have to redraw >> the rect_mc each time the color changes. >> >> >> private var rect_mc:MovieClip; >> private var __bgColor:Number = 0xFFFF66; >> private var __hasInitialized:Boolean = false; >> >> private function draw() { >> setBgColor(); >> __hasInitialized = true; >> } >> >> private function setBgColor():Void { >> // draw stuff, using __bgColor >> rect_mc.clear(); >> rect_mc.beginFill(__bgColor); >> // etc.. >> rect_mc.endFill(); >> } >> >> [Inspectable(defaultValue="#FFFF66",type="Color")] >> public function get bgColor():Number { >> return __bgColor; >> } >> public function set bgColor(val:Number):Void { >> __bgColor = val; >> if(__hasInitialized) setBgColor(); >> } > > Regards > Alex > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com