UI.lua and director class

Hi,
I can’t get them working together. anyone knows how to get button working with director class? I mean to have two states.
local button1 = ui.newButton{
default = “buttonRed.png”,
over = “buttonRedOver.png”,
onRelease = button1,}

local button1 = display.newImage(“images/button1_start.png”)
local function button1t ( event )
if event.phase == “ended” then
director:changeScene(“level1”,“flip”)
end
end
button1:addEventListener(“touch”,button_t)
button1.x = display.contentWidth/2
button1.y = 200
localGroup:insert(button1)

This is not working :/, I tries to remove event listener so button onRelease triggers event, but that didn’t work as well…
If anyone knows how to get that working please let me know.

Cheers [import]uid: 27699 topic_id: 6496 reply_id: 306496[/import]

I am also interested in how to get this to work.
[import]uid: 9059 topic_id: 6496 reply_id: 22504[/import]

I have a lot of buttons on my apps, I will put it with the new demo of the version 1.2. There are no different thing to do with Director, just insert into the localGroup. [import]uid: 8556 topic_id: 6496 reply_id: 22666[/import]

I love director class but I have the same problem… I can use UI to create the button but not to control the functionality of the button. Instead I have to do something like the following:

[code]
local bt01= ui.newButton{
default = “images/buttonBlue.png”,
over = “images/buttonBlueOver.png”,
id = “bt01”,
text = “Classic”,
size = 30,
textColor = { 255, 255, 255, 255 },
emboss = true
}
bt01.x = 160
bt01.y = 180
localGroup:insert(bt01)
bt01:addEventListener(“touch”,bt01t)
[import]uid: 16901 topic_id: 6496 reply_id: 23128[/import]

You can try the following code for buttons and director class:

[lua] local ui = require(“ui”) – need this to create buttons

local button = ui.newButton{ – create a new button
text = “Test Button”,
size = 12,
textColor = {0,0,0,255},
default = “up.png”,
over = “down.png”
}
button.x = 138
button.y = 275
button.isVisible = true

localGroup:insert(button) – insert the new button into ‘localGroup’ for Director class
localGroup.button = button

function loadGame(event) – button function to load the game screen
if event.phase == “ended” then
director:changeScene(“myGame”,“moveFromLeft”)
end
end
button:addEventListener(“touch”, loadGame) – listen for when the button is ‘touched’[/lua] [import]uid: 33866 topic_id: 6496 reply_id: 23174[/import]

@txmarsh

This is not the way to use the UI button, it will not work with or without Director. Please take a look at the sample on Director 1.2, I put there a lot of UI buttons. [import]uid: 8556 topic_id: 6496 reply_id: 23184[/import]

@ricardorauber
Agree that this is not the “correct” way to make buttons in UI but it was the only way I managed to get it to work once I implemented director class. Regardless, I can’t believe I missed the fact that version 1.2 was released! I’ll check out the sample code… thanks!
[import]uid: 16901 topic_id: 6496 reply_id: 23204[/import]

@txmarsh

Take a look on it and tell me if that was useful. I think the sample on 1.2 version can help a lot with this. [import]uid: 8556 topic_id: 6496 reply_id: 23238[/import]