Hope I’m not rehashing old requests, but I need some help
I’m creating a menu system, the text buttons should, on rollover, move all buttons to the left (of the button currently rolled over) 100 pixels, in the gap created a sub menu running vertically will appear which will break into a 2nd horizontal submenu etc.
I’m still in the early stages, and have hit a stumbling block, I placed a trace (this); cmd in root of the roll over function then again in each segement of the IF/ELSE loop inside that fuction. The trace CMD in the root of the rollover gives me the feed back _level0.btn1 or 2 or what ever button I have rolled over but the ones inside the IF/ELSE loop all say _level0.btn0 regardless of the button I roll over! Any Ideas why ? Heres the code any help appreciated…
var fontSize:Number = 40;
var yOffset:Number = -7;
var xOffset:Number = 100;
//Sets an originating x and y position for your buttons (in pixels)
var xPosition:Number = 10;
var yPosition:Number = 45;
// on load perform the actions between the curly brackets when your flash movie is loaded
onLoad = function () {
//Creates an array for the number of buttons you want added
/*var button:Array = [home, about, contact]; // number of items here is equal to number of buttons you want*/
var button:Array = new Array();
button[0] = "DRIVES";
button[1] = "SECURITY";
button[2] = "MEMORY";
button[3] = "MOTHERBOARDS";
button[4] = "PROCESSORS";
button[5] = "GRAPHICS";
button[6] = "SOFTWARE";
button[7] = "CASES/PSUs";
//Set a "for loop" to match length of array
for (i=0; i<button.length; i++) {
//Attach the button Movie Clip from the libray, give it an instance name and place it on the next highest level
_root.attachMovie("button","btn"+i,_root.getNextHighestDepth());
// "button" is the IDENTIFIER name given to your symbol in the Linkage window.
// "btn"+i will be the INSTANCE name each new button will be given
// with i being a number that increases by one for each new button.
//Set the y position of the buttons
_root["btn"+i]._x = xPosition;
_root["btn"+i]._y = yPosition;
//Sets a new yPosition so the buttons are underneath each other
// Note: for horizontal menu, you can change this to xPosition
xPosition = xPosition+35;
//Assigns text
//Note: arrays start at zero, so your top button would be named btn0, second button is btn1, etc, etc.
//create textfield "txt1" at "_root.[incrementally increasing name] (name,depth, ypos,xpos,height, width) height and width overridden later in code...
var txt1:TextField = _root["btn"+i].createTextField("txt1", 1000, yOffset, xOffset, 100, 100);
//embed fnts to allow rotation etc.
txt1.embedFonts = true;
//insert text from array location
txt1.text = button*;
//allow autosize of textfield to fit the length of string inserted from array
txt1.autoSize = true;
//rotate the text
txt1._rotation = -90;
//TEXTFORMATTING
txtFormat1 = new TextFormat();
txtFormat1.font = "my_font";
txtFormat1.color = "0xCCCCCC";
txtFormat1.size = fontSize;
txt1.setTextFormat(txtFormat1);
if (i>0) {
trace (i);
trace (_root.btn0.txt1.textWidth);
trace (_root["btn"+i].txt1.textWidth);
//temp varible "ix" defined as number then defined as a percentage of btn0's textwidth
var ix:Number = (_root.btn0.txt1.textWidth/_root["btn"+i].txt1.textWidth)*100;
trace ("ix"+ix);
//item is then scaled to match the percentage "i"
_root["btn"+i].txt1._xscale = ix;
} else {
}
//Assigns the button link
_root.btn0.link = "http://www.chrismcfall.com";
_root.btn1.link = "http://www.google.com";
_root.btn2.link = "http://www.kmscomponents.com";
//Set functions and assign names for the different button states
_root["btn"+(i)].onRollOver = btnOver;
_root["btn"+(i)].onRollOut = btnOut;
_root["btn"+(i)].onRelease = btnRelease;
_root["btn"+(i)].onPress = btnPress;
}
};
// Set the functions that are used in the names above
// When a button is rolled over, perform the actions between the curly brackets
function btnOver() {
this.gotoAndPlay("over");
trace (this);
if (this =_level0.btn0){
trace (this);
}else if(this=_level0.btn1){
trace (this);
}else if(this=_level0.btn2){
trace (this);
}else if(this=_level0.btn3){
trace (this);
}else if(this=_level0.btn4){
trace (this);
}else if(this=_level0.btn5){
trace (this);
}else if(this=_level0.btn6){
trace (this);
}else{
trace ("false");
}}
// When a button is rolled off, perform the actions between the curly brackets
function btnOut() {
this.gotoAndPlay("off");
}
// When a button is pressed, perform the ations between the curly brackets
function btnPress() {
this.gotoAndStop("down");
}
// When a button is released, perform the ations between the curly brackets
function btnRelease() {
this.gotoAndStop("off");
getURL(this.link);
}
Its been a long time since I coded so I’m probably missing something basic, also sorry for being longwinded but I figuure its best to layout the entire concept rather than introduce new complications later…
Many thanks
Chris
PS its AS2 in CS4