Event listeners not dealing with an object

Hello-

Is there any way I could have a set of circumstances (like " if x = 2 " )
and some sort of event listener set up to call a function when these conditions are true (or false for that matter)?

Please say something if you think im being unclear (im new here) [import]uid: 35210 topic_id: 7163 reply_id: 307163[/import]

yes but what’s the event? [import]uid: 6645 topic_id: 7163 reply_id: 25306[/import]

[lua]local x

–…
–do something with X
–…

function onEachFrame()
if x = 2 then
yourFunction(param)
end
end

Runtime:addEventListener(“enterFrame”,onEachFrame)[/lua] [import]uid: 5712 topic_id: 7163 reply_id: 25315[/import]

thanks, thats just what I wanted! [import]uid: 35210 topic_id: 7163 reply_id: 25318[/import]

[lua]if(x==2)[/lua] [import]uid: 6645 topic_id: 7163 reply_id: 25324[/import]