# Accessing Function on Sub Class via Default Class

**URL:** <https://forum.kirupa.com/t/accessing-function-on-sub-class-via-default-class/314690>\
**Category:** flash\
**Created:** [October 6, 2010, 11:52am UTC](https://forum.kirupa.com/t/accessing-function-on-sub-class-via-default-class/314690 "2010-10-06T11:52:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alpha\_eX](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alpha\_eX](https://forum.kirupa.com/u/Alpha_eX)\
**Post date:** [October 6, 2010, 11:52am UTC](https://forum.kirupa.com/t/accessing-function-on-sub-class-via-default-class/314690/1 "2010-10-06T11:52:53Z")

</div>

I’m trying to do this,

```auto
Main.instance.subClassFunction();

```

instance is a public static variable on the default class, Main.

I can do Main.instance.defaultClassFunction() with no problems at all, I use it to access functions and variables from within other classes.

Is it possible to use this method to call a function on the subclass, currently I have to do this,

```auto
Main.instance["subClassFunction"]();

```

I think that’s too messy and would like to know how to get around this. I have tried doing this:

```auto
Subclass.instance.subClassFunction();

```

But it throws an error, 1119: Access of possibly undefined function…

I can also do this,

```auto
var ins:Subclass;
ins = Main.instance as Subclass;
ins.subClassFunction();

```

But again, messy.

Can anyone help?
