# How to achive this?

**URL:** <https://forum.kirupa.com/t/how-to-achive-this/185271>\
**Category:** Uncategorized\
**Created:** [April 12, 2006, 3:43am UTC](https://forum.kirupa.com/t/how-to-achive-this/185271 "2006-04-12T03:43:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xxlm](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/xxlm/32/58_2.png) [@xxlm](https://forum.kirupa.com/u/xxlm)\
**Post date:** [April 12, 2006, 3:43am UTC](https://forum.kirupa.com/t/how-to-achive-this/185271/1 "2006-04-12T03:43:42Z")

</div>

SO, the thing is I have this superClass “GameWorld” (singleton).  
the function createworld just run the init function and return the singleton instance.

```auto

public static function createWorld(owner:MovieClip):GameWorld {
GameWorld.instance.init(owner);
return GameWorld.instance;
}

```

The thing is I 'm inheriting this superClass.  
And I want to call childClass.instance.createWorld which will do  
ActionScript Code:

```auto

childClass.instance.init(owner);
return childClass.instance;

```

The thing is I don’t want to write down in my childClass this function createworld (lazy and to be able to only add in the childClass, properties and method specific to the game itself, not the way the engine is started or whatever related to it)

So I come with this idea, but still not working  
ActionScript Code:

```auto

public static function createWorld(owner:MovieClip, baseClass:String) {
// init the game world (setting up the variable)         
var clazz = _global[baseClass];             
//clazz.instance.init(owner);        
return clazz.instance;     
}

```

I have 2 problems here.  
I would like to be able to return the type of the class used (clazz type)  
The \_global[baseClass] is undefined…

Any idea?

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 12, 2006, 3:47am UTC](https://forum.kirupa.com/t/how-to-achive-this/185271/2 "2006-04-12T03:47:04Z")

</div>

i dunno but just so you know u can use [as] and [/as] to wrap you actionscript

```auto

//yay as
trace("hello");
//

```

---

<div class="post-metadata">

**Author:** ![xxlm](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/xxlm/32/58_2.png) [@xxlm](https://forum.kirupa.com/u/xxlm)\
**Post date:** [April 12, 2006, 3:52am UTC](https://forum.kirupa.com/t/how-to-achive-this/185271/3 "2006-04-12T03:52:38Z")

</div>

Thx mate. I didn’t knew that it was available on this forum as well 🙂  
Hehe
