Simple Question about timer.performwithdelay

Hi All,

I want change my object color in a timer

My code is below.

I hope my object color should change in a time but my object coming same red color.

What is my wrong? 

[lua]obj = display.newRoundedRect( 100, 250, 60, 20, 4)
obj:setFillColor(0, 0, 0)

local function changeColor(i)
obj:setFillColor(i,0,0)
end

for a=1, 255 do
timer.performWithDelay (a*10,changeColor(a))
end
[/lua]

First of all, color range is 0-1 not 0-255.

Also times are short. You wrote:
after 10 ms change r to 1
after 20 ms change r to 2
.
.
.
after 2550ms change r to 255

The best solution would be to pass a/255 to function.

Hi piotrz,

RGB usable at setfillcolor. I think 2550 ms is enough time for see change. 

I think at least I have observed that go toward light to dark.

setfillcolor Syntax

object:setFillColor( gray )

object:setFillColor( gray, alpha )

object:setFillColor( red, green, blue )

object:setFillColor( red, green, blue, alpha )

object:setFillColor( gradient )

First of all, color range is 0-1 not 0-255.

Also times are short. You wrote:
after 10 ms change r to 1
after 20 ms change r to 2
.
.
.
after 2550ms change r to 255

The best solution would be to pass a/255 to function.

Hi piotrz,

RGB usable at setfillcolor. I think 2550 ms is enough time for see change. 

I think at least I have observed that go toward light to dark.

setfillcolor Syntax

object:setFillColor( gray )

object:setFillColor( gray, alpha )

object:setFillColor( red, green, blue )

object:setFillColor( red, green, blue, alpha )

object:setFillColor( gradient )