Hi all!
I ve made a function which creates buttons from an array but i have to problems. First it doesnt align the buttons as i say to do and second only the last button is clickable.
Here is tha code
function createMenu(numBut:Array,butWidth:Number,butHeight:Number) {
this.createEmptyMovieClip("menu_mc", this.getNextHighestDepth());
var xPos:Number = 0;
var yPos:Number = 0;
var tfFormatter:TextFormat = new TextFormat();
tfFormatter.bold = true;
//tfFormatter.color = 0xFFFFFF;
for (var i = 0; i<numBut.length; i++) {
var button = menu_mc.createEmptyMovieClip("button"+i, menu_mc.getNextHighestDepth(), {_x:xPos, _y:yPos});
var buttonText = button.createTextField("text"+i, button.getNextHighestDepth(), 10, 0, butWidth-20, butHeight);
button.lineStyle(1, 0xffffff, 100);
button.beginFill(0xFFFFFF,100)
button.lineTo(butWidth, 0);
button.lineTo(butWidth, butHeight);
button.lineTo(0, butHeight);
button.lineTo(0, 0);
buttonText.text = numBut*;
buttonText.setTextFormat(tfFormatter);
xPos += button._width+10;
}
button.onPress = function() {
startDrag(this);
}
button.onRelease = function() {
stopDrag();
}
}
var nameArray:Array = new Array("Home", "Lessons", "Bio", "Contact");
createMenu(nameArray,100,20);
Thank you in advance!!