Dynamically Sized Hit Area

Hi all, I tried searching for this, but couldn’t find anything. I have a movie in which buttons are created dynamically:

links = [“About Us|about.html”, “Locations|locations.html”, “Doctors|doctors.html”, “Hospitals|hospitals.html”, “Research|research.html”, “Optical Shops|optical.html”, “International|international.html”];
function buildList() {
var i = -1;
while (++i<links.length) {
name = “Button”+i;
_root.linksHolder.attachMovie(“links”, name, i, {_x:800, number:i, high:links.length});
_root.linksHolder[name].linkName = links*.split(’|’)[0];
_root.linksHolder[name].link = links*.split(’|’)[1];
}
}
buildList();
stop();

But, I want the “hit” area of the buttons to be the same length as linkName, because right now, the button extends way beyond the text, which doesn’t look that nice. I’ve tried both using “autoSize” and creating a movieclip in the hit area, but have been successful with neither, any suggestions would be greatly appreciated!

You’ll have to manipulate the hitArea property a bit (you can get the length of your text with TextField.textWidth).

Worked like a charm! thanks! :slight_smile: Had to convert my button to a movie clip, but now it works perfectly! :love: