How change widget after create

I created a widget in function scene:create

How i can now change this widget in scene:show ?

Need to make this widget global or what?

local composer = require( "composer" ) local widget = require( "widget" ) local scene = composer.newScene() function scene:create( event )     local group = self.view     local title = display.newText( "Test1" x, y - 140, globals.ui.fonts.IndieFlower, 30 )     group:insert(title)     title:setFillColor( 0, 0.5, 1 ) end function scene:create( event )     local group = self.view    local = group:getObjectByName ( "title" ) -- NOT WORKING    title.text = "Test2" end

Hi @kirsan007,

By “widget” do you mean the “title” text object?

Whatever the case, if you need to access objects in different phases of the scene (create, show, hide, destroy), you need to forward-reference those objects outside and above the separate phase functions.

Take care,

Brent

I find my self fwd declare all my variables when dealing with complex stuff in Composer, that way I dont need to think about the different phases and what is in the different scopes. Guess you could also use

[LUA]

composer.setVariable()

– and

composer.getVariable()

[/LUA]

This way your variables are always in scope of composer

Hi @kirsan007,

By “widget” do you mean the “title” text object?

Whatever the case, if you need to access objects in different phases of the scene (create, show, hide, destroy), you need to forward-reference those objects outside and above the separate phase functions.

Take care,

Brent

I find my self fwd declare all my variables when dealing with complex stuff in Composer, that way I dont need to think about the different phases and what is in the different scopes. Guess you could also use

[LUA]

composer.setVariable()

– and

composer.getVariable()

[/LUA]

This way your variables are always in scope of composer