Just to clarify mixins and strategy are a bit different. One is more
structural while the other is more behavioral.

Also mixins aren't really considered a design pattern but it is made up of
composites, proxies / facades (all structural design patterns ) +
interfaces. They are used to emulate multiple inheritance. So something
could have functionality of say a MovieClip and a Sound Object.

The strategy design pattern is used to encapsulate interchangeable logic
(layout, validation, etc).

However, I think what you're really asking is more of an architectural
question so I would take a look at ARP and Cairngorm.

Cairngorm is labeled for Flex but can be easily adapted to Flash
development. Similarly ARP is thought of as being used for slides but can be
adapted to using MovieClips.

Just a note, Cairngorm is less prescriptive about how to structure your
views (which may or may not be a good thing depending on your disposition)
so if you're already pretty far a long in your development check out
Cairngorm

Cairngorm:
http://labs.adobe.com/wiki/index.php/Cairngorm

ARP:
http://www.osflash.org/ARP


If you want want something a bit more fine grained you can do a search on
MVP (Model View Presenter) or MVC (Model View Controller). Both are similar
but have different rules of communication and responsibilities.

-erik

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Ham
Sent: Monday, January 29, 2007 11:40 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?)

OK, this is helping a lot. And Steven I see what you mean, poor Flair  
is starting to look a little meager now.

In my app, I  have several different states. Each state sets itself  
up by initializing variables and drawing its various pieces, and the  
final piece is to subscribe various parts of the app to events that  
happen in other parts. So in one state I have methods like:

onRoomObjectPress()
onRoomObjectRelease()

that are triggered by onPress and onRelease events in my object  
movieclips. These onSomething() methods contain the core logic of the  
app--code to resize clips or process values or what have you. This  
structure is good because I know where to look to track down where  
things happen, but its bad because sometimes a bunch of things are  
supposed to happen at once and those onSomething() methods get hairy.

So in this new mixin strategy (which does look a lot like Strategy,  
thanks James!), should I design my Snappable class to have methods  
that would map to movieclip events, such as:

startObjectDrag triggered by     obj_mc.onPress
checkForSnap    triggered by    setInterval or onEnterFrame type of event,  
in this case onObjectDrag
stopObjectDrag  triggered by    obj_mc.onRelease

Am I headed in the right direction?

Thank you again, this

OK
DAH

> The theory of mixins originated from multiple inheritance programming
> languages such as C++.
>
> So for example: Say you wanted to make an object dragable,  
> clickable and
> resizable. You would then create separate classes called: Dragable,
> Clickable and Resizable (common naming convention for a mixin).
>
> Then your base class would just inherit form those 3 classes.
>
> Since AS2 doesn't support multiple inheritances you can emulate a  
> mixin
> using interfaces and composed classes.
>
> For example:
>
> IClickable, IDragable, IResizable
>
> So then your AS2 class would say:
>
> Class MyClass extends Whatever implements IClickable, IDragable,  
> IResizable
>
> Those interfaces just specify what methods your class has to support.
>
>> From there you could have a class (or a consolidated class)  
>> implement that
> functionality
>
> private var clickable:Clickable = new Clickable();
> private var dragable:Dragable = new Dragable();
> private var resizeable:Resizeable = new Resizeable();
>
> from there you just forward / wire the appropriate methods to its
> corresponding instances.
>
> public function startResize()
> {
>       this.resizeable.startResize();
> }
>
> Or for arguments:
>
> public function startResize()
> {
>       this.resizeable.apply.(this.resizeable.startResize, arguments);
> }
>
> You could get even more fancy by externalizing those classes so  
> based on
> various rules you could pass in different resize logic, etc.
>
> Anyhow, hope that gets the gears turning. =)
>
> DISCLAIMER: Didn't spell check or test anything in the compiler so  
> maybe
> some typos. =)
>
> -erik
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of  
> David Ham
> Sent: Monday, January 29, 2007 7:12 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?)
>
>> Anyhow I tend not to use decorators (matter of personal taste). I
>> prefer to
>> not Frankenstein an object at runtime and rather use mixins
>> (composition +
>> interfaces).
>
> Ah, thank you, now we are getting somewhere!
>
> Tell me about mixins. I have used EventDispatcher before, but I am
> unfamiliar with the theory behind mixins in general.
>
> In my app, i have objects that can be dragged around in a Room, and
> they have a "snapping" behavior that lets them snap to the walls of
> the room, and in some cases, rotate themselves so that a given side
> of the object is always to the wall.
>
> Currently, my snapping behavior is in a separate class like the one
> at the top of this thread. If the room object has snapping enabled,
> the  SnapFlair class adds an object with a bunch of methods and
> properties to it. The snapping methods are triggered by an event that
> is broadcast as the room object is being dragged.
>
> How would I implement this as a mixin?
>
> Many thanks fellas!
>
> As for Steven, sounds like HE'S got a case of the Mondays! *smirk*
>
> OK
> DAH
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
>
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com

-- 
David Ham
http://anthropomorphy.org               ::      +1 630 297 1273
http://davidham.com                     ::      [EMAIL PROTECTED]



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to