Var a:Item = new Item("Business", "+", textsize, color, alignment)

Hi all,

I am new to AS3 and have spent a few weeks to figure out how to create a class which have 2 TextFields - the first textfield is either a “+” or " " and the second one is some text … Since there are over 50 items, I think it will be good to create a class instead of using symbols in flash. I need to adjust the font size, font color, alignment, rotation inside the class.

Example :

var a:Item = new Item(“Business”, “+”, textsize, color, alignment,rotation)

I have the following code which works in timeline but don’t know how to put it in a class…

Can anyone help me out… Thanks in advance !!!


var element01:Sprite = new Sprite();

addChild(element01);

var cFont:String = “Arial”;
var cTitle:uint = 0x999999;
var cContent:uint = 0xc4b789;
var cContainer:uint = 0x7c7f4f;
var c12:uint = 12;
var c10:uint = 10;

var myFont:Font = new EmbedArial();

var txtFmt_gContainer:TextFormat = new TextFormat();
txtFmt_gContainer.font = myFont.fontName;
txtFmt_gContainer.size = 24;
txtFmt_gContainer.font = cFont;
txtFmt_gContainer.color = cContainer;
txtFmt_gContainer.size = c10;
txtFmt_gContainer.align = “right”;

var item:TextField = new TextField();

item.autoSize = TextFieldAutoSize.LEFT;
item.defaultTextFormat = txtFmt_gContainer;
item.embedFonts = true;
item.text = “business”;
element01.addChild(item);

item.x = 10;
item.y = -10;

item.rotation = -8;

var sign:TextField = new TextField();

sign.autoSize = TextFieldAutoSize.LEFT;
sign.defaultTextFormat = txtFmt_gContainer;
sign.embedFonts = true;
sign.text = “+”;
element01.addChild(sign);


Florence