简体   繁体   中英

Flash CS6, AS3 button issue

I'm using the code below to have button "legalBtn" access the layer and instance name of "legalOverlay." Then after the legalese has been read, the enduser can close the "legalOverlay" via "closeBtn" and return to the last frame of the banner ad. The code below has no compiler errors, but the "legalBtn" is still not working. Any ideas?

import flash.events.MouseEvent;

function init(){
    legalBtn.addEventListener(MouseEvent.CLICK, legalClick);
    legalBtn.visible=true;

    legalOverlay.clickthru.addEventListener(MouseEvent.CLICK);
    legalOverlay.clickthru.buttonMode=true;
    legalOverlay.closeBtn.addEventListener(MouseEvent.CLICK);
    legalOverlay.closeBtn.buttonMode=true;

    legalOverlay.visible=false;
}
    function legalClick(e:MouseEvent){
        if(legalOverlay.visible==true){
        legalOverlay.visible=false;
        } else {
        legalOverlay.visible=true;
        }
}

stop();

您必须调用init()函数以在您的legalBtn对象上添加click事件侦听器并使之可见。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM