2010-03-19 76 views
0

我正試圖學習如何使用actionscript over mxml來獲得靈活性。我有MXML,我試圖將轉換爲動作的這個簡單的塊,但我雖然將mxml Rect&SolidColor轉換爲actionscript

<s:Rect id="theRect" x="0" y="50" width="15%" height="15%"> 
    <s:fill> 
     <s:SolidColor color="black" alpha="0.9" /> 
    </s:fill> 
</s:Rect> 

我可以轉換的矩形沒有問題

private var theRect:Rect = new Rect(); 
theRect.x = 0; 
theRect.y = 50; 
theRect.width = "15%"; 
theRect.height = "15%"; 

然後我被卡住了一半米卡在填充。儘可能在幾行代碼中添加SolidColor的最有效方法是什麼?

回答

5

這應該工作:

private var theRect:Rect = new Rect(); 
theRect.x = 0; 
theRect.y = 50; 
theRect.width = "15%"; 
theRect.height = "15%"; 
theRect.fill = new SolidColor(0x000000, 0.9); 

屬性在MXML(<fill>)只是在Actionscript中點綴性質,和值是接下來會發生什麼,所以它不是太糟糕了。

希望幫助, 蘭斯

+0

沒辦法,那簡單嗎?謝謝:) – touB 2010-03-19 05:48:15

+0

我知道,我有時候也是這樣。沒問題。 – 2010-03-19 05:50:16

1

你本可以自動完成,通過使用保存生成的ActionScript文件的編譯器標誌。請參閱article瞭解如何使用它。