I have variables declared (I assume) in Main.as and I wish to use them in other AS files such as pg1.as
Here’s my code:
//Main.as
package {
import fl.controls.*;
import flash.text.*;
import flash.events.*;
import flash.net.*;
import flash.display.Sprite;
public class Main extends Sprite {
public static var tf_CSM_17_l:TextFormat = new TextFormat();
tf_CSM_17_l.font = "Comic Sans MS";
tf_CSM_17_l.bold = false;
tf_CSM_17_l.color = 0x000000;
tf_CSM_17_l.size = 17;
tf_CSM_17_l.align = TextFormatAlign.LEFT;
//several more almost identical declarations
function Main(){
var Page1:pg1 = new pg1();
Page1.pg_1();
}
//lots more coding not relevant to the problem
}
}
//pg1.as
package {
import fl.controls.*;
import flash.text.*;
import flash.events.*;
import flash.net.*;
import flash.display.Sprite;
public class pg1 extends Sprite {
public function pg_1(){
var pt1:Label = new Label()
pt1.setStyle("textFormat", tf_CSM_17_l);
pt1.move(102,93);
pt1.width = 789;
pt1.height = 284;
pt1.text="some text";
addChild(pt1);
}
}
}
this produces the following error:
1120: Access of undefined property tf_CSM_17_l.
I assume its in the wording of the “public static var”. What should be used so that this variable is available to all AS files?