flex fill rect with many colors and rotation 45 degrees

时间:2013-12-17 08:46:45

标签: flex colors fill rect

有没有办法填充s:Rect有3-4种不同的颜色和旋转45度?类似的东西:

    <s:fill>
        <s:SolidColor  color="#ff0000" />
        <s:SolidColor  color="#00ff00" />
        <s:SolidColor  color="#ffff00" />
    </s:fill>

2 个答案:

答案 0 :(得分:1)

使用LinearGradient作为fill属性,如下所示:

<s:Rect left="0" right="0" top="0" bottom="0">
    <s:fill>
        <s:LinearGradient rotation="45">
            <s:GradientEntry color="#ff0000" />
            <s:GradientEntry color="#00ff00" />
            <s:GradientEntry color="#ffff00" />
        </s:LinearGradient>
    </s:fill>
</s:Rect>

答案 1 :(得分:0)

你希望在mxml中使用@RIA star是正确的,但是如果你想在动作脚本中这里是代码。它很长但你可以减少它

protected function box1_mouseOverHandler(event:MouseEvent):void
        {
            if(event.currentTarget!=null)
            {
                if(event.type == MouseEvent.MOUSE_OVER)
                {
                    var fill:LinearGradient = new LinearGradient();

                    var g1:GradientEntry = new GradientEntry(0xE7E7E7);
                    var g2:GradientEntry = new GradientEntry(0xFDFDFD);

                    fill.entries = [g1,g2];
                    fill.rotation = 45;
                    event.currentTarget.backgroundFill = fill;
                    Mouse.cursor = MouseCursor.BUTTON;
                }
                else
                {
                    var fill1:LinearGradient = new LinearGradient();

                    var g3:GradientEntry = new GradientEntry(0xFDFDFD);
                    var g4:GradientEntry = new GradientEntry(0xE7E7E7);

                    fill1.entries = [g3,g4];
                    fill1.rotation = 45;
                    event.currentTarget.backgroundFill = fill1;
                    Mouse.cursor = MouseCursor.AUTO;
                }
            }
        }