;

PDA

Click to See Complete Forum and Search --> : [RESOLVED] combining variable with sting for html textfield


calmchess
09-15-2009, 12:27 PM
I'm using the following code to try and change the font size of a textfield dynamically using a varaible but I can't get size to use the variable as a value however all the other variables I combine with the string works as intended just not size .....can somebody spot the trouble plz.



var chSize = 50;
trace(msg);
insID.htmlText += "<font size="+chSize.toString(16)+" fontFamily='Tahoma' color=\"#"+newColor.toString(16)+"\">"+msg+"</font>";
insID.wordWrap=true;
stage.focus = msgOut;
scrollBar.update();

dudeqwerty
09-15-2009, 01:18 PM
Why are you converting the size to hexadecimal?

Change:

chSize.toString(16)
to:

chSize.toString()

calmchess
09-15-2009, 01:19 PM
doesn't work either way

dudeqwerty
09-15-2009, 01:19 PM
Forgot one thing, you need the quotes around the size too. Your could should look like this:

var chSize:int = 50;
trace(msg);
insID.htmlText += "<font size=\""+chSize.toString()+"\" fontFamily='Tahoma' color=\"#"+newColor.toString(16)+"\">"+msg+"</font>";
insID.wordWrap=true;
stage.focus = msgOut;
scrollBar.update();

calmchess
09-15-2009, 01:27 PM
YES! I knew it was just a matter of getting quoats in the right place.............Thank you very much for your help once again......cookie for you