-
Lunatic
Calling a parent class
I'm pretty new to OOP and classes, I have quite some experience in AS1 but I recently started learning OOP. Here's a very 'noobish' question:
Imagion I have a world-class and that class contains a hero-class. So:
_lvl01 -> world -> hero
Now I want a methode in the hero to call a methode in the world, for example when the hero opens a chest this effects the properties of the world. What is the easiest way to do this?
I'm looking for something very simular to _parent when trying to reach back in a movieclips hirarchy. So that in the hero class I can do something like _parent.openChest() were openChest() is a methode in the world class. Hope you get the idea.
Right now when hero is created, I create a _parent property myself in the constructor, being an instance of the world (_root.myWorld), but there's got to be an easier way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|