0

好吧,我会尝试解释我的问题。感谢您帮助 Simsoft。第 1 帧有 9 个按钮,包括翻转、输出和点击。当用户单击任何按钮时,时间线会跳转到第 2 帧,从该介绍菜单过渡,并出现一个新的、更永久的菜单。至此,我们位于第 10 帧。现在我可以毫无问题地使用这个新菜单 - 问题在于使用第一个菜单。我需要第一个菜单跳转到第 2 帧,执行退出转换(第 2-10 帧),然后,当它到达第 10 帧时,转到与用户单击的按钮对应的任何帧。所以这是第 1 帧的代码:

停止();

 function rollOverCommand(event:MouseEvent):void{
 if(event.target.name == "button1"){
    event.target.gotoAndPlay(2);

}
if(event.target.name == "button2"){
    event.target.gotoAndPlay(2);
}
if(event.target.name == "button3"){
    event.target.gotoAndPlay(2);
}
if(event.target.name == "button4"){
    event.target.gotoAndPlay(2);
}
    if(event.target.name == "button5"){
    event.target.gotoAndPlay(2);
}
    if(event.target.name == "button6"){
    event.target.gotoAndPlay(2);
}
    if(event.target.name == "button7"){
    event.target.gotoAndPlay(2);
}
    if(event.target.name == "button8"){
    event.target.gotoAndPlay(2);
}
    if(event.target.name == "button9"){
    event.target.gotoAndPlay(2);
}
}



container.addEventListener(MouseEvent.MOUSE_OVER, rollOverCommand);

function rollOutCommand(event:MouseEvent):void{
if(event.target.name == "button1"){
    event.target.gotoAndPlay(11);
}
if(event.target.name == "button2"){
    event.target.gotoAndPlay(11);
}
if(event.target.name == "button3"){
    event.target.gotoAndPlay(11);
}
if(event.target.name == "button4"){
    event.target.gotoAndPlay(11);
}
    if(event.target.name == "button5"){
    event.target.gotoAndPlay(11);
}
    if(event.target.name == "button6"){
    event.target.gotoAndPlay(11);
}
    if(event.target.name == "button7"){
    event.target.gotoAndPlay(11);
}
    if(event.target.name == "button8"){
    event.target.gotoAndPlay(11);
}
    if(event.target.name == "button9"){
    event.target.gotoAndPlay(11);
}
 }
 container.addEventListener(MouseEvent.MOUSE_OUT, rollOutCommand);



 function clickCommand(event:MouseEvent):void{
    if(event.target.name ==   "button1","button2","button3","button4","button5","button6","button7","button8","button9"){
    gotoAndPlay(2);
}
 }
 container.addEventListener(MouseEvent.CLICK, clickCommand);

这是第 10 帧的代码(使用名为“main”的新按钮) stop();

 container2.addEventListener(MouseEvent.CLICK, clickCommand2);

 function clickCommand2(event:MouseEvent):void
 {
if (event.target.parent.name == "main1")
{

    event.target.root.gotoAndPlay(1);
    trace(event.target.parent.name);
}
else if (event.target.parent.name == "main2")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(13);
}
else if (event.target.parent.name == "main3")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(14);
}
else if (event.target.parent.name == "main4")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(15);
}
else if (event.target.parent.name == "main5")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(16);
}
else if (event.target.parent.name == "main6")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(17);
}
else if (event.target.parent.name == "main7")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(18);
}
else if (event.target.parent.name == "main8")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(19);
}
else if (event.target.parent.name == "main9")
{
    trace(event.target.parent.name);
    event.target.root.gotoAndStop(20);
}
 }











 container2.addEventListener(MouseEvent.MOUSE_OVER, rollOverCommand2);

 function rollOverCommand2(event:MouseEvent):void
 {
if (event.target.name ==    "main1","main2","main3","main4","main5","main6","main7","main8","main9")
{

    event.target.parent.gotoAndPlay(16);

}
 }




 container2.addEventListener(MouseEvent.MOUSE_OUT, rollOutCommand2);

 function rollOutCommand2(event:MouseEvent):void
{
if (event.target.name ==    "main1","main2","main3","main4","main5","main6","main7","main8","main9")
{

    event.target.parent.gotoAndPlay(21);

}
 }

我的想法是简单地编写让第一个菜单将 alpha 渐变为零,然后跳转到相应的框架,这有效,但我的第二个,主要按钮集的翻转、退出和点击停止工作。哇,这不容易解释!无论如何,我很感谢你抽出时间来帮助我。

4

2 回答 2

0

您可以在 ENTER_FRAME 事件上添加侦听器。

于 2011-02-15T13:47:37.810 回答
0

尝试这样的事情:

var clickedButton : String;

function clickCommand(event:MouseEvent):void{
    stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    clickedButton = event.target.name;
    gotoAndPlay(2);
}

function onEnterFrame(e:Event) : void
{
    if(currentFrame == 12)
    {
        switch(clickedButton)
        {
            case "button1":
                gotoAndStop(13);
                break;
            case "button2":
                gotoAndStop(14);
                break;
        }

        removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
}

于 2011-02-15T14:23:55.647 回答