I’m trying to add an enterFrame listener to some of my objects, but I can’t seem to get the syntax right. I’ve looked at some examples on the forums and the docs…I must be missing something very obvious 
The enterFrame listener is being called just fine, but I can’t access any of the properties on my object within it. I get an endless stream of runtime exceptions complaining that my properties are nil.
Should I not use “self” in the enterFrame listener function? Am I screwing up the “.” vs “:” syntax?
[code]
local myObject = {}
local myObject_mt = { __index = myObject }
function myObject.new( displayObject )
local newObject = displayObject
newObject.alpha = 0
newObject.fadingIn = true
newObject.startingTime = system.getTimer()
newObject.transitionTime = 10000
Runtime:addEventListener( “enterFrame”, newObject )
return setmetatable( newObject, myObject_mt )
end
function myObject:enterFrame( event )
if self.fadingIn then
local newAlpha = ( system.getTimer() - self.startingTime ) / ( self.transitionTime )
if newAlpha > 1 then
self.alpha = 1
self.startingTime = system.getTimer()
self.fadingIn = false
else
self.alpha = newAlpha
end
else
local newAlpha = 1 - (( system.getTimer() - self.startingTime ) / ( self.transitionTime ))
if newAlpha < 0 then
self.alpha = 0
self.startingTime = system.getTimer()
self.fadingIn = true
else
self.alpha = newAlpha
end
end
end
return myObject
[/code] [import]uid: 82003 topic_id: 20781 reply_id: 320781[/import]