PDA

View Full Version : how to read the color name


thipperudra
05-11-2004, 06:16 AM
Hi,

I want to read the color name(in debugger), when i select the newcolor.But now i am getting integer number for the respective selected color(in debugger).What i have to do for reading color name in this below code.

<canvas height="300" debug="true">
<class name="colorspot" clickable="true"
width="22" height="22" bgcolor="black">
<attribute name="mycolor"/>
<attribute name="trackgroup" type="string" value="${parent.trackgroup}"/>
<view name="spot" bgcolor="${parent.mycolor}"
x="2" y="2" width="18" height="18"/>
<method event="oninit">
LzTrack.register(this, this.trackgroup);
</method>
<method event="onmousetrackover">
setAttribute('bgcolor', gray); // hilite: gray
</method>
<method event="onmousetrackout">
setAttribute('bgcolor', black); // normal: black
</method>
<method event="onmousetrackup">
parent.onnewcolor.sendEvent(this.spot.bgcolor);
</method>
</class>

<view bgcolor="0x0000ff" width="20" height="20"
onmousedown="this.colorpicker.setVisible(true); LzTrack.activate('mymenu');"
onmouseup="this.colorpicker.setVisible(false); LzTrack.deactivate('mymenu');">
<view name="colorpicker" visible="false" x="10" y="10">
<attribute name="trackgroup" value="mymenu" type="string"/>
<method event="onnewcolor" args="newcolor">
parent.setAttribute('bgcolor', newcolor);
debug.write("COLOR"+newcolor);
</method>

<simplelayout axis="x"/>
<colorspot mycolor="red"/>
<colorspot mycolor="green"/>
<colorspot mycolor="white"/>
<colorspot mycolor="yellow"/>
<colorspot mycolor="black"/>
</view>
</view>
<text>Click on the square, then release the mouse button to select a new color.</text>
<simplelayout axis="y" spacing="20"/>
</canvas>

Thanks in advance,
Rudresh

antun
05-11-2004, 01:17 PM
There isn't a built-in method to convert numbered colors back to named colors, but you could write a method that did that for you. You'd have to store the name/number combinations in an array.

-Antun