Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Thread Tools Rate Thread Display Modes
Old 08-16-2007, 06:09 PM   #1
Registered User
Join Date: Mar 2007
Posts: 18
Default 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.
miraceti is offline   Reply With Quote
Old 08-16-2007, 09:09 PM   #2
dr_zeus's Avatar
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999

You probably want to look into composition instead of inheritance. Also, consider using interfaces because you can implement multiple interfaces (unlike classes).
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
single function classes uncleunvoid ActionScript 2.0 5 12-22-2006 09:45 AM
Applying multiple CSS classes to a text element _malte ActionScript 2.0 4 08-18-2006 09:47 PM
AS 2.0 Classes for Multiple Loaded Movies? Supa-T ActionScript 2.0 1 10-14-2004 06:57 PM
multiple language selection spacefabrix Other Flash General Questions 3 03-10-2002 07:02 AM

All times are GMT. The time now is 05:41 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.