2010-02-25 48 views
-1

它像金字塔,其中每個對象將有4個層下面有2個對象。幫助我總結這些腳本

if (myXML.MEMBER[1][email protected]=="NO") { 
      circlesArray[0][0].mouseEnabled=false; 
      TweenLite.to(circlesArray[0][0],0.8,{tint:0x333333}); 

      manArray[0][0].mouseEnabled=false; 
      TweenLite.to(manArray[0][0],0,{tint:0x666666}); 
     } else { 
      circlesArray[0][0].mouseEnabled=true; 
      manArray[0][0].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[2][email protected]=="NO") { 
      circlesArray[0][1].mouseEnabled=false; 
      TweenLite.to(circlesArray[0][1],0.8,{tint:0x333333}); 

      manArray[0][1].mouseEnabled=false; 
      TweenLite.to(manArray[0][1],0,{tint:0x666666}); 
     } else { 
      circlesArray[0][1].mouseEnabled=true; 
      manArray[0][1].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[3][email protected]=="NO") { 
      circlesArray[1][0].mouseEnabled=false; 
      TweenLite.to(circlesArray[1][0],0.8,{tint:0x333333}); 

      manArray[1][0].mouseEnabled=false; 
      TweenLite.to(manArray[1][0],0,{tint:0x666666}); 
     } else { 
      circlesArray[1][0].mouseEnabled=true; 
      manArray[1][0].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[4][email protected]=="NO") { 
      circlesArray[1][1].mouseEnabled=false; 
      TweenLite.to(circlesArray[1][1],0.8,{tint:0x333333}); 

      manArray[1][1].mouseEnabled=false; 
      TweenLite.to(manArray[1][1],0,{tint:0x666666}); 
     } else { 
      circlesArray[1][1].mouseEnabled=true; 
      manArray[1][1].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[5][email protected]=="NO") { 
      circlesArray[1][2].mouseEnabled=false; 
      TweenLite.to(circlesArray[1][2],0.8,{tint:0x333333}); 

      manArray[1][2].mouseEnabled=false; 
      TweenLite.to(manArray[1][2],0,{tint:0x666666}); 
     } else { 
      circlesArray[1][2].mouseEnabled=true; 
      manArray[1][2].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[6][email protected]=="NO") { 
      circlesArray[1][3].mouseEnabled=false; 
      TweenLite.to(circlesArray[1][3],0.8,{tint:0x333333}); 

      manArray[1][3].mouseEnabled=false; 
      TweenLite.to(manArray[1][3],0,{tint:0x666666}); 
     } else { 
      circlesArray[1][3].mouseEnabled=true; 
      manArray[1][3].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[7][email protected]=="NO") { 
      circlesArray[2][0].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][0],0.8,{tint:0x333333}); 

      manArray[2][0].mouseEnabled=false; 
      TweenLite.to(manArray[2][0],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][0].mouseEnabled=true; 
      manArray[2][0].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[8][email protected]=="NO") { 
      circlesArray[2][1].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][1],0.8,{tint:0x333333}); 

      manArray[2][1].mouseEnabled=false; 
      TweenLite.to(manArray[2][1],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][1].mouseEnabled=true; 
      manArray[2][1].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[9][email protected]=="NO") { 
      circlesArray[2][2].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][2],0.8,{tint:0x333333}); 

      manArray[2][2].mouseEnabled=false; 
      TweenLite.to(manArray[2][2],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][2].mouseEnabled=true; 
      manArray[2][2].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[10][email protected]=="NO") { 
      circlesArray[2][3].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][3],0.8,{tint:0x333333}); 

      manArray[2][3].mouseEnabled=false; 
      TweenLite.to(manArray[2][3],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][3].mouseEnabled=true; 
      manArray[2][3].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[11][email protected]=="NO") { 
      circlesArray[2][4].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][4],0.8,{tint:0x333333}); 

      manArray[2][4].mouseEnabled=false; 
      TweenLite.to(manArray[2][4],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][4].mouseEnabled=true; 
      manArray[2][4].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[12][email protected]=="NO") { 
      circlesArray[2][5].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][5],0.8,{tint:0x333333}); 

      manArray[2][5].mouseEnabled=false; 
      TweenLite.to(manArray[2][5],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][5].mouseEnabled=true; 
      manArray[2][5].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[13][email protected]=="NO") { 
      circlesArray[2][6].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][6],0.8,{tint:0x333333}); 

      manArray[2][6].mouseEnabled=false; 
      TweenLite.to(manArray[2][6],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][6].mouseEnabled=true; 
      manArray[2][6].mouseEnabled=true; 
     } 

     if (myXML.MEMBER[14][email protected]=="NO") { 
      circlesArray[2][7].mouseEnabled=false; 
      TweenLite.to(circlesArray[2][7],0.8,{tint:0x333333}); 

      manArray[2][7].mouseEnabled=false; 
      TweenLite.to(manArray[2][7],0,{tint:0x666666}); 
     } else { 
      circlesArray[2][7].mouseEnabled=true; 
      manArray[2][7].mouseEnabled=true; 
     } 

我已經試過,但它不工作

for (var i:uint=0; i<2; i++) { 
      for (var j:uint=0; j<2-1; j++) { 
       if (myXML.MEMBER[i][email protected]=="NO") { 
        circlesArray[1][j].mouseEnabled=false; 
        TweenLite.to(circlesArray[1][j],0.8,{tint:0x333333}); 
       } else { 
        circlesArray[1][j].mouseEnabled=true; 
       } 
      } 
     } 
+0

它根本不編譯,還是編譯但沒有顯示所需的輸出? 請稍微介紹一下,或許我們可以幫助。 – Ashine 2010-02-25 08:12:51

回答

0

好,首先,第一循環應該遍歷myXML.MEMBER.length(),你有辦法它成立了,不會涵蓋你所有的成員。

以下可能是錯誤的,因爲我無法測試它,因爲您的場景不容易重新創建。但是,背後的邏輯應該很容易糾正,使其工作。也許你應該檢查一下,看看你是否正在訪問數組中的有效項目和類似的東西。

var t:int = myXML.MEMBER.length(); 
var ii:int; 
var jj:int; 

for(var i:int = 0; i < t; i++) { 
    ii = circlesArray.length; 
    for (var ci:int = 0; ci < ii; ci++) { 
     jj = circlesArray[ci].length;  
     for (var cj:int = 0; cj < jj; cj++) { 
      if (myXML.MEMBER[i][email protected]=="NO") { 
       circlesArray[ci][cj].mouseEnabled=false; 
       TweenLite.to(circlesArray[ci][cj],0.8,{tint:0x333333}); 
       manArray[ci][cj].mouseEnabled=false; 
       TweenLite.to(manArray[ci][cj],0,{tint:0x666666}); 
      } else { 
       circlesArray[ci][cj].mouseEnabled=true; 
       manArray[ci][cj].mouseEnabled=true; 
      } 
     } 

    } 
}