# AS3 + Inherited Dependencies

**URL:** https://forum.kirupa.com/t/as3-inherited-dependencies/633101
**Category:** flash
**Created:** [April 28, 2015, 9:34pm UTC](https://forum.kirupa.com/t/as3-inherited-dependencies/633101 "2015-04-28T21:34:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![selacius](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@selacius](https://forum.kirupa.com/u/selacius)
#### Post date: [April 28, 2015, 9:34pm UTC](https://forum.kirupa.com/t/as3-inherited-dependencies/633101/1 "2015-04-28T21:34:15Z")

</div>

I am curious as to what would be quicker, better and use less memory when it comes to variables. Let me explain, I have my main document Main.as, which at present I have a 2nd class instantiated called Formulas.as which contains all of my various calculations in the game. My 3rd class Player.as presently “inherits” the Formulas variable because I pass an instance of Main to Player (new player (Main)). This has led to some issues when I attempt to make a 1 frame preloader. My question is, would it be easier to have every instance of Player (which contains all allies, etc) to have their own variable instance of Formula and therefore remove the requirement for passing Main?

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [April 29, 2015, 11:19pm UTC](https://forum.kirupa.com/t/as3-inherited-dependencies/633101/2 "2015-04-29T23:19:54Z")

</div>

Can Formulas be a singleton, like `Math`? That would make it inherently accessible to any Player without having a dependency on Main.

Otherwise, as far as memory goes, it would be more memory to have each player have its own instance of Formulas but I’m pretty sure it would be negligible unless Formulas is generating some giant, gnarly state when created. From something called “Formulas” that is currently being shared, I doubt that would be the case.

---

<div class="post-metadata">

### Author: ![selacius](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@selacius](https://forum.kirupa.com/u/selacius)
#### Post date: [April 30, 2015, 12:48am UTC](https://forum.kirupa.com/t/as3-inherited-dependencies/633101/3 "2015-04-30T00:48:16Z")

</div>

Basically I am making an RPG game, so the Formulas file would contain all the necessary formulas for stat and damage calculations. Depending on the specific function utilized it takes the data from either the Player class solo or from both an Enemy or Player class. It has no specific need to be called or instantiated from the Main class. I just thought it would be easier to have the main class call it and then have each sub-class (Player) call it by accessing main\_class.formula
