flash actionscript:
[quoted text, click to view] "¶Ç»¡¤§¯«" <someone@ms.com> wrote in message
news:ctldjh$hg$1@forums.macromedia.com...
> Here is my part of code, which is to achieve the URLs stored in a 2-D
array
> : subButtonURL[x][y]
>
============================================================================
====
[quoted text, click to view] >
> function showSubMenu(x, y, buttonNum, subbuttonNum) {
> hideSubMenu();
> for (i=0; i<subbuttonNum; i++) {
> var tempi:Number = i;
> var tempbuttonNum:Number = buttonNum;
> this["subbutton"+(i+1)+"_mc"]._visible = true;
> this["subbutton"+(i+1)+"_mc"]._x = x+10+(80*i);
> this["subbutton"+(i+1)+"_mc"]._y = y+23;
> this["subbutton"+(i+1)+"_mc"].subbutton_lb.text =
> _root.subButtonText[buttonNum-1][i];
> var myURL:String;
> myURL = _root.subButtonURL[buttonNum-1][i];
> this["subbutton"+(i+1)+"_mc"].onRelease = releaseSubButton(myURL);
> }
> }
>
> function releaseSubButton(myURL) {
> getURL(myURL);
> trace(myURL);
> }
The primary problem is here:
myURL = _root.subButtonURL[buttonNum-1][i];
this["subbutton"+(i+1)+"_mc"].onRelease = releaseSubButton(myURL);
The value of "myURL" in the button event is not the value of "myURL" at the
time the button event is created, but rather, it is the value of "myURL"
when the button event executes (when it's released), which, since the loop
has completely finished running, is the same for all buttons.
--
--------
Reality will not be altered to comply with preconceived notions.
Byron "Barn" Canfield