I have a library of functions to manipulate DisplayObjects. Currently, it’s a class with static methods.
It’s getting pretty huge (the .as file weights 20 kb) and adds over 4 kb to every swf that uses it. Other problem is the organization: I’m obligated to use ctrl+f to find a method to edit and it’s easy to lose myself in that half-thousand lines of code.
Thinking about that, and wanting to remove the ugly class reference that haunts every function call, I found a solution:
- separate the functions in their own source files, like the ones in the flash.utils package.
So, instead of
import boppreh.utils.Display
Display.setPosition(params)
it would be
import boppreh.utils.display.setPosition
setPosition(params)
I thought of extending MovieClip, since virtually all functions require a DisplayObject as first parameter, but it probably would get messy very quickly, full of wrappers for non-MovieClip objects.
What do you think of it? Should I change or not? How do you organize your functions?