A PositionManager could be a solution (through the event model). However, sometimes we want more encapsulation (or black-box behaviour) and then  composition is the way to go.

On 10/10/06, Michael Schmalle <[EMAIL PROTECTED]> wrote:

> lack of multiple inheritance

Not to start anything but, thankfully there is not multiple inheritence.

Composition is an option but, from what you explain it sounds like the old, addEventListener() will do the trick.

AS is event based, so that is the strong point. You can add a listener to anything that dispatches an event and have the code in one spot.

You could create a PositionManager class that had a static getInstance() class method and subclass EventDispatcher.

You then could take your two subclasses classes, then code;

addEventListener(MouseEvent.DOUBLE_CLICK,
                          PositionManager.getInstance().this_doubleClickHandler);

addEventListener( PositionEvent.UPDATE_POSITION,
                          positionManager_updatePositionHandler);

private function positionManager_updatePositionHandler(event:PositionEvent):void
{
   // do what ever this subclass needs to do based on the logic tested
}



Then in the PositionManager..

public function this_doubleClickHander(event:MouseEvent):void
{
   // ... compare
   // dispatchEvent(new PositionEvent(PositionEvent.UPDATE_POSITION, ...));
}


There is obviosly a lot here to architect into your own sculpture but, I have not ran into any instance where I even thought I needed multiple inheritence in the ActionScript language.

... Things evovle and there are other ways to accomplish something you may be used to from prior experience.

Peace, Mike



On 10/10/06, Marcelo de Moraes Serpa < [EMAIL PROTECTED]> wrote:

Use Interfaces and composition to work around the lack of multiple inheritance.

On 10/10/06, Daniel Freiman < [EMAIL PROTECTED] > wrote:

I know that strictly speaking there is no way for an object to inherit from two superclasses, but doesn't anyone know a good workaround to simulate this in actionscript?  Being able to write code in interfaces instead of just method definitions would be a perfect solution to this problem, but a simple test showed me that wasn't possible.  Anyone have any thoughts?

For those who are confused at what I am asking, a contrived but simple example:
Let's say I'm trying to layout a user interface.  I have two types of controls (ComboBoxes, Buttons).  When doubleclicked I want a control to report it's x value so a user can determine if the controls are aligned by x value.  Right now what I'm doing is implementing this ability in a subclass of combobox and of button, and then extending these new classes when I want to create controls with custom functionality.  This is acceptable except I keep adding functionality to my custom superclasses.  Let's say I want to now want the controls to also report their y position.  I have to go back and both my new combobox and button classes, which is annoying and doubles my code.

Any thoughts on a good way around this problem?

thanks

- Dan





--
What goes up, does come down.


__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to