Flash CS3 / Flex 2 AS3 Error#1168

Error #1168: Illegal assignment to function setTextFormat.

This is another easy one. It just means that you assign the format within parenthesis rather than after the “=” sign.
Bad Code:

var myText:TextField = new TextField();
var myFrmt:TextFormat = new TextFormat();
myFrmt.color = 0x336699;
myFrmt.font = “Franklin Gothic Book”;
myText.text = “Flash is fun – Happy Flashing Everyone”;
myText.border =true;
myText.wordWrap = true;
myText.autoSize = TextFieldAutoSize.CENTER;
myText.setTextFormat = myFrmt;
this.addChild(myText);

Good Code:

var myText:TextField = new TextField();
var myFrmt:TextFormat = new TextFormat();
myFrmt.color = 0x336699;
myFrmt.font = “Franklin Gothic Book”;
myText.text = “Flash is fun – Happy Flashing Everyone”;
myText.border =true;
myText.wordWrap = true;
myText.autoSize = TextFieldAutoSize.CENTER;
myText.setTextFormat(myFrmt);
this.addChild(myText);

And this is how you resolve Error #1168: Illegal assignment to function setTextFormat.

One thought on “Flash CS3 / Flex 2 AS3 Error#1168

  1. Pingback: Action Script Error Repository » 1168 Illegal assignment to function

Comments are closed.