How to make a Copy of a display object

I’m trying to implement my own caching system. I have a situation where I need multiple copies of an image, scaled to a particular value.

Doing this is slow:
[lua]for i=1,10 do
local image = display.newImageRect(imageName,width,height)
image.y = (i-1)*(height+margin)
group:insert(image)
end[/lua]
Notice that I’m just inserting 10 copies of the same scaled image into the group. Calling newImageRect 10 times is slow.

What I’d like to do is somehow cache a single image, then make 10 copies of it. Something like this:
[lua]local imageCache = display.newImageRect(imageName,width,height)
for i = 1,10 do
local image = copy of imageCache
image.y = (i-1)*(height+margin)
group:insert(image)
end[/lua]
This would load and scale the image once and then just make copies of it.

Now, if a display object was just a normal LUA table, then I could create a Copy function that just looped through the keys. But I know that Display Objects are special. So is there any way to do this? [import]uid: 12529 topic_id: 7153 reply_id: 307153[/import]

I’m running into the same problem. Does anyone know how to (deep)copy a display object? [import]uid: 43714 topic_id: 7153 reply_id: 50219[/import]

I want it too…
But… by the date… it looks impossible…
[import]uid: 6732 topic_id: 7153 reply_id: 127157[/import]

I want it too…
But… by the date… it looks impossible…
[import]uid: 6732 topic_id: 7153 reply_id: 127157[/import]

Just facing the same need. Anyone found a way? [import]uid: 4883 topic_id: 7153 reply_id: 138839[/import]

Just facing the same need. Anyone found a way? [import]uid: 4883 topic_id: 7153 reply_id: 138839[/import]