Solved

Does Flex have Abstract class

Posted on 2010-11-20
4
1,310 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
ID: 34183059
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
ID: 34220476
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
ID: 34476156
Thanks
0
 
LVL 14

Expert Comment

by:tomaugerdotcom
ID: 34476291
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Difference between FDS and LCDS 7 348
FLex Calendar 3 551
learning partner 1 218
establish a .net -flex website with existing code 3 330
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…
If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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