2010-03-19 33 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了解如何使用它。