我正在使用AS2构建的闪存菜单。它按照预期执行:如果单击菜单中的按钮,此按钮将进入选定状态,最重要的是,此按钮仅在释放另一个按钮时淡出。你可以在这里看到演示:
http://activeden.net/item/buttons-section-selected/6100
它适用于此代码:**
//SET STAGE
Stage.scaleMode = "noScale"
//SET BUTTONS TEXT (Here you can change the buttons name)
b1.MC_btnTxt.TXT.text = "Button 1";
b2.MC_btnTxt.TXT.text = "Button 2";
b3.MC_btnTxt.TXT.text = "Button 3";
b4.MC_btnTxt.TXT.text = "Button 4";
b5.MC_btnTxt.TXT.text = "Button 5";
/*CREATE THE BUTTONS ARRAY(if you wanna add or delete
buttons you have to ad or delete the istance button name from the list*/
var myArray = [b1,b2,b3,b4,b5];
//CREATE FUNCTIONS FOR THE BUTTONS ANIMATION
function overBtn (){
for (j=0; j<myArray.length; j++) {
myArray[j].onRollOver = function(){
this.gotoAndPlay(2);
}
myArray[j].onRollOut = function(){
this.gotoAndPlay("fadeOut");
}
}
}
function releaseStatus() {
for (a=0; a<myArray.length; a++) {
myArray[a].enabled = false;
}
deselection();
}
function deselection() {
for (b=0; b<myArray.length; b++) {
if (b<>selectedBtn) {
myArray[b].enabled = true;
if(myArray[b]._currentframe==32)
myArray[b].gotoAndPlay("selectionFadeOut");
}
}
}
// SET BUTTONS
b1.onRelease = function() {
sectionTXT.text = "Section 1"
selectedBtn = 0;
releaseStatus();
this.gotoAndPlay("selectionFadeIn");
}
b2.onRelease = function() {
sectionTXT.text = "Section 2"
selectedBtn = 1;
releaseStatus();
this.gotoAndPlay("selectionFadeIn");
}
b3.onRelease = function() {
sectionTXT.text = "Section 3"
selectedBtn = 2;
releaseStatus();
this.gotoAndPlay("selectionFadeIn");
}
b4.onRelease = function() {
sectionTXT.text = "Section 4"
selectedBtn = 3;
releaseStatus();
this.gotoAndPlay("selectionFadeIn");
}
b5.onRelease = function() {
sectionTXT.text = "Section 5"
selectedBtn = 4;
releaseStatus();
this.gotoAndPlay("selectionFadeIn");
}
//INIT INTERFACE
overBtn();
问题是,如果你想在按钮内添加一个按钮(b1,b2,b3 ......),内部按钮不起作用。例如:下面的代码不适用于其中一个主按钮(b5)内的按钮。
b5.ex .onRelease = function ()
{
this.gotoAndStop("selectionInnerButton");
}
;
我的问题是:为了使内部按钮正常工作,我应该在代码中更改什么?
谢谢!
答案 0 :(得分:0)
第1步:进入按钮。
步骤2:右键单击子按钮
第3步:为它创建一个onclick函数(this.onRelease = function()
)
第4步:在构造代码中,访问子按钮的parent
,并告诉它像您一直那样转到selectionInnerButton
框架:_parent.gotoAndStop('selectionInnerButton')
< / p>
你去吧。但是,您当前的代码出了什么问题,我发现您说this.gotoAndStop
让我相信您在按钮中,因此函数应为this.ex.onRelease = function()
。