Copy link to clipboard
Copied
Hello!
I'm trying to have the ability to make a font smaller if a variable string is longer than the textfield (function updateFormat). I've been able to do it easily in the past, but this time there is an issue. Problem is that it is on a movie clip that is clicked on by the user (and there are multiple instances of said mc on the stage). So I want to have the function execute on the textfield within the clicked instance of the movieclip when it is clicked. I thought just having the code use currentTarget would be fine; however I get syntax error 1084 as Animate expects the right parenthesis before the dot. Any thoughts on how I can make this work? Pertinent code is provided below.
Thanks!
function movePrize(event: MouseEvent) {
if (event.currentTarget.pz_txt.text == "") {
event.currentTarget.pz_txt.text = wonPrize;
updateFormat(event.currentTarget.pz_txt);
wonPrize = null;
} else {
wonPrize = event.currentTarget.pz_txt.text;
event.currentTarget.pz_txt.text = "";
}
}
function updateFormat(event.currentTarget.pz_txt) {
var format:TextFormat = new TextFormat();
if (event.currentTarget.pz_txt.length > 20) {
format.size=12;
} else if (event.currentTarget.pz_txt.length > 10 && event.currentTarget.pz_txt.length < 20) {
format.size=14;
} else {
format.size=16;
}
event.currentTarget.pz_txt.setTextFormat(format);
}
Have something to add?