I want an object to be restyled with any drawing and number of sprite/bitmap/shape/movieclips and all this without recreating any of these if I don't have to because then the application can redraw the object anytime using the current style. The goal being to save resources. I already implemented a solution but I'd like to know how you guys would go about this. Basically the solution I have now is make the new style requests a number and type of objects first.
So let's say it requests 3 bitmaps and 2 sprites. A method checks the current object state and get rid of all objects that are not of the type required. Then it checks if there are at least 3 bitmaps and 2 sprites available and clear them and return them for the new style to use. If there's too many of these, the method removes the not needed ones. Then of course it gives all this back to the style with correct depth and the style draws or puts whatever in them. Of course if some type are missing the method creates them and returns them.
THX A LOT! I read a few article about FlyWeight pattern and this is what I wanted! What I did was the same idea only with a smaller scope. But the FlyWeight pattern is really what I need. Now back to work! Thx Flash Gordon!