2

我遇到了这个脚本的问题......除了点击之外,它的一切都在工作。这是一个二进制时钟,我想把灯调暗

package{
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
import com.greensock.*;
import com.greensock.easing.*;
import flash.events.TouchEvent;

public class Main extends MovieClip
{
    var clock:Timer=new Timer(1000);
    var date:Date=new Date();
    var hr:int;
    var min:int;
    var sec:int;
    var bits:Array;

    public function Main()
    {
        init();
        tvinnet.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
    }

    private function init():void
    {
        sec=date.getSeconds();
        min=date.getMinutes();
        hr=date.getHours();
        turnBits(converter(sec),'S');
        turnBits(converter(min),'M');
        turnBits(converter(hr),'H');
        clock.start();
        clock.addEventListener(TimerEvent.TIMER, setTime);

    }



    function fl_MouseOverHandler(e:MouseEvent):void
    {
            clock.alpha = 0;
    }




    private function setTime(e:TimerEvent):void
    {
        date=new Date();
        sec=date.getSeconds();
        min=date.getMinutes();
        hr=date.getHours();
        turnBits(converter(sec),'S');
        turnBits(converter(min),'M');
        turnBits(converter(hr),'H');
    }

    private function dec2bin(dec:int, length:int)
    {
        var bin:Array= new Array();
        while((dec/2)>0)
        {
            bin.push(dec%2);
            dec=dec/2;
        }
        while(bin.length<length) bin.push(0);
        return bin;
    }

    private function converter(num:int)
    {
        var st:String=String(num);
        if(st.length==1)st='0'+st;
        var fDigit:int=int(st.charAt(1));
        var sDigit:int=int(st.charAt(0));
        var fColumn:Array=dec2bin(fDigit,4);
        var sColumn:Array=dec2bin(sDigit,3);
        var result:Array=fColumn.concat(sColumn);
        return result;
    }

    private function turnBits(newBits:Array, target:String)
    {
        for(var a:int=0;a<newBits.length;a++)
        {
            if((a!=6)||(target!="H"))
            {
                if(newBits[a]==0) TweenMax.to(this.getChildByName(target+String(a)), 1, {glowFilter:{color:0x00cbff, alpha:0, blurX:15, blurY:15,strength:1},alpha:.1});
                else TweenMax.to(this.getChildByName(target+String(a)), 1, {glowFilter:{color:0x00cbff, alpha:1, blurX:20, blurY:20,strength:.8},alpha:1});
            }
        }
    }
}   

}

所以如果你很棒,你能在里面找到什么吗?

4

1 回答 1

2

您将时钟变量定义为 Timer,然后您尝试访问它在 Timer 中不可用的 alpha 属性。

function fl_MouseOverHandler(e:MouseEvent):void
    {
            clock.alpha = 0; //wrong approach, use this.alpha = 0;
    }
于 2012-06-18T22:07:10.577 回答