change button default image

Hi,
I created a button with ui.newButton and setting a default image. Is there a way I can change the default image something like myBtn.defaul = “image.png” ?

[import]uid: 6661 topic_id: 1039 reply_id: 301039[/import]

You could do it by adding a function to the button library that takes a new display object as an argument, then deletes the old one and swaps in the new one.

But if you don’t want to go that far, you could just delete the button itself and create a new button with the desired image.

Also, if you don’t need the rollover states, you can turn ANY display object into a “button” by just adding a touch listener to it and listening for the touch events. See the “Sample Code/iPhone/Getting Started/FollowMe” sample code for a simpler touch-handling example. [import]uid: 3007 topic_id: 1039 reply_id: 3102[/import]

“You could do it by adding a function to the button library that takes a new display object as an argument, then deletes the old one and swaps in the new one.”

I did that and for a little while I was having issues with the original button image lingering despite (i thought) using removeSelf() on it. If you have the same issue make sure you declare default and over as local variables within the button class or else they will be out of scope when you try and delete the old image from your newly created function.

Thanks for the the suggestion though evan!

-Matt [import]uid: 12578 topic_id: 1039 reply_id: 17123[/import]