Get image file name for a display image object

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.

I doubt you will be able to do that currently, however you could do something like this:

1
2
3
4
5
6
7
8
9
10
11
local cachedNewImage = display.newImage
 
display.newImage = function( filename, baseDir )
 
     local image = cachedNewImage( filename, baseDir )
 
     image.filename = filename
 
    return image
 
end

This worked for me:


_filename = "myFile.png"

local foo = display.newImageRect(_filename, 120, 120)
foo.myFileName = _filename

print(foo.myFileName)

views:1459 update:2011/9/30 9:15:39
corona forums © 2003-2011