views:

38

answers:

2

I have a problem when making flash applications with more than one frame that has symbols placed on it in that I can't declare all of the event listeners for the objects at the same time and I have found that even if I put them all on the first frame, add the event listeners, then click through to the next frame then the buttons won't work on that frame.

Does anyone have any idea how I could solve this? I did consider myself a fairly competent AS3 programmer until I realised I had no idea how to handle this sort of thing

Solved: I initialised the clips from my external class and then addChild'd and removeChild'd them as I needed to and placed their x and y on addChilding. Thanks, guys

A: 

When working both with Flash & an external IDE such as FlashBuilder , I tend to put as little code as possible in Flash and handle most of the logic in FlashBuilder. Since you refer to an external class , I'm assuming that you may have a similar setup , whereas some of the coding is done outside the Flash IDE.

I don't know your project so it may not be possible or it may be a little late to externalize all your code, but this would be my first option. I find it easier to keep track of the event listeners , the functions triggered , the number of children on stage, who does what when etc...

Another way to look at it, could also be to encapsulate your methods in your MovieClips so that they're not frame dependent and use event dispatching to call methods on the main timeline

PatrickS
Well my project has barely started as I have a lot of ideas but realised I was stumped at the first hurdle as I'm not doing things the way I usually do. The problem is that the movieclips are on the stage already and so they're not initialising correctly but do you think I should just get the locations of them and place them dynamically in the external class and then remove them when I 'change frame'?
Harold
PatrickS
A: 

Well, the better approach will be put all symbols on Frame 1 and add event listener on First Frame OR add them in document class.You can put those symbols outside the stage which are not required to be visible at first Frame and you can bring them on stage on specific frame.

Listeners will be attached to the symbols if they are at first Frame otherwise you will have to attach them on that frame where they are defined and used. And once, listeners are attached to the buttons or any DisplayObjects then it does not matter, frame changes or not. May be your buttons have changed during frame by frame Animation..

Another way to look at it, could also be to encapsulate your methods in your MovieClips so that they're not frame dependent and use event dispatching to call methods on the main timeline

Muhammad Irfan