At work I’ve been asked to make a small web based mini-game prototype.
I went down the flash route and am using Flash Develop with Flex SDK.
I’ve also found a graphical framework and I can use that no problem, but I’m trying to make my own code reusable at a later date.
I have written a small class for loading a list of textures, from names supplied to the class before loading. It is here to keep the question concise.
To be honest when it comes to Flash/ActionScript, I have no idea what I’m doing, I only started using it a week ago.
What I want to know is whether my attempt is acceptable from a more experienced AS programmer’s point of view. Is it really bad flash coding practice? Does flash handle garbage collection? Should I be keeping an eye on the new Loader() calls that I just disregard?
First of all make loader as field of your class and reuse it. Then add error listener:
Also you should check input data:
When all images were loaded you should “reset” you loader:
And it would be better if you will check the state of your loader to prevent unpredictable cases:
ps immutable fields such as
loader, map, arraymark const. It’s not mistake but other developers will know that these fields are immutable.