I have flash project (ActionScript 3), which has a several frames. Each frame contains some unique controls (buttons, textInputs, etc) with unique ids. I want to add event listeners to these controls:
this.gotoAndStop(2);
trace(AddResource); //null !!!
AddResource.addEventListener(MouseEvent.CLICK,AddRes); // Error
I don't know, how to define time, when AddResource will be loaded, after gotoAndStop. I tried to use setTimeout - it works sometimes and makes unwanted delays. So it is bad idea, in my opinion.
Each frame has a lot of controls, they might be changed in future - so, I don't want to use this way (Get MovieClip in another frame).
If it is possible, I want to keep ActionScript code in *.as files, not on timeline (flash cs5: when i change frames in a movieclip, event listeners pointed to one object in the previous frame are removed).
How to solve this problem?