change displayed image's source file?

is there any way to change a image’s source file? I need to change an image to different source files after different events.

would not [lua]

display.newImage( “image1.png”, blah, blah, blah)

onFunction

image.filename = (“image2.png”)

end

[/lua] work?  I tried it to no success.

Assign it to a variable:

local myImage = display.newImage( "image1.png", blah, blah, blah) onFunction myImage:removeSelf() myImage = display.newImage( "image2.png", blah, blah, blah) end

it works, but the image doesn’t remove itself when i exit the scene…I’m off to experiment some more

You need to insert the image into the scene group

I did so.  it turns out i had the create code in 2 spots and it kept creating a new image over the old one.  It works now, as i modified the second set.  I also had to re-ad the x and y data every time i had to recreate it or it would go to (0,0)

I know this isn’t related to this problem, but what is the best way to save/read/modify user data that shouldn’t be deleted in an app update?  I have a settings scene that would need to be able to save to it and other scenes would need to be able to read the settings values.  I checked the code exchange, and i tried one “super  package” and i made all my display objects go in crazy places, so i think i need something more simple.

Assign it to a variable:

local myImage = display.newImage( "image1.png", blah, blah, blah) onFunction myImage:removeSelf() myImage = display.newImage( "image2.png", blah, blah, blah) end

it works, but the image doesn’t remove itself when i exit the scene…I’m off to experiment some more

You need to insert the image into the scene group

I did so.  it turns out i had the create code in 2 spots and it kept creating a new image over the old one.  It works now, as i modified the second set.  I also had to re-ad the x and y data every time i had to recreate it or it would go to (0,0)

I know this isn’t related to this problem, but what is the best way to save/read/modify user data that shouldn’t be deleted in an app update?  I have a settings scene that would need to be able to save to it and other scenes would need to be able to read the settings values.  I checked the code exchange, and i tried one “super  package” and i made all my display objects go in crazy places, so i think i need something more simple.