Calling functions from the document class in other classes
Hi there! I'm fairly new to ActionScript and as the title suggests I'm trying to call a function in the document class from another class. I've tried a few methods online such as this that people suggest:
class AnotherClass
{
private var _main:Main;
public function AnotherClass(main:Main)
{
_main = main;
_main.test(); // Success!
}
}
class Main
{
public function Main()
{
var another:AnotherClass = new AnotherClass(this);
}
public function test():void
{
trace("Success!");
}
}
This doesn't work, I get errors where it can't find what main is....does anyone have a better solution or one that won't produce errors? Thanks!