accessing elements/groups in for loop

This is really simple and probably a Lua specific question but can I concatenate a string for an element or a group so I can shorten access to elements that have the same name but end with a different #?

That way I can put it in an i = 1 to 4 do, statement. Currently I have this...

1
2
3
4
5
6
7
8
9
10
11
        layout.elements.LeftTopScreen1:play()
        layout.elements.LeftTopScreen1:currentFrame (hudItem[1])
        layout.elements.LeftTopScreen1:pause()
 
        layout.elements.MiddleTopScreen1:play()
        layout.elements.MiddleTopScreen1:currentFrame (hudItem[2])
        layout.elements.MiddleTopScreen1:pause()
 
        layout.elements.RightTopScreen1:play()
        layout.elements.RightTopScreen1:currentFrame (hudItem[3])
        layout.elements.RightTopScreen1:pause()

layout.elements["LeftTopScreen" .. i]
I think this should do...

hey that's the ticket.

My problem was I was leaving in the period. Like this: layout.elements.["LeftTopScreen" .. i]

I guess the '.' is inherit with the brackets !!!

views:1529 update:2012/1/1 13:29:50
corona forums © 2003-2011