Okay, so this might seem like a weird question but let’s suppose you’ve got a display group containing a load of display image objects but you don’t know what the images are and so you want to iterate through them and pull out the image file names - is that possible? I have no problem looping through them but can’t see any way of extracting the image file name from any given display image objects. [import]uid: 39538 topic_id: 10632 reply_id: 310632[/import]
I doubt you will be able to do that currently, however you could do something like this:
local cachedNewImage = display.newImage
display.newImage = function( filename, baseDir )
local image = cachedNewImage( filename, baseDir )
image.filename = filename
return image
end
Untested but it should do the trick. [import]uid: 5833 topic_id: 10632 reply_id: 38635[/import]
This worked for me:
\_filename = "myFile.png"
local foo = display.newImageRect(\_filename, 120, 120)
foo.myFileName = \_filename
print(foo.myFileName)
[import]uid: 28775 topic_id: 10632 reply_id: 39415[/import]