开发者

flash AS3 and _currentframe

开发者 https://www.devze.com 2023-02-11 02:56 出处:网络
Alright I\'ll try to explain my problem.Thanks for helping Simsoft.Frame 1 has 9 buttons with rollovers,outs, and clicks.When a user clicks any of the buttons, the timeline jumps to frame 2, there is

Alright I'll try to explain my problem. Thanks for helping Simsoft. Frame 1 has 9 buttons with rollovers,outs, and clicks. When a user clicks any of the buttons, the timeline jumps to frame 2, there is a transition away from that intro-menu and a new, more permanent menu appears. By this point we are at frame 10. Now I can use this new menu no problem - the problem is using the first menu. I need the first menu to jump to frame 2, do the exit-transition (frames 2-10), then, when it hits frame 10, go to whichever frames corresponds with the button the user clicked. So here is the code for frame 1:

stop();

 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.addEventList开发者_StackOverflow中文版ener(MouseEvent.CLICK, clickCommand);

Here is the code at frame 10 (using the new buttons called '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);

}
 }

I had the idea to simply write have the first menu fade alpha to zero, then jump to the corresponding frame, which worked, but my second,main set of buttons' rollovers,outs and clicks just stopped working. Wow this isn't easy to explain! Anyways, I do appreciate you taking the time to help me.


Try something like this:

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);
    }
}


You can add a listener on ENTER_FRAME event.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号