I keep getting compiler errors when I try to access flashVars in an AS3 class.
Here's a stripped version of the code:
package myPackage {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
public class myClass {
public function CTrafficHandler() {
var myVar:String = LoaderInfo(this.root.loaderInfo).parameters.myFvar;}}}
And I get a compilation error:
1119: Access of possibly undefined property root through a reference with static type source:myClass.
When I change the class row to
public class myClass extends Sprite {
I don't get a compiler error, but I do get this in the output window:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Via the debugger (as suggested) I can see that this.root is null.
How can I solve this problem?