Hi, I posted almost this exact same post on bit-101, but I hope I will receive some more insight over here -
I have run into this problem twice now, for two different reasons. Technically the more recent time it isn’t a roadblock, but rather I just want to avoid memory waste by not using nested functions for my event handlers.([color=#006699]http://www.timotheegroleau.com/Flash/articles/scope_chain.htm[/color])
The reason I’ve come to this forum is that I always went on my merry way, defining event handler functions on movieclips within functions, until today, I read “I really didn’t like the idea of defining an event handling function within a method of a class. I don’t think nested functions are a really good practice.” in the [color=#006699]archives of the BIT-101 blog[/color]. So I decided to try to extract these and assign only a reference to each movieclip that needs the function. The problem is, it’s in a class - and I need access to the properties of the movieclip from within the function. I figured I might be able to extend MovieClip, but I don’t want anything in the library, so I run into the problem of how I would use my new movieclip-extending class - I read something about using the Linkage name of “__Packages.”+[classname] - is that really proper? Either way, my final question is - if it’s not good practice to use nested functions within the class, where do I create my event handler functions?
Any help would be appreciated, including comments of any of you who’ve experienced this same problem (solution or not)! Thanks!