[very noob] how do i find out the filename of an image object?

i’ve got a directory with 10 images. (image1.png, image2.png…)
I’ve written some code that when i tap a button, it shows the next image.

function button:tap( event )  
 if x == 10 then  
 x = 0  
 else   
 x = x + 1  
 end  
 myImage = display.newImage( "image"..x..".png" )  
end  

I want to hide a button in image7.png that will take the user to another set of images.

i tried myImage.name == “image7.png” and myImage.filename == “image7.png” to compare filenames, but it doesn’t seem to work. How do i call the filename property (attribute ?) of myImage?
i just started Lua and looked but couldn’t find an example. I’m sure it’s out there…

thanks in advance [import]uid: 9662 topic_id: 2433 reply_id: 302433[/import]

Hi nimara,

you can extend an object with anything. So just store the filename inside the object.

[lua]myImage = display.newImage( “image”…x…".png" )
myImage.yourfilename = “image”…x…".png"[/lua]

Then you can retrieve it later.

Just be aware that, when you remove an extended object, a table with your extension is still left, so you need to remove it then too.

Cheers
Michael Hartlef

http://www.whiteskygames.com
http://www.twitter.com/mhartlef
[import]uid: 5712 topic_id: 2433 reply_id: 7208[/import]

Thanks!!! [import]uid: 9662 topic_id: 2433 reply_id: 7303[/import]