Try this:

[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,
Muzak

----- Original Message ----- 
From: "Alexander Farber" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
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=0xFFFF66, type='Number')]
> private var bgcolor:Number = 0xFFFF66;
> ....
> 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 0xFFFFFF 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
>
>


_______________________________________________
[email protected]
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

Reply via email to