Script for creating dynamic button

here is the code to create dynamic buttons
i have added function to create an indicator to know wih button is activated it’s some lines code i have added at the bottom of the addbutton fuction please try this new version and give me some feedback here is the entire code updated :

function makebuttons(){
// if we have buttons created at first time we remove them to recreate others ones

if(_global.createdClips.length>0){
clearbuttons();
}
addbuttons(homany);
}

function addbuttons(howmany) {
// we create an array to save the buttons references
_global.createdClips = new Array();

for(i=1;i<=howmany;i++){
_root.count++;
myButton = this.createEmptyMovieClip(“but”+i,i+_global.maxSeed) ;
myButton.lineStyle(1) ;
myButton.beginFill(0x336699) ;
myButton.lineTo(22,0) ;
myButton.lineTo(22,20);
myButton.lineTo(0,20) ;
myButton.lineTo(0,0) ;
this[“but”+i]._x = imyButton._width1 ;
myButton.createTextField(“txt”+i,i+10);
myButton[“but”+i].text=i;

// when the movieclip is created we save the reference in the array using this syntax

_global.createdClips.push(myButton);

//=====================we create another movie to make a 3Doutline to the buttonD========================

myButton = this.createEmptyMovieClip(“contour”+i,i+_global.maxSeed+20) ;
myButton.lineStyle(1.75,0x999999) ;
myButton.lineTo(22,0) ;
myButton.lineTo(22,20);
myButton.lineStyle(1.75,0xffffff) ;
myButton.lineTo(0,20) ;
myButton.lineTo(0,0) ;
this[“contour”+i]._x = imyButton._width1 ;

_global.createdClips.push(myButton);

//=============we create a textfield to store the caption ====================================
myButton.createTextField(“text”+i, 0, 3, 1, 18, 20);
myButton[“text”+i].multiline = false;
myButton[“text”+i].wordWrap = false;
myButton[“text”+i].border = false;
myButton[“text”+i].background = false;
myButton[“text”+i].variable = “”;
myformat = new TextFormat();
myformat.font=“verdana”;
myformat.size=“9”;
myformat.color = 0xffffff;
myformat.bullet = false;
myformat.underline = false;
myButton[“text”+i].text = i;
myButton[“text”+i].setTextFormat(myformat);
_global.createdClips.push(myButton);

// we attach event to the button
myButton.onPress = function(){

indicator._visible=true;
indicator._x=this._x;

//you place the code you want

}

myButton.onRelease = function(){

// you place the code you want

}
myButton.onRollOver = function(){

// you place the code you want
}

myButton.onRollOut = function(){

// you place the code you want
}

}

// here is the new lines code to create an indicator
myindic = this.createEmptyMovieClip(“indicator”,_global.maxSeed);
myindic.lineStyle(1);
myindic.beginFill(0x990000);
myindic.lineTo(22,0);
myindic.lineTo(22,3);
myindic.lineTo(0,3);
myindic.lineTo(0,0);
indicateur._y=mybutton._y+myButton._height;
indicateur._x=myButton._x;
init();

}

// here i set the visible property of the indicator to false
function init() {
indicator._visible=false;
}

function clearbuttons() {
indicator.removeMovieClip();
for(var myButton in _global.createdClips){
_global.createdClips[myButton].removeMovieClip();

// we delete the reference of the movieclip removed from the array

_global.createdClips.pop();

}
}

am waiting for your feedback