开发者

Extending a class with multiple classes

开发者 https://www.devze.com 2023-01-08 02:39 出处:网络
I\'m creating a class that extends another class. public class ASClass extends UIComponent{ } but I\'m trying to make it extend multiple classes. Is this somehow possible? I r开发者_运维问答ead i

I'm creating a class that extends another class.

public class ASClass extends UIComponent{

}

but I'm trying to make it extend multiple classes. Is this somehow possible? I r开发者_运维问答ead it may be possible through composition?


You're asking about multiple inheritance; which is not supported in ActionScript [or as far as I knew, most modern languages w/ OO Features]. You may think you want the feature, but multiple inheritance opens up a huge can of worms.

I suggest you look into interfaces as they are the intended alternative to multiple inheritance. Here is some Adobe Documentation on Interfaces. Interfaces do not allow you to share an implementation, though.

You can use ActionScript includes as one way to share implementation between multiple files.


You can, but only through a slightly hacky method of using the #include pragma. Here is a Darron Schall article explaining how: http://www.darronschall.com/weblog/2006/10/multiple-inheritance-in-actionscript-3.cfm.

0

精彩评论

暂无评论...
验证码 换一张
取 消