tziuka
tziuka

Reputation: 545

AS3 InputTextField Component size change

I want to use text input component and I drag it on the stage, I give it a instance name. Now from code I'm trying to change the size of it by instance name , because I expand a little bit and the text size remain like it was. Here is my code:

userLog.size = 30;

I receive this error: 1119:Access of possibly undefined property size through a reference with static type fl.controls:TextInput. Thank you!

Upvotes: 1

Views: 97

Answers (1)

Ivan Chernykh
Ivan Chernykh

Reputation: 42166

You can do:

userLog.width = 30;

Or even:

userLog.width = userLog.textWidth ;

Or even more:

userLog.addEventListener(Event.CHANGE,onChange);

function onChange(e:Event):void{
    var new_width:Number;

    if(userLog.textWidth<100){
        new_width = 100;
    } else {
        new_width = userLog.textWidth;
    }

    userLog.width = new_width;
}

UPDATE. In case you want to change TextInput's font size , use TextFormat:

var format:TextFormat = new TextFormat();
format.size = 24;
userLog.setStyle("textFormat", format);

Upvotes: 1

Related Questions