Read books will help to understand the concept, let's try an example:

Let's say you built a flash library and one of your class (ex: Main class)
needs another proper class to be instantiated (like a Config class).

Main class constructor:

Public function Main(config:IConfig):void {

}

IConfig is an interface because you want to be sure the guys are going to
pass a class as a parameter that implementing IConfig:

public class MyConfig implements IConfig

and then instantiate:

var main:Main = new Main(new MyConfig());

Why doing that?

You want to be sure that you will have the functions required in the Config
class passed as a parameter to make it work correctly.

The interface describe it:

public interface IConfig {
        function init():void;
        function get myPropertyNeeded():String;
        function myFunctionNeeded():String;
}

If they pass a Config class that miss one of these functions/properties, you
won't be able to compile as you need to pass a proper IConfig
implementation.

Sorry if my example is not really good, I'm not an OOP wizard, neither a
teacher :) but I hope it helps.

Romu
www.soundstep.com



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ron Wheeler
Sent: 11 September 2008 13:36
To: Flash Coders List
Subject: Re: [Flashcoders] A Question that I've been asking for years!!

Second the recommendation.
Great book - applies to ActionScript easily.

Ron


Steven Loe wrote:
> Check out "Head First Design Pattens" (oreilly). It's an easy to
comprehend book on patterns and software design goodness. The book examples
are in Java, so if you can read AS3 you'll be able to read sample code. 
>
> It a great resource to learn not only what interfaces are, but why and
when you want to use them. IMO its made EAS3 *much* easier going. Moock's
interface / pattern explanations make much more sense after spending some
time with Head First Design Pattens.
>
>
> -Steven Loe
>
>
>
>   
>>> This could seem weird...
>>> But what the hell is an interface!!!???????? I've
>>>       
>> read lots of books
>> and
>>     
>>> posts without getting the answer. I bought
>>>       
>> "Essential AS3" to read
>> about
>>     
>>> interfaces and he says that helps for multi
>>>       
>> inheritance. In other
>> places I
>>     
>>> read that it is a "deal" to ensure that a
>>>       
>> class has some methods and
>> so on.
>>     
>>> But what is the real benefit that I can come out with
>>>       
>> using
>> interfaces????
>>     
>>> Maybe that is stupidity or I am not smart enough to
>>>       
>> get the concept
>> but
>>     
>>> believe me... its is been two years now!!
>>>
>>> Please Help!!!
>>>
>>> --
>>> Omar M. Fouad - Digital Emotions
>>> http://www.omarfouad.net
>>>
>>> This e-mail and any attachment is for authorised use
>>>       
>> by the intended
>>     
>>> recipient(s) only. It may contain proprietary
>>>       
>> material, confidential
>>     
>>> information and/or be subject to legal privilege. It
>>>       
>> should not be
>> copied,
>>     
>>> disclosed to, retained or used by, any other party. If
>>>       
>> you are not an
>>     
>>> intended recipient then please promptly delete this
>>>       
>> e-mail and any
>>     
>>> attachment and all copies and inform the sender. Thank
>>>       
>> you.
>>     
>>> _______________________________________________
>>> Flashcoders mailing list
>>> [email protected]
>>>
>>>       
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>     
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>     
>
>
>       
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>   


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to