Hi folks,
I have some problem with custom event dispatch,
I have a main class call main.as, which will call in another class call
something.as, when something.as is called it will dispatch an event.
i have added an eventListener for that particular event, but it’s not working…
please help~~
thanks in advance
main.as
package {
import flash.events.*;
import flash.display.MovieClip;
import something;
public class main extends MovieClip {
public function main() {
if (stage) {
init();
}
else {
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
public function init(evt:Event = null) {
removeEventListener(Event.ADDED_TO_STAGE, init)
createObjects();
}
public function createObjects() {
var newthing:something = new something();
newthing.addEventListener("lalala",callBack)
addChild(newthing);
function callBack(evt:Event){
trace("here")
}
}
}
}
something.as
package {
import flash.events.*;
import flash.display.MovieClip;
public class something extends MovieClip {
public function something() {
dispatchEvent(new Event("lalala"));
}
}
}