Создал Пользовательский компонент, всё работает, но..
В свойствах выбора цвета выбирая #FF0000 - красный, возвращает на этапе выполнения строку формата 2400632. Цвет элемента естественно, уже не соответствует желаемому.
Код основного класса:
Код AS3:
package scripts
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class checkBoxM extends Sprite
{
[Inspectable (name="Font", variable="tFont", defaultValue="Arial", type="Font Name")]
[Inspectable (name="Color", variable="tColor", defaultValue="#000000", type="Color")]
[Inspectable (name="Checked", variable="Checked", defaultValue=false, type="Boolean")]
[Inspectable (name="Text", variable="Text", defaultValue="CheckBox", type="String")]
private var isChecked:Boolean = false;
private var isHovered:Boolean = false;
private var textColor:int;
private var textFont:String;
public function checkBoxM():void // конструктор
{ // ===================================================================
addEventListener(MouseEvent.CLICK, setCheck);
addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
} // ===================================================================
// ~~~~~~~~~~~~~~~~~~~!!! Параметры компонента !!!~~~~~~~~~~~~~~~~~~~~~~
public function set tFont(font:String):void{textFont = font;}
public function set tColor(color:int):void{textColor = color;}
public function set Checked(bool:Boolean):void{isChecked = bool; redraw()}
public function set Text(text:String):void
{
Label.htmlText = "<font face=\""+textFont+"\"><FONT COLOR=\"#"+textColor+"\">"+text+"</FONT>";
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/////// REDRAW /////////////////////////////////////////////////////////
private function redraw():void // перерисовка иконки по запросу
{ // ===================================================================
if(checked){icon.setIcon("Checked");}else{icon.setIcon("Normal");}
} // ===================================================================
/////// TEXT ///////////////////////////////////////////////////////////
public function set text(string:String) {Label.htmlText = string;}
public function get text():String {return(Label.htmlText);}
/////// CHECKED ////////////////////////////////////////////////////////
public function set checked(bool:Boolean) {isChecked = bool; redraw()}
public function get checked():Boolean {return(isChecked);}
public function setCheck(e:MouseEvent):void // триггер свойства Checked
{ // ===================================================================
if(isChecked == true)
{
isChecked = false;
icon.setIcon("Normal");
}
else
{
isChecked = true;
icon.setIcon("Checked");
}
} // ===================================================================
/////// HOVERED ////////////////////////////////////////////////////////
public function get hovered():Boolean{return(isHovered);}
private function mouseOver(e:MouseEvent):void // мышь над объектом
{ // ===================================================================
if(icon.getIcon() == "Normal")
{
isHovered = true;
icon.setIcon("Hovered");
}
else if (icon.getIcon() == "Checked")
{
isHovered = true;
icon.setIcon("CheckedHovered");
}
} // ===================================================================
private function mouseOut(e:MouseEvent):void // мышь покинула объект
{ // ===================================================================
if(icon.getIcon() == "Hovered")
{
isHovered = false;
icon.setIcon("Normal");
}
else if(icon.getIcon() == "CheckedHovered")
{
isHovered = false;
icon.setIcon("Checked");
}
} // ===================================================================
}
}
Добавлено через 46 минут
Проблемная строчка:
Код AS3:
public function set Text(text:String):void
{
Label.htmlText = "<font face=\""+textFont+"\"><FONT COLOR=\"#"+textColor+"\">"+text+"</FONT>";
}