Solved

Does Flex have Abstract class

Posted on 2010-11-20
4
1,303 Views
Last Modified: 2012-05-10
Does Flex have abstract class ?If so please can some one give an example
0
Comment
Question by:randyraj
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
mawni earned 250 total points
Comment Utility
as far as I know, Flex (Action Script) doesn't support abstract classes!
0
 
LVL 14

Assisted Solution

by:tomaugerdotcom
tomaugerdotcom earned 250 total points
Comment Utility
AS3 does not support abstract classes directly (ie: there is no "Abstract" directive).

However, an abstract class is essentially a class for whose methods you do not define an implementation. The best practice around abstract class creation can be summed up in this example:
package {

  public class MyAbstractClass implements IMyClass {

    public function MyAbstractClass() {



    }



    public function myPublicMethod():Object {

      throw new Error("Abstract Class: you must define an implementation for myPublicMethod");

      return new Object(); // so we don't get a compile-time error

    }



    private function myPrivateMethod():String {

       throw new Error("Abstract Class: you must define an implementation for myPrivateMethod");

       return ""; / to avoid compile-time exception

    }

  }

}

Open in new window

0
 

Author Closing Comment

by:randyraj
Comment Utility
Thanks
0
 
LVL 14

Expert Comment

by:tomaugerdotcom
Comment Utility
I don't normally complain, but how is my answer a "C"? It's complete, it has a working code example and it addresses your question explicitly. What is your expectation of an "A" answer?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Adobe AIR in bar  launch 3 262
Getting rid of an unwanted URL 5 218
change color row in datagrid 6 631
Display PHP content using Adobe AIR 9 456
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now