AS3 - Abstract Classes

前端 未结 4 1181
孤城傲影
孤城傲影 2021-02-11 16:52

How can I make an abstract class in AS3 nicely?

I\'ve tried this:

public class AnAbstractClass
{
    public function toBeImplemented():void
    {
                


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-11 17:57

    abstract classes are not supported by actionscript 3. see http://joshblog.net/2007/08/19/enforcing-abstract-classes-at-runtime-in-actionscript-3/

    the above reference also provides a kind of hackish workaround to create abstract classes in as3.

    Edit
    also see http://www.kirupa.com/forum/showpost.php?s=a765fcf791afe46c5cf4c26509925cf7&p=1892533&postcount=70

    Edit 2 (In response to comment)

    Unfortunately, you're stuck with the runtime error. One alternative would be to have a protected constructor.... except as3 doesn't allow that either. See http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/ and http://gorillajawn.com/wordpress/2007/05/21/actionscript-3-%E2%80%93-no-private-constructor/.

    You may Also find these useful: http://www.as3dp.com/category/abstract-classes/ and, in particular, http://www.as3dp.com/2009/04/07/design-pattern-principles-for-actionscript-30-the-dependency-inversion-principle/

提交回复
热议问题