# Extending a class

**URL:** <https://forum.kirupa.com/t/extending-a-class/300026>\
**Category:** Uncategorized\
**Created:** [November 14, 2009, 5:27pm UTC](https://forum.kirupa.com/t/extending-a-class/300026 "2009-11-14T17:27:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![regbolD](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@regbolD](https://forum.kirupa.com/u/regbolD)\
**Post date:** [November 14, 2009, 5:27pm UTC](https://forum.kirupa.com/t/extending-a-class/300026/1 "2009-11-14T17:27:01Z")

</div>

…and capturing an event from extended class.

i am extending class B from class A.

snippet form class A (ButtonControl):

```auto

protected function overControls(e:MouseEvent):void {}
protected function outControls(e:MouseEvent):void {}
private function clickControls(e:MouseEvent):void {
            
     _targetName = e.target.name;
              
     dispatchEvent(new Event(ButtonControl.CLICK));
        
}
        
public function getName():String{
            
     return _targetName; 
            
}

```

snippet from class B (ButtonControlTint):

```auto

override protected function overControls(e:MouseEvent):void {}
override protected function outControls(e:MouseEvent):void {}

```

as you can see in class A i am dispatching an event, but the only way to listen for it (as i figured it out) is to add the listener to instance of class B.  
(which ofcourse mean i have to import class A as well)

```auto
import ButtonControlTint;
import ButtonControl;
var btt:ButtonControlTint = new ButtonControlTint( params );
btt.addEventListener(ButtonControl.CLICK, clickControls, false, 0, true);
function clickControls(e:Event = null):void {
    trace(btt.getName());
}

```

is this fine?
