thats the way i started learning years ago. maybe if you show me some code i can help. the code i posted above works as is for me. dispatchEvent is a way of creating your own event. like enterFrame, userInput, touch, … in the code above theres an eventListener for a touch event on the circle. when i dispatch my event what im doing is changing the event.phase and im resending it back to the circle as a touch event. You can completely make your own event and dispatch it to an object or to the Runtime. all you need to do is create a variable for a table and inside the table you have to at lease have a name variable.
function myFunct(event) --this does something print(event.name,event.phase,.....) end local myEvent = { name = "doSomething", phase = "start", .... } myObject:addEventListener( "doSomething", myFunct ) function iDidSomethingThatSentMeHere() myObject:dispatchEvent(myEvent) end
whats happening is i hane an object that was created called myObject. when the user does whatever that causes the functin iDidSome… to run it dispatches the event i created called myEvent and myObject has an eventListener listening for an event called doSomething. so it send you to the function called myFunct and myFunct can read all the variables setup inside of myEvent. hope that helps it took me a few times playing around with it to completely grasp it