Hello 
I am planning to make a simple animation to tow buttons. The animation should start after user pressed one of the buttons. The Problem is that the button that gets pressed, calls the handleButtonFuntion. In the function, a transition gets called but the button gets created after the function… I hope my text makes any sense to you.
The code will explain it better than the text!
Code:
local function handleBtnEdit( event )
if ( “ended” == event.phase ) then
print( “Button was pressed and released BTNEdit” )
–Do something!
end
end
– Create the widget
local btnEdit = widget.newButton(
{
label = “Bearbeiten”,
fontSize = 20,
labelColor = { default = { 0, 0, 0, 0.6 }, over = { 0, 0, 0, 0.6 } },
onEvent = handleBtnEdit,
emboss = false,
– Properties for a rounded rectangle button
shape = “roundedRect”,
width = 150,
height = 35,
cornerRadius = 5,
fillColor = { default = {1 / 255 * 0, 1 / 255 * 143, 1 / 255 * 236}, over = {1 / 255 * 0, 1 / 255 * 160, 1 / 255 * 236} },
}
)
– Center the button
btnEdit.x = display.contentCenterX
btnEdit.y = display.contentCenterY + 20
grpUI:insert(btnEdit)
local function handleBtnBestaetigen( event )
if ( “ended” == event.phase ) then
print( “Button was pressed and released Bestätigen” )
transition.to( btnEdit, { time = 500, x = display.contentCenterX + 80 } ) – This button is already existing and the transition works
transition.to( btnBestaetigen, { time = 1000, x = display.contentCenterX - 80 } ) – The Problem
end
end
– Create the widget
local btnBestaetigen = widget.newButton(
{
label = “BESTÄTIGEN”,
fontSize = 20,
labelColor = { default = { 0, 0, 0, 0.6 }, over = { 0, 0, 0, 0.6 } },
onEvent = handleBtnBestaetigen,
emboss = false,
– Properties for a rounded rectangle button
shape = “roundedRect”,
width = 150,
height = 35,
cornerRadius = 5,
fillColor = { default = {1 / 255 * 2, 1 / 255 * 200, 1 / 255 * 115}, over = {1 / 255 * 2, 1 / 255 * 225, 1 / 255 * 150} },
}
)
– Center the button
btnBestaetigen.x = display.contentCenterX
btnBestaetigen.y = display.contentCenterY + 20
grpUI:insert(btnBestaetigen)
Thanks for helping and sorry for my English skills :DD
