Degrafa 新手在这里:-)。
我能够获得“com.degrafa.skins.CSSSkin”来创建线性渐变背景。现在我正在研究更高级的东西,因为我试图找出径向渐变......
我通过观看Flex-skinning-with-degrafa-screencast发现了这一点,但我的代码对我不起作用,而且我的画布上出现了白色背景。
这是我到目前为止的代码:
我有一个 MXML 组件 ThreeWayGrad.mxml,它扩展了 Canvas 并具有 ThreeWayGradient 的 styleName:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas
xmlns:mx="http://www.adobe.com/2006/mxml"
styleName="ThreeWayGradient"/>
我有一个 ThreeWayGradient 的 CSS 样式条目,带有 RadialGradient 类的皮肤标签:
Canvas.ThreeWayGradient
{
borderSkin: ClassReference("assets.skins.RadialGradient");
}
最后是 RadialGradient.mxml 组件:
<?xml version="1.0" encoding="utf-8"?>
<GraphicBorderSkin
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="http://www.degrafa.com/2007">
<mx:Script>
<![CDATA[
[Bindable] private var _height:Number = 0;
[Bindable] private var _width:Number = 0;
override protected
function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);
_height = h;
_width = w;
trace("INFO: displaylist updated --" + _height + " : " + _width );
}
]]>
</mx:Script>
<strokes>
<SolidStroke id="mainStroke" color="#333333" weight="3"/>
</strokes>
<fills>
<RadialGradientFill
id="blueGradient"
angle="45"
focalPointRatio="0">
<GradientStop
alpha="1"
ratio=".25"
color="#ffffff"/>
<GradientStop
alpha="1"
ratio=".70"
color="#003355"/>
<GradientStop
alpha="1"
ratio="1"
color="#111111"/>
</RadialGradientFill>
</fills>
<!-- Creating the background -->
<geometry>
<GeometryComposition>
<!-- Creating a Rectangle to draw the gradient to and
moving the center of the gradient to the lower left corner -->
<RegularRectangle
fill="{blueGradient}"
stroke="{mainStroke}"
height="{_height}"
width="{_width}"
/>
</GeometryComposition>
</geometry>
</GraphicBorderSkin>
有谁知道为什么这不起作用?我看到了正确大小的跟踪输出,所以我知道这个类被调用了。
我还使用 Surface 而不是 GraphicBorderSkin 元素和 GeometryGroup 而不是 GeometryComposition 将此代码复制到一个新的应用程序中,并且它可以工作。无论如何,我确定我错过了一些简单的东西,提前谢谢!!!