setFillColor - attempt to call, a nil value

Using simulator 2013.1244 on a pc so NOT a graphics 2.0 issue. This code returns the error - attempt to call method setFillColor - a nil value.

    local drawScreen = function()

        local myText = display.newText( “hello”, 0, 0, native.systemFontBold, 100 )
        myText:setFillColor( 1, 0, 0 )
        
    end
    drawScreen()

Surely something simple but can’t work it out…

 

For text you need to use setTextColor, not setFillColor.

Oh thanks, did realise in graphics 2.0 that object:setTextColor  has been deprecated. But didn’t know all the docs have been updated for graphics 2.0 already:

http://docs.coronalabs.com/api/library/display/newText.html

Hi @kilopop,

For 1.0-based builds, you need to continue using “setTextColor()”. In 2.0-based builds, use “setFillColor()” on display objects, including text, or use V1 compatibility mode to minimize the immediate conversion changes.

I’ve updated the documentation along these lines:

http://docs.coronalabs.com/api/type/ShapeObject/setFillColor.html

Best regards,

Brent

For text you need to use setTextColor, not setFillColor.

Oh thanks, did realise in graphics 2.0 that object:setTextColor  has been deprecated. But didn’t know all the docs have been updated for graphics 2.0 already:

http://docs.coronalabs.com/api/library/display/newText.html

Hi @kilopop,

For 1.0-based builds, you need to continue using “setTextColor()”. In 2.0-based builds, use “setFillColor()” on display objects, including text, or use V1 compatibility mode to minimize the immediate conversion changes.

I’ve updated the documentation along these lines:

http://docs.coronalabs.com/api/type/ShapeObject/setFillColor.html

Best regards,

Brent