OK, I am building an AS driven menu system. I am using the following code:-
// stop on current frame
stop();
// set default starting places
var buttonX:Number = 30;
var clientMenuY:Number = 200;
var menuStep:Number = 23;
// create an array with the menu information
var menuArray:Array = ["architekButton",
"kinskiButton",
"creativeButton",
"nubButton",
"luellaButton",
"nylonButton",
"pachiraButton",
"edenButton",
"chainButton",
"harrowButton",
"gingerButton",
"breedButton",
"zandermanButton",
"plasticButton",
"atomicButton",
"hennesButton",
"geButton",
"sainsburyButton"];
// if logo button is pressed then load menu
logo_btn.onRelease = function() {
resetMenu();
}
/*
This function loads the main menu and adds
all the functionality for the page
*/
function loadMenu():Void {
// disable invis button
logo_btn._visible = false;
// load menu
_root.attachMovie("clientsButton", "clients_btn", 1);
_root.attachMovie("contactButton", "contact_btn", 2);
// set properties
clients_btn._x = buttonX;
clients_btn._y = 80;
contact_btn._x = buttonX;
contact_btn._y = 102;
// if they click on the contact button
contact_btn.invis_btn.onRelease = function() {
// reset menu
resetMenu();
// load email button
loadEmailButton();
}
// if they click on the clients button then run animation to output menu
clients_btn.invis_btn.onRelease = function() {
// reset menu
resetMenu();
// load client menu
clientMenu();
}
}
/*
This function loads the email button
*/
function loadEmailButton():Void {
// load email link
_root.attachMovie("emailButton", "email_btn", 3);
// set properties
email_btn._x = buttonX;
email_btn._y = 137;
// if they click on the info button then open email
email_btn.invis_btn.onRelease = function() {
sendEmail();
}
}
/*
this function sends the email
*/
function sendEmail():Void {
// send email
getURL("mailto:info@leonardcommunications.co.uk");
}
/*
This function resets the menu
*/
function resetMenu():Void {
// delete menu items
removeMovieClip(_root.clients_btn);
removeMovieClip(_root.contact_btn);
removeMovieClip(_root.email_btn);
// load menu again
loadMenu();
}
/*
This outputs the client menu to the page
*/
function clientMenu():Void {
// loop through and create menu
for (i = 0; i < menuArray.length; i++) {
// add menu items
clipName = "menuItem" + i;
zIndex = i * 10;
_root.attachMovie(menuArray, clipName, zIndex);
["menuItem" + i]_x = 30;
}
}
Now when the clientMenu() is called it moves all the elements on the screen to
the right. It seems that ["menuItem" + i]_x = 30; is the offending bit of code
but I cannot see how. To see what I am talking about you can go to
http://www.simonbaynes.com/FlashError/ then click on the word Leonard, followed
by the word clients.
Any advice would be greatly appreciated.