Hi everyone,
I am in the process of coding for a navigation menu, and I have a For Loop which, at the moment, duplicates my button movie clip for each of the menu items, and sets some of its properties. Here is the code so far:
for (i=1;i<6;i++){
duplicateMovieClip("mc", "mc"+i, i);
this["mc"+i].button.text = _root["menu"+i];
this["mc"+i].hit._width = (this["mc"+i].button.textWidth + _root.textwidthpadding + _root.rightpadding);
this["mc"+i].button._width = this["mc"+i].hit._width;
_root.totalmenuwidth = (SUM OF ALL EXISTING MC BUTTON WIDTHS) + (_root.menupadding*(i-1)));
_root.startingpos = (-(_root.totalmenuwidth/2));
this["mc"+i]._x = _root.startingpos + (SUM OF ALL EXISTING BUTTON WIDTHS) + (_root.menupadding*(i-1));
this["mc"+i]._y = -(one._height/2);
My question is: How can I get the sum of the Button widths up to and including that value of i? In other words, how can I derive the sum of:
(when i = 3) mc1.button._width + mc2.button._width + mc3.button._width.
(when i = 2) mc1.button._width + mc2.button._width
(when i = 1) mc1.button._width etc.
Thanks in advance for any replies.
Andy