Hi jmp909 -
Here is some more additional info as to what I am trying to do:
[lua]text1 = “Some Variable”
text2 = “Some Other Variable”
text3 = “Yet Another Variable”
d = {}
local textTable1 = { text1, text2, text3 } – Table of variables
local textTable2 = { “text1”, “text2”, “text3” } – Table of labels for above variables
– This is the listener for the display Text object
local function textTouch(event)
local id = event.target.id
if(event.phase == “began”) then
transition.to( text[id]:setTextColor(255,255,55), { time=50, alpha=1.0})
d = text[id] – As a test, this should save the variable (Not text label)
elseif(event.phase == “moved”) then
transition.to( text[id]:setTextColor(255,255,55), { time=50, alpha=1.0 })
elseif(event.phase == “ended”) then
transition.to( text[id]:setTextColor(255,255,255), { time=100, alpha=1.0 })
end
end
– Create text display objects that have listeners for touch events
text = {}
for k, v in ipairs(textTable2) do
local myText = display.newText( v, m, n, “Helvetica”, 16 )
myText:setReferencePoint(display.TopLeftReferencePoint)
myText.id = k
myText:setTextColor(255,255,255)
myText:addEventListener(“touch”, textTouch)
text[k] = myText
end[/lua]
Right now I have two tables:
textTable1 has a list of the actual variables.
textTable2 has a list of the labels for these variables.
I then use ipairs to iterate through textTable2 and create 3 text display Objects with listeners that respond to touch events.
Finally, under function textTouch, I have a test table that should save the variable name and not the text name as a test condition (table d). However, this is not occurring.
So as a result, I have to have 2 tables - textTable1 and textTable2. This isn’t really a big deal, but I was hoping for a more “elegant” solution with one table since the names are identical (The only thing being different is that one is a set of variables and the other is a set of strings).
Thanks! [import]uid: 32833 topic_id: 6960 reply_id: 24372[/import]