PDA

View Full Version : dynamic width for dynamic text boxes


electronic ink
02-20-2003, 11:39 AM
Hey all.

I've searched long and hard to resolve this.

After using Jessie's basic array and duplicatemc to create a horizontal menu, I realized that I couldn't dynamically change the length of the text boxes (the text just cuts off).

Can anyone tell me how to achieve this?

The code so far:

Option = ["Home", "Portfolio", "About Us", "Company", "Etc."];
for (n=0; n<=Option.length-1; n++) {
name = "controller"+n;
this.duplicateMovieClip( 'controller', name, n+100);
with (this[name]) {
_x = 20+(_width*n);
_alpha = 100;
_y = 100;
}
this["controller"+n].display = Option[n];
}
stop ();

I know that in this code the MC determines the position and width, I can't workout how to make the text control it. Somehow the length of the text should dictate the width of the text box as well as the MC and its button (the MC and button will both be transparent so just the text is visilbe).

If you could help I would be most grateful.

Cheers

electronic ink

tost
02-20-2003, 02:44 PM
i've done this before, let's see..
the logic is to set the content first, so you can check its length when it appears in the controllers. Make your textBox more than long enough (in the fla) to hold any name, to be sure it isn't chopped before we measure and downscale it.


Option = ["Home", "Portfolio", "About Us", "Company", "Etc."];
for (n=0; n<=Option.length-1; n++) {
name = "controller"+n;
this.duplicateMovieClip( 'controller', name, n+100);
this["controller"+n].display = Option[n];
with (this[name]) {
textBox._width = textBox.textWidth;
_x = 20+(_width*n);
_alpha = 100;
_y = 100;
}
}
stop ();


you might need to add an
updateAfterEvent();
right after
this["controller"+n].display = Option[n];

hope this helps :)
tost