# Call function of parent class

**URL:** <https://forum.kirupa.com/t/call-function-of-parent-class/295259>\
**Category:** Uncategorized\
**Created:** [August 27, 2009, 10:41am UTC](https://forum.kirupa.com/t/call-function-of-parent-class/295259 "2009-08-27T10:41:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artheus](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@artheus](https://forum.kirupa.com/u/artheus)\
**Post date:** [August 27, 2009, 10:41am UTC](https://forum.kirupa.com/t/call-function-of-parent-class/295259/1 "2009-08-27T10:41:48Z")

</div>

Hey!

I’ve got a little question…

How can I make a call to a function in the parent class of the class I’m in.

example:

main class

```auto

package {

    import flash.display.Sprite;

    public class mainClass extends Sprite
    {
        public function mainClass():void
        {
            init();
        }

        private function init():void
        {
            var newObject:MovieClip = new child_class();

            this.addChild(newObject);
        }

        public function theImportantFunction():void
        {
            trace("Very important!");
        }
    }
}

```

child\_class

```auto

package {

    import flash.display.Sprite;

    public class child_class extends Sprite
    {
        public function child_class():void
        {
            init();
        }

        private function init():void
        {
            var someButton:MovieClip = new MovieClip();

            someButton.addEventListener(MouseEvent.CLICK, mouseClick);

            this.addChild(newObject);
        }

        private function mouseClick(e:MouseEvent):void
        {
            theImportantFunction();
        }
    }
}

```

I realise that there is some stuff that is missing in the “full” code here, but that’s just because I’m to lazy to write it all…

**So my question is** … How do I get the “someButton” in the “child\_class” to call the “theImportantFunction” in the main class??? Is it even possible?  
I know that it is possible to make a “dispatchEvent” in the “mouseClick” function, and then add a eventlistener in the main class… But is there another way to just call the function directly?

Cheers,  
Artheus
