Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-29-2008, 03:44 PM   #11
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 1,571
Default

Aaaaah, werry clever! That makes sense. I think this more clearly illustrates Abstract Factory for me than any of the literature I've read on the topic.
__________________
http://www.scriptocalypse.com - It's not the end of the world. It's just Actionscript!

man.mask = mask_mc;
maskedMan is offline   Reply With Quote
Old 10-03-2008, 11:38 PM   #12
acolyte
Senior Member
 
acolyte's Avatar
 
Join Date: Feb 2005
Posts: 532
Default

was it the thingy you was looking for ?? did it helped you .

Discussion about design pattern theory in the Best Practice area in my Opinion would be a nice Sticky thread - dont you think .

So we could collect a library covering all patterns with flash/flex examples
__________________
>>I know my english sucks, ... but I speak german.
(this Signature was stolen from some french guy)

Last edited by acolyte; 10-03-2008 at 11:45 PM.
acolyte is offline   Reply With Quote
Old 10-05-2008, 02:45 AM   #13
MichaelxxOA
Flash Sucks
 
MichaelxxOA's Avatar
 
Join Date: Mar 2005
Location: Victorville, Ca
Posts: 2,228
Send a message via AIM to MichaelxxOA Send a message via MSN to MichaelxxOA Send a message via Yahoo to MichaelxxOA Send a message via Skype™ to MichaelxxOA
Default

If you end up needing an interface just refactor your code. Simple code right now will make things easier when refactoring later.
MichaelxxOA is offline   Reply With Quote
Old 10-08-2008, 03:59 PM   #14
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 1,571
Default

Sorry it has taken so long to get back to you, Acolyte! Work is busy.

Hmmm... So, the "Factorys" itself is a sprite, but the IFactory objects it requests instances of are not. I suppose if the IFactory objects were in charge of changing some graphical elements in the Factorys object it could work. The problem is that while you're able to get IFactory objects just fine, you can't add them to the display list because they aren't considered by the machine to be display objects. That's what I'm really getting at... a way to instantiate any number of different subclasses of MovieClip/Sprite without referring to classnames, or even superclassname, but instead by using a common interface and then add them to the display list.
__________________
http://www.scriptocalypse.com - It's not the end of the world. It's just Actionscript!

man.mask = mask_mc;
maskedMan is offline   Reply With Quote
Old 11-04-2008, 10:30 AM   #15
creynders
flash veteran
 
creynders's Avatar
 
Join Date: May 2005
Location: Belgium
Posts: 914
Default

Just declare a getter for the instance as a MovieClip in the interface definition.
ActionScript Code:
//interface function get mc() : MovieClip
ActionScript Code:
//implementation public function get mc() : MovieClip{     return this as MovieClip }
creynders is offline   Reply With Quote
Old 11-04-2008, 03:51 PM   #16
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 1,571
Default

I did eventually try something like that, and it worked for a time. Problem was that it still didn't know its own base class if you used things like getChildAt(x) to retrieve it... so I took a little bit from Acolyte's example and created a recasting utility that basically accepts any object and returns it cast as its classname. Absolutely useless in most cases, but absolutely awesome if you are trying to stick an interface into a display list, or retrieve from said display list and immediately invoke a function or assign a variable.

I then took it a step further and added the recasting utility to a second utility that creates new instances of objects you pass to it. It has as function for making just default instances, a different function that accepts objects implementing an IClonable interface that allows the object that is to be coppied to be responsible for setting all of its relevant data in its clone before the clone is returned by the utility. It's a primitive, but in all the cases I need it effective way of duplicating display objects.
__________________
http://www.scriptocalypse.com - It's not the end of the world. It's just Actionscript!

man.mask = mask_mc;
maskedMan is offline   Reply With Quote
Old 11-05-2008, 06:35 PM   #17
acolyte
Senior Member
 
acolyte's Avatar
 
Join Date: Feb 2005
Posts: 532
Default

Quote:
Originally Posted by maskedMan View Post
I did eventually try something like that, and it worked for a time. Problem was that it still didn't know its own base class if you used things like getChildAt(x) to retrieve it... so I took a little bit from Acolyte's example and created a recasting utility that basically accepts any object and returns it cast as its classname. Absolutely useless in most cases, but absolutely awesome if you are trying to stick an interface into a display list, or retrieve from said display list and immediately invoke a function or assign a variable.

I then took it a step further and added the recasting utility to a second utility that creates new instances of objects you pass to it. It has as function for making just default instances, a different function that accepts objects implementing an IClonable interface that allows the object that is to be coppied to be responsible for setting all of its relevant data in its clone before the clone is returned by the utility. It's a primitive, but in all the cases I need it effective way of duplicating display objects.
Wow that sound nice maskedman i like to organize my mediator like this what is most of the time a subclass of my view if you dont care i would love to see wht you found out about this topic
so it would be cool if you could upload a example maybee ?

What is a good rehearsal maybee for realy getting a crasp what
factory is doing infact i would recommend checking out steven sacks awesome gaiaflashframework what is one of a big factory .

http://www.gaiaflashframework.com/

If you follow the framework flow you will recognize that it is the factory what is abstracting away complexity what if you know what is all about with this strange word "consultancy" :| could be worth something if you are forced to work with nasty stinky sphagetticoders.

bw

m@
__________________
>>I know my english sucks, ... but I speak german.
(this Signature was stolen from some french guy)

Last edited by acolyte; 11-05-2008 at 07:01 PM.
acolyte is offline   Reply With Quote
Old 12-15-2008, 03:57 PM   #18
NickZA
Member
 
NickZA's Avatar
 
Join Date: Aug 2007
Location: Ascot, UK
Posts: 66
Default

Programming to interfaces forces you to think about your classes in terms of the services they provide... which in truth, is all that matters.

I find it prudent to structure objects first around what they provide (methods). Their internal structure is a function of these provisions.

In other words, don't build something in earnest until you know what it's for.

(P.S. This does not mean you cannot change your interfaces as you go, but by a certain point they will have solidified as you realise your requirements through coding... cf. the XP way: the "true" design emerges as you work.)
__________________
www.visualharmonics.co.uk
NickZA 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming to interfaces rawmantick Best Practices 3 12-29-2008 03:40 PM
Programmer-Oriented Programming MichaelxxOA Best Practices 43 02-22-2008 08:54 AM
Senior Flash programmer in Quebec City Bettye Projects and Positions 1 01-30-2008 07:00 PM
Program to Interfaces over Implementations Flash Gordon Best Practices 8 09-03-2007 09:12 AM


All times are GMT. The time now is 12:09 AM.

///
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.