Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-23-2009, 09:51 PM   #1
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default Reusing Objects in a Dynamic Drawing.

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.

Does that seem a good solution?
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 09-24-2009, 02:14 AM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

it sounds like you might be describing a FlyWeight pattern
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 09-24-2009, 02:26 PM   #3
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

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!
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 09-24-2009, 05:59 PM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

cool beans. Good luck!
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:58 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.