如何申请行动,多张闪光层 [英] How to apply action to mulitple flash layers

查看:133
本文介绍了如何申请行动,多张闪光层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5层,每个符号:A,B,C,D和E。 我试图找出如何操作波纹管适用于A,C,D和E,当你将鼠标悬停乙级以上。

I have 5 layers with symbols on each: a, b, c, d and e. I am trying to work out how to apply the action bellow to a, c, d and e when you hover over b.

也有类似的gotoAndStop(0)其它操作;而不是立即去框0,它可以追溯到它来时的路?

Also is there another action similar to ' gotoAndStop(0); ' that instead of going immediately to frame 0 it goes back the way it came?

链接到.FLA HTTP:// WWW。 fileden.com/files/2012/11/27/3370853/Untitled-2.fla

stop();

stage.addEventListener(MouseEvent.MOUSE_OVER, playMovie); function playMovie(event) { play(); }
stage.addEventListener(MouseEvent.MOUSE_OUT, stopMovie); function stopMovie(event) { gotoAndStop(0); }


stop();

感谢

推荐答案

修改

在看着你的根,这里是缺少/错位的:

After looking at your .fla, here is what is missing/misplaced:

  1. 图层闪光灯并不意味着以外的任何z顺序/深度。你不能操纵层code。你所有的动画都是一样的时间轴上,所以他们会经常一起玩。如果你想要一个单独的项目没有其他动画,你必须做的动画在它自己的时间安排(不只是它的唯一层)。您可以通过双击它访问你的符号自己的时间安排 - 做你的动画有

  1. Layers in flash don't mean anything other than z-order/depth. You cannot manipulate a layer in code. All your animations are on the same timeline, so they will always play together. If you want an individual item to animate without the others, you'll have to do the animation on it's own timeline (not just it's only layer). You access your symbols own timeline by double clicking it - do your animation in there.

要引用是在舞台上,你需要给他们一个实例名称的项目。你可以通过点击这是在舞台上,然后在属性面板中的项目,有场在那里你可以把一个实例名称。对于下面的工作code,你需要分别给他们的A,B,C,D,E的实例名称。这比库中的符号名不同(尽管它可能是相同的名称)。

To reference items that are on the stage, you need to give them an instance name. You do that by clicking on the item that's on the stage, then in properties panel, there is field where you can put in an instance name. For the code below to work, you'd need to give them an instance name of "a","b","c","d","e" respectively. This is different than the symbol name in your library (though it can be the same name).

您可以做到这一点的方法之一:


One way you could do this:

var btns:Vector.<MovieClip> = new Vector.<MovieClip>(); //create an array of all your buttons
btns.push(a,b,c,d,e); //add your buttons to the array

for each(var btn:MovieClip in btns){
    btn.addEventListener(MouseEvent.MOUSE_OVER, btnMouseOver);  // listen for mouse over on each of the buttons
    btn.addEventListener(MouseEvent.MOUSE_OUT, btnMouseOut);
}

function btnMouseOver(e:Event):void {
    for each(var btn:MovieClip in btns){ //loop through all your buttons
        if(btn != e.currentTarget){ //if the current one in the loop isn't the one that was clicked
            btn.play();

            try{
                btn.removeEventListener(Event.ENTER_FRAME,moveBackwards); //this will stop the backwards animation if running.  it's in a try block because it will error if not running
            }catch(err:Error){};
        }
    }
}

function btnMouseOut(e:Event):void {
    for each(var btn:MovieClip in btns){ //loop through all your buttons
        if(btn != e.currentTarget){ //if the current one in the loop isn't the one that was clicked
            goBackwards(btn);
        }
    }
}

有没有好的办法向后播放一个时间表,但有办法做到这一点。一个这样的方式:

There is no nice way to play a timeline backwards, but there are ways to do it. One such way:

//a function you can call and pass in the item/timeline you want played backwards
function goBackwards(item:MovieClip):void {
    item.stop(); //make sure the item isn't playing before starting frame handler below
    item.addEventListener(Event.ENTER_FRAME, moveBackwards); //add a frame handler that will run the moveBackwards function once every frame
}

//this function will move something one frame back everytime it's called
function moveBackwards(e:Event):void {
    var m:MovieClip = e.currentTarget as MovieClip; //get the movie clip that fired the event
    if(m.currentFrame > 1){ //check to see if it's already back to the start
        m.prevFrame();  //if not move it one frame back
    }else{
        m.removeEventListener(Event.ENTER_FRAME,moveBackwards); //if it is (at the start), remove the enter frame listener so this function doesn't run anymore
    }
}

这篇关于如何申请行动,多张闪光层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆