OpenLaszlo - Runtime Color Values :(
I promised I would report the good AND bad of OpenLaszlo. I just found another item to complain about. (For people-finding-this-through-a-search-engine-in-the-future-sake, I am using OpenLaszlo 3.0.2.)
This is really lame.
I'm declaring a piece of text with a bgcolor of some shade of gray here (note I switched the angle brackets for square brackets because of Blogger's CMS tool.):
If I want to change the bgcolor of the above text view to white, you would think I could write some code that looked like this:
Wrong!
I played with this for about an hour before I decided to hit the OpenLaszlo forums. I discovered the following. Apparently at runtime OpenLaszlo can only work with the interger values of colors, and not text (i.e. "black") or hex code (i.e. "#000000"). I have no idea if this is a "Flash thing" or an "OpenLaszlo thing".
Now, in OpenLaszlo's defense their documentation for the bgcolor attribute says the following:
If anyone can point me towards a web site that has the math to convert hex codes to interger values I'd appreciate it. You can leave the link below.
This is really lame.
I'm declaring a piece of text with a bgcolor of some shade of gray here (note I switched the angle brackets for square brackets because of Blogger's CMS tool.):
[canvas]
[text id="yoText" bgcolor="#f2f2f2"]Yo[/text]
[/canvas]
If I want to change the bgcolor of the above text view to white, you would think I could write some code that looked like this:
[method name="changeTextBgcolor"]
canvas.yoText.setAttribute("bgcolor", "#ffffff");
[/method]
Wrong!
I played with this for about an hour before I decided to hit the OpenLaszlo forums. I discovered the following. Apparently at runtime OpenLaszlo can only work with the interger values of colors, and not text (i.e. "black") or hex code (i.e. "#000000"). I have no idea if this is a "Flash thing" or an "OpenLaszlo thing".
Now, in OpenLaszlo's defense their documentation for the bgcolor attribute says the following:
The color of background of this view. Null if there is no bgcolor. A number from 0 - 0xFFFFFF.Which I read, but didn't "get" until now. At 1:30 am. :(
If anyone can point me towards a web site that has the math to convert hex codes to interger values I'd appreciate it. You can leave the link below.


4 Comments:
Michael,
I think you can just use...
yoText.setAttribute('bgcolor', 0xffffff)
(so essentially replace the # in the hex code with "0x").
http://www.colorschemer.com/online.html
Hi Mario,
Thanks for the tip! I'm out of town right now, but I'll try it out when I get back.
Thanks again!
It works! Thanks Mario!
<< Home