开发者

Assigning links to buttons - All on same layer

I have a fla/swf file, with 6 buttons on i开发者_运维知识库t all with their own hover effects and such, however they're all on the same layer. So assigning a link to each one through actionscript is confusing as I've only done it if they were on different layers.

Any advice as to how to achieve this? (Using Flash cs4)


In general it does not make any difference if they are on the same layer or not. You have to assign a instance name to every button(e.g. "button01" and "button02" and then you can differentiate between them like:

function init():void {
    button01.addEventListener(MouseEvent.MOUSE_CLICK,onActionPerformed,false,0,true);
    button01.addEventListener(MouseEvent.MOUSE_CLICK,onActionPerformed,false,0,true);
}

function onActionPerformed(e:MouseEvent):void {
    switch(e.currentTarget) {
       case button01: navigateToUrl(/*put your link in here*/); break;
       case button02: navigateToUrl(/*Put another link in here*/); break;
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜