hi there,
create your button swf with dynamic text and make sure export for actionscript is checked.
after loading in your xml create an attach .swf mehtod with a variable of the Y position of each instance in a loop. - I can't garuntee this code will work first time for you so put traces on tjhe arrays and amend them as necessary.
this bit goes in frame 1
///ignore the whitespace always best
XML.prototype.ignoreWhite = true;
///Create a new empty XML Object
var myXMLbuttons:XML = new XML();
///load in the xml files
myXMLbuttons.load("xml/buttons.xml"); // xml source for your buttons
myXMLbuttons.onLoad = function(success){ //open function statement (1)
var rootNode:XMLNode = myXMLCoreTeam.firstChild;
var contentNode:XMLNode = rootNode.firstChild;
//new array for the total number of childNodes
_global.menuArray = new Array();
_global.menuArray = rootNode.childNodes;
_global.numOfItems = _global.menuArray.length;
_global.buttontext = new Array();
_global.buttonURL = new Array();
//set up Arrays for each attribute of each child
for(var i=0;i<=_global.numOfItems;i++){ // (2) For loop -
//depending on how your xml is set up you will need to load in as attributes or nodes (omit one lot of comments)
//_global.buttontrxt.push(menuArray[i].childNodes[0].childNodes[0].nodeValue);
//_global.buttonURL.push(menuArray[i].childNodes[1].childNodes[0].nodeValue);
//or chose to load in as attributes
//_global.buttontext.push(this.firstChild.childNodes[i].attributes.BUTTONName);
//_global.buttonURL.pushpush(this.firstChild.childNodes[i].attributes.BUTTONurl);
} //Close Loop (2)
gotoAndPlay("success"); /// if sucessful goto and play another frame where it makes the buttons
} //Close function (1)
- ///ignore the whitespace always best
- XML.prototype.ignoreWhite = true;
- ///Create a new empty XML Object
- var myXMLbuttons:XML = new XML();
- ///load in the xml files
- myXMLbuttons.load("xml/buttons.xml"); // xml source for your buttons
- myXMLbuttons.onLoad = function(success){ //open function statement (1)
- var rootNode:XMLNode = myXMLCoreTeam.firstChild;
- var contentNode:XMLNode = rootNode.firstChild;
- //new array for the total number of childNodes
- _global.menuArray = new Array();
- _global.menuArray = rootNode.childNodes;
-
- _global.numOfItems = _global.menuArray.length;
- _global.buttontext = new Array();
- _global.buttonURL = new Array();
-
- //set up Arrays for each attribute of each child
- for(var i=0;i<=_global.numOfItems;i++){ // (2) For loop -
- //depending on how your xml is set up you will need to load in as attributes or nodes (omit one lot of comments)
- //_global.buttontrxt.push(menuArray[i].childNodes[0].childNodes[0].nodeValue);
- //_global.buttonURL.push(menuArray[i].childNodes[1].childNodes[0].nodeValue);
-
- //or chose to load in as attributes
- //_global.buttontext.push(this.firstChild.childNodes[i].attributes.BUTTONName);
- //_global.buttonURL.pushpush(this.firstChild.childNodes[i].attributes.BUTTONurl);
-
-
- } //Close Loop (2)
-
-
- gotoAndPlay("success"); /// if sucessful goto and play another frame where it makes the buttons
- } //Close function (1)
ok after successfully loading we are going to create a new instance of each button mc on stage and assign each new instance a new ylocation
do this on frame labelled success...
////////////////////////////////////// Function for creating buttons //////////////////////////////////////
_global.Heightofbutton = 100;
pushoverY = 0;
while(L<_global.numOfItems){//open loop (1)
this.attachMovie("button_mc", "button_mc" + L, (-L) , {_x:0 ,_y:pushoverY});
set("button_mc" + L + ".menuID" , L);
with (eval("button_mc" + L )){
button_txt = _global.team_member_name[L]; //where button_txt is the name of the variable in the button
}// end with evaluation
pushoverY = pushoverY + _global.Heightofbutton;
L=L+1;
} // closes loop (1)
-
- ////////////////////////////////////// Function for creating buttons //////////////////////////////////////
- _global.Heightofbutton = 100;
- pushoverY = 0;
- while(L<_global.numOfItems){//open loop (1)
- this.attachMovie("button_mc", "button_mc" + L, (-L) , {_x:0 ,_y:pushoverY});
- set("button_mc" + L + ".menuID" , L);
-
-
- with (eval("button_mc" + L )){
- button_txt = _global.team_member_name[L]; //where button_txt is the name of the variable in the button
-
-
- }// end with evaluation
-
- pushoverY = pushoverY + _global.Heightofbutton;
- L=L+1;
- } // closes loop (1)
ok the next thing is to assing some action script to your instance of your button. open/edit you button mc in the library
creat a new layer and create a box, convert to button but only assign it a hit area.
give the hit area an instance name of hitarea
next create a new layer for actionscript
LinkB= buttonURL[menuID]; //Link Value for Sub Menu - we assigned the menuID for each instance ni success on the main time line, buttonURL is the value from the xml file
buttonInstance._alpha = 100;
hitarea.onRollOver = function(){
buttonInstance._alpha = 50;
}
hitarea.onRollOut = function(){
buttonInstance._alpha = 100;
}
hitarea.onRelease = function(){
getURL(LinkB, "_blank");
//trace(LinkB);
}
- LinkB= buttonURL[menuID]; //Link Value for Sub Menu - we assigned the menuID for each instance ni success on the main time line, buttonURL is the value from the xml file
- buttonInstance._alpha = 100;
- hitarea.onRollOver = function(){
- buttonInstance._alpha = 50;
-
- }
- hitarea.onRollOut = function(){
- buttonInstance._alpha = 100;
- }
- hitarea.onRelease = function(){
- getURL(LinkB, "_blank");
- //trace(LinkB);
- }