Hi
I have a scrollpane and I load a movieclip from library using Scroll Content parameter. No problem.
The problem is inside the the movieclip I load.
I want to load a lot of buttons/movieclips and then dynamically set up text, onRelease and more. But I can't make it work. You can see the code I want to use in the for-loop:
Because it does not work I code it testing if the buttons/movieclips exists and then set them up. Then it is working. Only problem is that the screen don't refresh first. I must find the code for refreshing the pane?
OK here is the code. If you have suggestion please answer me with specific help.
Thanks
AS - Code:
menuXml = new XML();
//menuXml._parent=this;
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
if (success) {
menuItem = new Array();
menuItem = this.firstChild.childNodes;
knap1_mc0._x+=2.5;
knap1_mc0._y+=2;
knap1_mc0.text_txt.text=menuItem[0].attributes.name;;
knap1_mc0.sub_btn.onRollOver=function() {
knap1_mc0.menu_mc.gotoAndPlay("over");
};
knap1_mc0.sub_btn.onRollOut=function() {
knap1_mc0.menu_mc.gotoAndPlay("out");
};
knap1_mc0.sub_btn.onRelease=function() {
getURL(menuItem[0].attributes.url,"_blank");
};
//I=5;
//knap1_mc0.duplicateMovieClip("knap1_mc"+i);
//knap1_mc5._x=knap1_mc0._x;
//knap1_mc5._y=knap1_mc0._y+23;
//we accept 10 subbuttons no more
if (menuItem.length>1) {
for (var i=1; i<menuItem.length; i++) {
//duplicate button knap1_mc and put release code on
knap1_mc0.duplicateMovieClip("knap1_mc"+i,i);
//here is code I want to have to work!!!!!!!!!!!
//this["knap1_mc"+i]._x=knap1_mc0._x;
//this["knap1_mc"+i]._y=knap1_mc0._y+(23*1);
//this["knap1_mc"+i].text_txt.text=menuItem.attributes.name;
//this["knap1_mc"+i].onRollOver=function() {
// this["knap1_mc"+i].gotoAndPlay("over");
//};
//and so on for other functions - what is wrong?
}//end for
if (knap1_mc1 != null) {
knap1_mc1._x=knap1_mc0._x;
knap1_mc1._y=knap1_mc0._y+(23*1);
knap1_mc1.text_txt.text=menuItem[1].attributes.name;
knap1_mc1.sub_btn.onRollOver=function() {
knap1_mc1.menu_mc.gotoAndPlay("over");
};
knap1_mc1.sub_btn.onRollOut=function() {
knap1_mc1.menu_mc.gotoAndPlay("out");
};
knap1_mc1.sub_btn.onRelease=function() {
getURL(menuItem[1].attributes.url,"_blank");
};
if (knap1_mc2 != null) {
knap1_mc2._x=knap1_mc0._x;
knap1_mc2._y=knap1_mc0._y+(23*2);
knap1_mc2.text_txt.text=menuItem[2].attributes.name;
knap1_mc2.sub_btn.onRollOver=function() {
knap1_mc2.menu_mc.gotoAndPlay("over");
};
knap1_mc2.sub_btn.onRollOut=function() {
knap1_mc2.menu_mc.gotoAndPlay("out");
};
knap1_mc2.sub_btn.onRelease=function() {
getURL(menuItem[2].attributes.url,"_blank");
};
if (knap1_mc3 != null) {
knap1_mc3._x=knap1_mc0._x;
knap1_mc3._y=knap1_mc0._y+(23*3);
knap1_mc3.text_txt.text=menuItem[3].attributes.name;
knap1_mc3.sub_btn.onRollOver=function() {
knap1_mc3.menu_mc.gotoAndPlay("over");
};
knap1_mc3.sub_btn.onRollOut=function() {
knap1_mc3.menu_mc.gotoAndPlay("out");
};
knap1_mc3.sub_btn.onRelease=function() {
getURL(menuItem[3].attributes.url,"_blank");
};
if (knap1_mc4 != null) {
knap1_mc4._x=knap1_mc0._x;
knap1_mc4._y=knap1_mc0._y+(23*4);
knap1_mc4.text_txt.text=menuItem[4].attributes.name;
knap1_mc4.sub_btn.onRollOver=function() {
knap1_mc4.menu_mc.gotoAndPlay("over");
};
knap1_mc4.sub_btn.onRollOut=function() {
knap1_mc4.menu_mc.gotoAndPlay("out");
};
knap1_mc4.sub_btn.onRelease=function() {
getURL(menuItem[4].attributes.url,"_blank");
};
if (knap1_mc5 != null) {
knap1_mc5._x=knap1_mc0._x;
knap1_mc5._y=knap1_mc0._y+(23*5);
knap1_mc5.text_txt.text=menuItem[5].attributes.name;
knap1_mc5.sub_btn.onRollOver=function() {
knap1_mc5.menu_mc.gotoAndPlay("over");
};
knap1_mc5.sub_btn.onRollOut=function() {
knap1_mc5.menu_mc.gotoAndPlay("out");
};
knap1_mc5.sub_btn.onRelease=function() {
getURL(menuItem[5].attributes.url,"_blank");
};
}//end if knap1_mc5
}//end if knap1_mc4
}//end if knap1_mc3
}//end if knap1_mc2
}//end if knap1_mc1
}//end if menuItem.length>1
}else {//else not success
knap1_mc._visible=false;
}
}
menuXml.load("menuknap5.xml");//load xml or php page
stop();