AS Stops working correctly
Nickels55 Aug 25, 2006 8:50 AMI am helping someone edit a template that they purchased. The
original file had 6 buttons, and when you move over a button the
buttons below it shift downward. I figured out the code enough to
add more buttons. Each button had to be named a number in
sequencial order (ex: 1,2,3,4....). Everything worked great until I
hit 10, then the array crapped out. The tenth button and so on
didn't react like the other buttons, they didn't move down, and
they didn't open correctly. Here is the code:
link = new Array();
frame = new Array();
location = new Array();
link[1] = "1.html";
link[2] = "2.html";
link[3] = "3.html";
link[4] = "4.html";
link[5] = "5.html";
link[6] = "6.html";
link[7] = "7.html";//link for button 7 (new 1)
link[8] = "8.html";//link for button 8 (new 2)
link[9] = "9.html";//link for button 9 (new 3)
link[10] = "10.html";//link for button 10 (new 4)
link[11] = "11.html";//link for button 10 (new 4)
frame[1] = "_self";
frame[2] = "_self";
frame[3] = "_self";
frame[4] = "_self";
frame[5] = "_self";
frame[6] = "_self";
frame[7] = "_self";
frame[8] = "_self";
frame[9] = "_self";
frame[10] = "_self";
frame[11] = "_self";
location = [80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80];
numOfMenu = 11;
gap = 35;
speed = 6;
_global.active = pageNum;
_global.subActive = subNum;
_global.over = active;
for (i = 1; i <= numOfMenu + 1; i++)
{
this ._y = this.defaultY = (i - 1) * gap + this[1]._y;
if (i > 1)
{
if (over)
{
if (this ._name <= over)
{
this.targetY = this .defaultY;
}
else
{
this.targetY = this .defaultY + location[over - 1];
} // end else if
}
else
{
this.targetY = this .defaultY;
} // end else if
this._y = this .targetY;
} // end if
this.bg.onRollOver = function ()
{
_global.over = this._parent._name;
};
this .bg.onRollOut = this.bg.onDragOut = function ()
{
_global.over = active;
};
this .bg.onRelease = function ()
{
getURL(link[this._parent._name], frame[this._parent._name]);
};
this.onEnterFrame = function ()
{
var _loc1 = this;
if (over == _loc1._name)
{
_loc1.direction = "next";
_loc1.nextFrame();
return;
} // end if
_loc1.direction = "prev";
_loc1.prevFrame();
_loc1.prevFrame();
};
} // end of for
this.onEnterFrame = function ()
{
var _loc1 = this;
for (i = 2; i <= numOfMenu + 1; i++)
{
if (over)
{
if (_loc1 ._name <= over)
{
_loc1.targetY = _loc1 .defaultY;
}
else
{
_loc1.targetY = _loc1 .defaultY + location[over - 1];
} // end else if
continue;
} // end if
_loc1.targetY = _loc1 .defaultY;
} // end of for
for (i = 2; i <= numOfMenu + 1; i++)
{
_loc1._y = _loc1 ._y + (_loc1.targetY - _loc1 ._y) / speed;
} // end of for
};
this[numOfMenu + 1].onRollOver = function ()
{
};
this[numOfMenu + 1].useHandCursor = false;
Any idea why this works with 9 buttons but fails to work at 10 or more?
Here is a sample of the buttons working (only 8 buttons)
http://www.johnkalnin.com/test/~TARGET_GO_MENU_TEST.swf
and not working:
http://www.johnkalnin.com/test/11Buttons-test.swf
Thanks for any help.
link = new Array();
frame = new Array();
location = new Array();
link[1] = "1.html";
link[2] = "2.html";
link[3] = "3.html";
link[4] = "4.html";
link[5] = "5.html";
link[6] = "6.html";
link[7] = "7.html";//link for button 7 (new 1)
link[8] = "8.html";//link for button 8 (new 2)
link[9] = "9.html";//link for button 9 (new 3)
link[10] = "10.html";//link for button 10 (new 4)
link[11] = "11.html";//link for button 10 (new 4)
frame[1] = "_self";
frame[2] = "_self";
frame[3] = "_self";
frame[4] = "_self";
frame[5] = "_self";
frame[6] = "_self";
frame[7] = "_self";
frame[8] = "_self";
frame[9] = "_self";
frame[10] = "_self";
frame[11] = "_self";
location = [80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80];
numOfMenu = 11;
gap = 35;
speed = 6;
_global.active = pageNum;
_global.subActive = subNum;
_global.over = active;
for (i = 1; i <= numOfMenu + 1; i++)
{
this ._y = this.defaultY = (i - 1) * gap + this[1]._y;
if (i > 1)
{
if (over)
{
if (this ._name <= over)
{
this.targetY = this .defaultY;
}
else
{
this.targetY = this .defaultY + location[over - 1];
} // end else if
}
else
{
this.targetY = this .defaultY;
} // end else if
this._y = this .targetY;
} // end if
this.bg.onRollOver = function ()
{
_global.over = this._parent._name;
};
this .bg.onRollOut = this.bg.onDragOut = function ()
{
_global.over = active;
};
this .bg.onRelease = function ()
{
getURL(link[this._parent._name], frame[this._parent._name]);
};
this.onEnterFrame = function ()
{
var _loc1 = this;
if (over == _loc1._name)
{
_loc1.direction = "next";
_loc1.nextFrame();
return;
} // end if
_loc1.direction = "prev";
_loc1.prevFrame();
_loc1.prevFrame();
};
} // end of for
this.onEnterFrame = function ()
{
var _loc1 = this;
for (i = 2; i <= numOfMenu + 1; i++)
{
if (over)
{
if (_loc1 ._name <= over)
{
_loc1.targetY = _loc1 .defaultY;
}
else
{
_loc1.targetY = _loc1 .defaultY + location[over - 1];
} // end else if
continue;
} // end if
_loc1.targetY = _loc1 .defaultY;
} // end of for
for (i = 2; i <= numOfMenu + 1; i++)
{
_loc1._y = _loc1 ._y + (_loc1.targetY - _loc1 ._y) / speed;
} // end of for
};
this[numOfMenu + 1].onRollOver = function ()
{
};
this[numOfMenu + 1].useHandCursor = false;
Any idea why this works with 9 buttons but fails to work at 10 or more?
Here is a sample of the buttons working (only 8 buttons)
http://www.johnkalnin.com/test/~TARGET_GO_MENU_TEST.swf
and not working:
http://www.johnkalnin.com/test/11Buttons-test.swf
Thanks for any help.


