how to inherit from multiple classes in a single inheritance language ?
How to deal with a situation when I need to divide the look and logic of all my objects in an application? Each object must look and behave in some way, so each object should inherit from exactly two classes: one defining its look and the second defining its behaviour.
An example:
First class will define how the textbox looks and changes depending on mouse events and so on - no application specific logic, only appearance. I want this class to be independent of the application logic and standalone and reusable in other applications.
Second class defines the application logic of this textbox - lets assume it is a "search" box and each time a user types a letter it should generate some event which returns a list of matching words (from a list which is a property of this class). It should define only the functional features and no appearance at all.
So, how to write a definition for my textbox which should have the appearance defined by first class and behavious defined by the second class? I thought I would just define myTextBox class which would inherit from both classes and then create an object of that class. But this is not possible in AS3 because of single inheritance.
|