I’ve a class file named MainGraphics. In my class file I’ve an eventlistener but it’s not firing.
package {
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Graphics;
import com.greensock.layout.*;
public class MainGraphics extends Sprite
{
GlobalVarContainer.vars.tempo_txt = new TextField();
GlobalVarContainer.vars.g = new Sprite;
public function CreateArea()
{
// constructor code
this.addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(event:Event)
{
trace(stage);
this.removeEventListener(Event.ADDED_TO_STAGE, init);
// Draw main area
GlobalVarContainer.vars.g.graphics.lineStyle(1, 0x333333, 1);
GlobalVarContainer.vars.g.graphics..beginFill(0x0099FF);
GlobalVarContainer.vars.g.graphics..moveTo(0, 0);
GlobalVarContainer.vars.g.graphics..lineTo(350, 0);
GlobalVarContainer.vars.g.graphics..lineTo(350, 280);
GlobalVarContainer.vars.g.graphics..lineTo(0, 280);
GlobalVarContainer.vars.g.graphics..lineTo(0, 0);
GlobalVarContainer.vars.g.graphics..endFill();
GlobalVarContainer.vars.g.width = 350;
GlobalVarContainer.vars.g.height = 280;
// Create a textfield and a textformat
var format:TextFormat = new TextFormat("Arial", 20, 0x333333, "bold");
format.size = 30;
GlobalVarContainer.vars.tempo_txt.border = true;
GlobalVarContainer.vars.tempo_txt.borderColor = 0x333333;
GlobalVarContainer.vars.tempo_txt.background = true;
GlobalVarContainer.vars.tempo_txt.backgroundColor = 0xffffff;
GlobalVarContainer.vars.tempo_txt.maxChars = 3;
GlobalVarContainer.vars.tempo_txt.mouseEnabled = true;
GlobalVarContainer.vars.tempo_txt.multiline = false;
GlobalVarContainer.vars.tempo_txt.selectable = true;
GlobalVarContainer.vars.tempo_txt.text = "120";
GlobalVarContainer.vars.tempo_txt.textColor = 0x333333;
GlobalVarContainer.vars.tempo_txt.wordWrap = false;
GlobalVarContainer.vars.tempo_txt.type = "input";
GlobalVarContainer.vars.tempo_txt.width = 30;
GlobalVarContainer.vars.tempo_txt.height = 30;
GlobalVarContainer.vars.tempo_txt.defaultTextFormat = format;
GlobalVarContainer.vars.tempo_txt.name = "GlobalVarContainer.vars.tempo_txt";
GlobalVarContainer.vars.tempo_txt.setTextFormat(format);
GlobalVarContainer.vars.tempo_txt.x = (GlobalVarContainer.vars.g.width - GlobalVarContainer.vars.tempo_txt.width) * .5;
GlobalVarContainer.vars.tempo_txt.y = (GlobalVarContainer.vars.g.height - GlobalVarContainer.vars.tempo_txt.height) * .5;
GlobalVarContainer.vars.g.addChild(GlobalVarContainer.vars.tempo_txt);
this.addChild(GlobalVarContainer.vars.g);
var area:AutoFitArea = new AutoFitArea(this, 99, 67, 350, 216, 0xffffff);
area.attach(GlobalVarContainer.vars.g);
area.preview = true;
}
}
}
When I set CreateArea text to MainGraphics, I’m getting error 1061.
Here’s my fla code:
var mGraphics:MainGraphics = new MainGraphics();
mGraphics.CreateArea();