View Single Post
12-03-16, 01:58 PM   #1
Tesser
A Deviate Faerie Dragon
Join Date: Oct 2016
Posts: 15
creating frames with for loops

I've made this generic because the actual loop is 50+ lines and I'm just wondering if I'm missing some basics here.
Everything is working except that when I go to print some information about the frame in the "mouseover" event (in this case just "i"), it always prints the information from the last frame created in the loop.
It seems like the logic should have it printing information to it's particular frame, no?

So in this case, say there were 5 table entries - hovering over any of the 5 frames created would print "5".

Code:
for i=1, #table, 1 do
	frames[i]=CreateFrame()
	frames[i]:SetPoint('CENTER', UI, 'CENTER' x, y)
	frames[i]:SetScript("OnEnter", function()
			print(i)
		end)
	frames[i]:SetScript("OnLeave", function() end)
end
  Reply With Quote