Re: [Flashcoders] Entering hex number (a color) as component parameter
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=#66,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=#66,type=Color)] public var bgcolor:Number = 0x66; 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 = 0x66; 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=#66,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
Re: [Flashcoders] Entering hex number (a color) as component parameter
Looks wrong to me because the drawing code (the setBgColor()) is called outside of the draw() method. Flash Help says to call invalidate() from the set methods instead... On 3/21/07, Johannes Nel [EMAIL PROTECTED] wrote: he checks if the component is init'd On 3/21/07, Alexander Farber [EMAIL PROTECTED] wrote: But what is the role of __hasInitialized in your example? Why can't I [Inspectable(defaultValue=#66,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=#66,type=Color)] public var bgcolor:Number = 0x66; 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 = 0x66; 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=#66,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
Re: [Flashcoders] Entering hex number (a color) as component parameter
That is if you're extending UIComponent, which 99.9% of the time I don't ;) regards, Muzak - Original Message - From: Alexander Farber [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Thursday, March 22, 2007 9:04 AM Subject: Re: [Flashcoders] Entering hex number (a color) as component parameter Looks wrong to me because the drawing code (the setBgColor()) is called outside of the draw() method. Flash Help says to call invalidate() from the set methods instead... ___ 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
Re: [Flashcoders] Entering hex number (a color) as component parameter
listen to that! the v2 components are sheet in flash unfortunately when compared to flex 1.5. if however you are hell bent on using the v2 framework, invalidate will be the thing to use, i would (residual memory kicking in) still have your own init flag. On 3/22/07, Muzak [EMAIL PROTECTED] wrote: That is if you're extending UIComponent, which 99.9% of the time I don't ;) regards, Muzak - Original Message - From: Alexander Farber [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Thursday, March 22, 2007 9:04 AM Subject: Re: [Flashcoders] Entering hex number (a color) as component parameter Looks wrong to me because the drawing code (the setBgColor()) is called outside of the draw() method. Flash Help says to call invalidate() from the set methods instead... ___ 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 -- j:pn http://www.lennel.org ___ 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
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=#66,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=#66,type=Color)] public var bgcolor:Number = 0x66; 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 = 0x66; 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=#66,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
Re: [Flashcoders] Entering hex number (a color) as component parameter
he checks if the component is init'd On 3/21/07, Alexander Farber [EMAIL PROTECTED] wrote: 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=#66,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=#66,type=Color)] public var bgcolor:Number = 0x66; 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 = 0x66; 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=#66,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 -- j:pn http://www.lennel.org ___ 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] Entering hex number (a color) as component parameter
Hello flash coders, I have a mostly working component (please see Bubble.* in http://preferans.de/flash/ ), but wonder how to make the background color to be a parameter. Currently I have: class Bubble extends UIComponent { [Inspectable(defaultValue=0x66, type='Number')] private var bgcolor:Number = 0x66; private function draw():Void { super.draw(); // draw a yellow rectangle: w x h rect_mc.clear(); rect_mc.beginFill(bgcolor); rect_mc.moveTo(0, 0); rect_mc.lineTo(w, 0); rect_mc.lineTo(w, h); rect_mc.lineTo(0, h); rect_mc.lineTo(0, 0); rect_mc.endFill(); - but the component inspector (Alt-F7) won't allow me to enter hexadecimal values like 0xFF into the bgcolor field. Only decimal values will work (which is a bit awkward to use for colors). How could I circumvent this? Use string? Regards Alex -- http://preferans.de ___ 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
Re: [Flashcoders] Entering hex number (a color) as component parameter
[Style(name=myName, type=uint, format=Color)] On 3/20/07, Alexander Farber [EMAIL PROTECTED] wrote: Hello flash coders, I have a mostly working component (please see Bubble.* in http://preferans.de/flash/ ), but wonder how to make the background color to be a parameter. Currently I have: class Bubble extends UIComponent { [Inspectable(defaultValue=0x66, type='Number')] private var bgcolor:Number = 0x66; private function draw():Void { super.draw(); // draw a yellow rectangle: w x h rect_mc.clear(); rect_mc.beginFill(bgcolor); rect_mc.moveTo(0, 0); rect_mc.lineTo(w, 0); rect_mc.lineTo(w, h); rect_mc.lineTo(0, h); rect_mc.lineTo(0, 0); rect_mc.endFill(); - but the component inspector (Alt-F7) won't allow me to enter hexadecimal values like 0xFF into the bgcolor field. Only decimal values will work (which is a bit awkward to use for colors). How could I circumvent this? Use string? Regards Alex -- http://preferans.de ___ 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 -- j:pn http://www.lennel.org ___ 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
Re: [Flashcoders] Entering hex number (a color) as component parameter
Try this: [Inspectable(defaultValue=#66,type=Color)] public var bgcolor:Number = 0x66; 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 = 0x66; 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=#66,type=Color)] public function get bgColor():Number { return __bgColor; } public function set bgColor(val:Number):Void { __bgColor = val; if(__hasInitialized) setBgColor(); } regards, Muzak - Original Message - From: Alexander Farber [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Tuesday, March 20, 2007 11:33 AM Subject: [Flashcoders] Entering hex number (a color) as component parameter Hello flash coders, I have a mostly working component (please see Bubble.* in http://preferans.de/flash/ ), but wonder how to make the background color to be a parameter. Currently I have: class Bubble extends UIComponent { [Inspectable(defaultValue=0x66, type='Number')] private var bgcolor:Number = 0x66; private function draw():Void { super.draw(); // draw a yellow rectangle: w x h rect_mc.clear(); rect_mc.beginFill(bgcolor); rect_mc.moveTo(0, 0); rect_mc.lineTo(w, 0); rect_mc.lineTo(w, h); rect_mc.lineTo(0, h); rect_mc.lineTo(0, 0); rect_mc.endFill(); - but the component inspector (Alt-F7) won't allow me to enter hexadecimal values like 0xFF into the bgcolor field. Only decimal values will work (which is a bit awkward to use for colors). How could I circumvent this? Use string? 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
Re: [Flashcoders] Entering hex number (a color) as component parameter
That's AS3 ;-) - Original Message - From: Johannes Nel [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Tuesday, March 20, 2007 12:55 PM Subject: Re: [Flashcoders] Entering hex number (a color) as component parameter [Style(name=myName, type=uint, format=Color)] ___ 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
Re: [Flashcoders] Entering hex number (a color) as component parameter
yes. i got confused for a second with the list. only when you posted your code and i started writing a reply about the stylechanged method and updatedisplaylist did i notice the flashcoders label :s On 3/20/07, Muzak [EMAIL PROTECTED] wrote: That's AS3 ;-) - Original Message - From: Johannes Nel [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Tuesday, March 20, 2007 12:55 PM Subject: Re: [Flashcoders] Entering hex number (a color) as component parameter [Style(name=myName, type=uint, format=Color)] ___ 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 -- j:pn http://www.lennel.org ___ 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