Hello, I'm having trouble putting this into words so I left a brief example below of three classes.
When I create an instance of the Holder class I pass an instance of TestClass (which I intend to use from both the Main & Holder classes). I would like to be able to store this reference in my Holder class and be able to call functions from TestClass. I can run the 'testFunction' from the pass variable 'newTest', but when I try running 'testFunction' from the 'test' variable it results in this error: '1061: Call to a possibly undefined method test through a reference with static type flash.display:Sprite.'
I'm pretty sure I'm running into a design error here. Any help appreciated. Thanks in advance!
Code:
public class TestClass extends Sprite {
public function TestClass () : void {
}
public function testFunction () {
trace ("works");
}
}
Code:
public class Holder extends Sprite {
var test:TestClass;
public function Holder (newTest:TestClass) : void {
test = newTest;
test.testFunction ();
}
}
Code:
public class Main extends Sprite {
var myTestClass = new TestClass ();
var myObject = new Holder (myTestClass);
}