Thursday, August 04, 2005

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.):

[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:

Blogger Mario said...

Michael,

I think you can just use...

yoText.setAttribute('bgcolor', 0xffffff)

(so essentially replace the # in the hex code with "0x").

Thursday, August 04, 2005 5:17:00 AM  
Anonymous Anonymous said...

http://www.colorschemer.com/online.html

Thursday, August 04, 2005 11:04:00 AM  
Blogger Michael Sica said...

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!

Saturday, August 06, 2005 10:15:00 AM  
Blogger Michael Sica said...

It works! Thanks Mario!

Monday, August 08, 2005 8:38:00 PM  

<< Home