2012-06-18 61 views
2

我遇到了這個腳本的麻煩......除了點擊事件之外,其中的一切都在工作。這是我想對暗淡1119:通過引用與靜態類型flash.utils訪問可能未定義的屬性alpha:Timer。

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

}

光二進制時鐘所以,如果你真棒,你能找到任何東西?

回答

2

您將時鐘變量定義爲Timer,然後嘗試訪問定時器中不可用的alpha屬性。

function fl_MouseOverHandler(e:MouseEvent):void 
    { 
      clock.alpha = 0; //wrong approach, use this.alpha = 0; 
    } 
+0

偉大的:D謝謝,我根本沒有注意到這一點!!!:D再次感謝:D – Napoleon

+0

歡迎:) –

相關問題