인터페이스 기본문법
package{
public interface Interface {
function method(parameter:Type):ReturnType;
function get property():ReturnType;
function set property(value:Type):void;
}
}
상속구현
public class A implements IExample
public class A extends SuperClass implements IExample
**
타입과 인터페이스, (구상)클래스와 구현은 서로 대응한다. 구상클래스가 인터페이스와 구현 모두를 정의하지만 인터페이스는 인터페이스만 정의한다. 마찬가지로 클래스는 타입이지만 ㅏ입은 클래스일 수 없다. 타입은 인터페이스일 수 있다. 변수를 인터페이스 타입으로 선언함으로써 좋은 유연성을 가지는 코드를 작성할 수 있다.
var item:IProduce;
item 은 IProduce 타입으로 선언됐고, item 변수에 IProduce를 구현하는 어떤 클래스의 인스턴스랃 할당할 수 있다. 더이상 하나의 특정한 클래스로 제한받지 않는다.
글. 액션스크립트 3 디자인 패턴





