passing an array to set default colours on Display objects

Anyone know if its possible to use setFillColor, or setDefault and pass a predefined array for RGB values. It doesn’t seem to work for me. I basically want to specify my app colours once and at the beginning of main.lua so theyre easy to change, but getting stuck on this. Seems like it might be a bug?

[code]
– assign RGB values for colour purple
appColor1 = {92,10,168}
appColor1Alpha = {92,10,168,255}

– applying to a rectangle using setFillColor does not work
backGround = display.newRect( 0, 0, 320, 450)
backGround:setFillColor( appColor1)

– applying to a line using setDefault does not work
display.setDefault( “lineColor”, appColor1Alpha )
local tabLine = display.newLine( 0,20, display.contentWidth,20 )

– applying to a TabBar widget DOES work!
local tabBar = widget.newTabBar{
top = vwFullHeightAbsolute- 50,
buttons = tabButtons,
topGradient = graphics.newGradient(appColor1Alpha,{255,255},“down”),
bottomFill = appColor1
}
[/code] [import]uid: 194387 topic_id: 35644 reply_id: 335644[/import]

Hi @tabrezk,
This is possible, but you need to pass the RGBA values to the command as parameters, not as an array/table.

So, if you had this:

local appColor1 = {92,10,168}  
display.setDefault( "lineColor", appColor1 )  

Change it to this:

local appColor1 = {92,10,168}  
display.setDefault( "lineColor", appColor1[1], appColor1[2], appColor1[3] )  

You could also “unpack” the RGBA array using Lua’s unpack function (http://docs.coronalabs.com/api/library/global/unpack.html), but for something this simple, you can probably just use the direct method.

Brent [import]uid: 200026 topic_id: 35644 reply_id: 141712[/import]

Thanks Brent. That works perfectly. [import]uid: 194387 topic_id: 35644 reply_id: 141721[/import]

. [import]uid: 84637 topic_id: 35644 reply_id: 141743[/import]

Hi @tabrezk,
This is possible, but you need to pass the RGBA values to the command as parameters, not as an array/table.

So, if you had this:

local appColor1 = {92,10,168}  
display.setDefault( "lineColor", appColor1 )  

Change it to this:

local appColor1 = {92,10,168}  
display.setDefault( "lineColor", appColor1[1], appColor1[2], appColor1[3] )  

You could also “unpack” the RGBA array using Lua’s unpack function (http://docs.coronalabs.com/api/library/global/unpack.html), but for something this simple, you can probably just use the direct method.

Brent [import]uid: 200026 topic_id: 35644 reply_id: 141712[/import]

Thanks Brent. That works perfectly. [import]uid: 194387 topic_id: 35644 reply_id: 141721[/import]

. [import]uid: 84637 topic_id: 35644 reply_id: 141743[/import]