Hi -
I’m trying to walk through building a custom “Tab” control. Right now I have it working with textboxes that I “Converted to Symbols” and then create dynamically. I can create them like so:
//For every row in the Entryset, create a tab, give it a label of the value in the current row,
//change its width to fit its label, displace it horizontally to fit next to adjacent tab, and
//then set its y coord.
this.mcContent = this.createEmptyMovieClip("mcContent", this.getNextHighestDepth());
for (var i = 0; i < rowLength; i++)
{
mcContent.attachMovie("Tab_MC", "mov" + i + "_mc", i);
mcContent["mov"+i+"_mc"].label_txt.text = rows*[columns[0].name];
newColumns* = new ProtoEntrysetColumn(mcContent["mov"+i+"_mc"].label_txt.text, "Any");
mcContent["mov"+i+"_mc"]._width = mcContent["mov"+i+"_mc"].label_txt.length*8 + 40;
mcContent["mov"+i+"_mc"]._x = mcContent["mov"+i+"_mc"]._width/2 + spacing;
spacing = mcContent["mov"+i+"_mc"]._x + mcContent["mov"+i+"_mc"]._width/2;
mcContent["mov"+i+"_mc"]._y = mcContent["mov"+i+"_mc"]._height/2;
}
I can set the text, and then do something when each tab is clicked (mc.onRelease).
But I’m stuck at trying to make the Tabs look better.
Here’s what I want to do:
- use a graphic and the 9-slicing to wrap the tabs in good-looking images
- use a label, textbox, whatever to draw the tab text over the graphic
- once that works, swap out the graphic when a tab is clicked.
Here’s what I did:
I imported a graphic and then made it a custom symbol, did the right linkage, etc. Then I added a textbox to that movie clip and gave it an instance name.
But when I dynamically make one of these movie clips, I can’t set the label text. I thought I would be able to reference both the graphic and the label text, but once there are more than one ‘object’ in the Symbol / movieclip, I can’t seem to control them.
Do I need to make a class called Tab or something and then have this handle adding a textbox and graphic to itself? I read both of the tutorials on this site: http://www.kirupa.com/developer/actionscript/duplicate.htm and http://www.kirupa.com/developer/flashcs3/animating_dynamic_movieclips_AS3_pg1.htm which were helpful in getting started, but can’t figure out what to do now.
Any help or pointing to the right tutorial to read would be great! I’m a beginner w/ action script, but a comfortable programmer. Just haven’t quite put the Flash model all together yet.
THanks!