| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
![]() So let me explain my situation. I have to build 4 sites that will use very similar features. Within those 4 sites, there will be several galleries for each site, say 8 galleries. Each gallery will have a linkage, and will look and function slightly different. However, within a single site each image transition will be the same for each gallery. The image transition is only different from site to site. So I have 4 sites, and each site has 1 transition associated. Each site as 8 galleries that use the 1 transition. Ok so my problem is, I have a bunch of code duplication. Each GalleryModuleX is a linkage class that basically sets the specific properties for the superclass. GalleryModuleX is specific to each site, where as the other class provide a framework. The problem is each GalleryModuleX classes are using the same code over and over and I don't know how to get rid of it. I keep copying and pasting this stuff. ActionScript Code:
Since I'm overriding method, how do I encapsulated this code so I only have to write it once?
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman Last edited by Flash Gordon; 10-21-2007 at 05:45 AM.. |
|
|
|
|
|
#2 |
|
as[org].addListener(this)
Join Date: Dec 2005
Location: LA, California
Posts: 838
|
So the only reason you're subclassing is to apply transition in/out effects?
If you want to template recurring logic, you should just use an abstract class as the super class. Last edited by Assertnfailure; 10-21-2007 at 06:09 PM.. |
|
|
|
|
|
|
|
|
#3 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
Thanks for the reply. What is happening is BasicGallery and GalleryX are class that take care of all the gallery functionality for each site. It has about 10 properties that are instantiated but undefined. "GalleryModuleX" just defines the properties and "GalleryModuleX" gets linked to in the Flash GUI. Does that make sense?
So I have BasicModule, BasicGallery, and GalleryX all in a com.framework.modules.galleries package and they are all abstracts. Where GalleryModuleX subclasses the framework but is specific to each site. mysite.modules.galleries package. I'm not sure where in the chain I could add the "abstract class as the super class" that you are referring to.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman Last edited by Flash Gordon; 10-21-2007 at 08:31 PM.. |
|
|
|
|
|
#4 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
anymore thoughts out there?
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#5 |
|
as[org].addListener(this)
Join Date: Dec 2005
Location: LA, California
Posts: 838
|
I know this is a little late, but.....
From what it sounds like to me, you are already using abstract classes in a template pattern arrangement (BasicGallery). Why not insert the common logic into BasicGallery, or insert another abstract class into the inheritance change? |
|
|
|
|
|
#6 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
it's never late to learn
![]() I actually haven't done much with it since then, but I think today I'm going to try and redo the structure to make it use composition rather than inheritance. The reason why I can't I can't "insert the common logic into BasicGallery" (at least in my mind) is that BasicGallery belongs to the "framework" as where "GalleryModule1" belong to the specific site. Each site has it's own GalleryModule1 but all sites share the BasicGallery. Since GalleryModule1 is inheriting from BasicGallery I can't make it inheritant at the site level since it is inheriting at the framework level....tough to explain without see it. I'll give it a shot with composition and post back my results. Thanks again for your valuable input. I always learn something from you posts!
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#7 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
update:
It nearly a complete restructure. In stead of templating the classes, I'm using composition and the Gallery1, GalleryX have been a storage facility for the data and doesn't direct the displaying of the data. That is handled at the GalleryModule level. This looks very promising, and it allows me to have inhertiance where i need it.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#8 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
It actually worked out really well. I wish I could subclass a "template" class and have that superclass have acess to my linkage movieclip.
![]()
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#9 | |
|
as[org].addListener(this)
Join Date: Dec 2005
Location: LA, California
Posts: 838
|
Quote:
ActionScript Code:
ActionScript Code:
Something like that? I haven't really worked in Flash CS3 in a while, so I might not be thinking the same thing. |
|
|
|
|
|
|
#10 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
Some ma na b**ch....
Thanks dude. This is extacly what I needed. ActionScript Code:
ActionScript Code:
ActionScript Code:
I think that right there has been my problem all a long!!!!
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman Last edited by Flash Gordon; 12-10-2007 at 08:50 PM.. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help me not duplicate code on | Seanx | ActionScript 2.0 | 10 | 07-19-2006 04:23 PM |
| Persistant Code Problem | CisTrans | ActionScript 1.0 (and below) | 0 | 06-11-2006 06:25 AM |
| GREATEST CODE EVER! (maybe) - Always get desired FPS in browser | jasonoda | ActionScript 1.0 (and below) | 9 | 06-01-2006 11:57 PM |
| Moving a cursor - Need help with my code | e39m5 | ActionScript 1.0 (and below) | 2 | 01-11-2006 09:20 PM |
| code not working | jaredly | ActionScript 1.0 (and below) | 6 | 06-05-2002 08:56 PM |