my array looks like this: var cont1:Array = new Array("300","30", "1, 0xFF0000, 1", "0xFFFFFF,1","yes", "myFormat","200","200", "the text", "10","5", "yes");
TypeError: Error #1034: Type Coercion failed: cannot convert "myFormat" to flash.text.TextFormat. at myclass_fla::MainTimeline/frame1()
im getting that? what is the proper way of passing the myFormat to the 开发者_运维技巧setTextFormat.
I think you might have Array's and class contructors mixed up.
you can't do this:
var cont1:Array = new Array("300","30", "1, 0xFF0000, 1", "0xFFFFFF,1","yes", "myFormat","200","200", "the text", "10","5", "yes");
var textFormat : TextFormat = new TextFormat( cont1 ); //this will throw an error;
generally you would construct a TextFormat using it's class methods like this:
var textFormat : TextFormat = new TextFormat();
textFormat.font = "Verdana"
textFormat.color = 0xFF0000;
textFormat.size = 10;
textFormat.underline = true;
then apply it to your textfield
label.defaultTextFormat = textFormat;
精彩评论