Css 如何在flex中创建垂直渐变

Css 如何在flex中创建垂直渐变,css,apache-flex,actionscript-3,Css,Apache Flex,Actionscript 3,如何在flex中创建垂直渐变 我现在有一个水平的颜色渐变。它工作得很好。但我不知道该如何使它垂直(当然这是要求) 我使用styleName=“chatWindowLeftGradient” 样式表如下所示: <mx:Style> .chatWindowLeftGradient{ backgroundImage: ClassReference("custom.GradientBackground

如何在flex中创建垂直渐变

我现在有一个水平的颜色渐变。它工作得很好。但我不知道该如何使它垂直(当然这是要求)

我使用styleName=“chatWindowLeftGradient”


样式表如下所示:

<mx:Style>
        .chatWindowLeftGradient{                        
            backgroundImage: ClassReference("custom.GradientBackground");
            backgroundSize: "100%";
            fillColors: #6db263, #a4d9a1;
            fillAlphas: 1, 1;                           
        }

    </mx:Style>
<s:Rect right="0" top="0" width="170" bottom="0">
    <s:fill>
        <mx:LinearGradient rotation="90">
            <mx:entries>
                <mx:GradientEntry color="#64574A"/>
                <mx:GradientEntry color="#FFFFCC"/>
            </mx:entries>
        </mx:LinearGradient>
    </s:fill>
</s:Rect>

.chatWindowLeftGradient{
背景图片:ClassReference(“custom.GradientBackground”);
背景尺寸:“100%”;
填充颜色:#6db263,#a4d9a1;
结果:1,1;
}
这将提供从上到下的渐变。我怎样才能从左到右

问候
Zeeshan

您可以通过编程皮肤来实现

  • 创建从Border继承的新类
  • 使用以下内容覆盖updateDisplayList:

    <mx:Style>
            .chatWindowLeftGradient{                        
                backgroundImage: ClassReference("custom.GradientBackground");
                backgroundSize: "100%";
                fillColors: #6db263, #a4d9a1;
                fillAlphas: 1, 1;                           
            }
    
        </mx:Style>
    
    <s:Rect right="0" top="0" width="170" bottom="0">
        <s:fill>
            <mx:LinearGradient rotation="90">
                <mx:entries>
                    <mx:GradientEntry color="#64574A"/>
                    <mx:GradientEntry color="#FFFFCC"/>
                </mx:entries>
            </mx:LinearGradient>
        </s:fill>
    </s:Rect>
    
    super.updateDisplayList(w,h)
    var g:Graphics=this.Graphics

    g、 清除()

    var m:矩阵=新矩阵(); m、 createGradientBox(w,h); g、 线型(0,0,0); g、 beginGradientFill(渐变型线性,[color1,color2],[alpha1,alpha2],[0,0xFF],m); g、 drawRect(0,0,w,h); g、 endFill()

  • 使用样式部分中的ClassReference将该类引用为皮肤


  • 您可以使用编程皮肤来实现

  • 创建从Border继承的新类
  • 使用以下内容覆盖updateDisplayList:

    <mx:Style>
            .chatWindowLeftGradient{                        
                backgroundImage: ClassReference("custom.GradientBackground");
                backgroundSize: "100%";
                fillColors: #6db263, #a4d9a1;
                fillAlphas: 1, 1;                           
            }
    
        </mx:Style>
    
    <s:Rect right="0" top="0" width="170" bottom="0">
        <s:fill>
            <mx:LinearGradient rotation="90">
                <mx:entries>
                    <mx:GradientEntry color="#64574A"/>
                    <mx:GradientEntry color="#FFFFCC"/>
                </mx:entries>
            </mx:LinearGradient>
        </s:fill>
    </s:Rect>
    
    super.updateDisplayList(w,h)
    var g:Graphics=this.Graphics

    g、 清除()

    var m:矩阵=新矩阵(); m、 createGradientBox(w,h); g、 线型(0,0,0); g、 beginGradientFill(渐变型线性,[color1,color2],[alpha1,alpha2],[0,0xFF],m); g、 drawRect(0,0,w,h); g、 endFill()

  • 使用样式部分中的ClassReference将该类引用为皮肤


  • 这不仅仅是插入css,Flex 4 mxml中的垂直渐变如下所示:

    <mx:Style>
            .chatWindowLeftGradient{                        
                backgroundImage: ClassReference("custom.GradientBackground");
                backgroundSize: "100%";
                fillColors: #6db263, #a4d9a1;
                fillAlphas: 1, 1;                           
            }
    
        </mx:Style>
    
    <s:Rect right="0" top="0" width="170" bottom="0">
        <s:fill>
            <mx:LinearGradient rotation="90">
                <mx:entries>
                    <mx:GradientEntry color="#64574A"/>
                    <mx:GradientEntry color="#FFFFCC"/>
                </mx:entries>
            </mx:LinearGradient>
        </s:fill>
    </s:Rect>
    
    
    

    您是否尝试过在样式中添加旋转=“90”?

    这不仅仅是插入css,Flex 4 mxml中的垂直渐变如下所示:

    <mx:Style>
            .chatWindowLeftGradient{                        
                backgroundImage: ClassReference("custom.GradientBackground");
                backgroundSize: "100%";
                fillColors: #6db263, #a4d9a1;
                fillAlphas: 1, 1;                           
            }
    
        </mx:Style>
    
    <s:Rect right="0" top="0" width="170" bottom="0">
        <s:fill>
            <mx:LinearGradient rotation="90">
                <mx:entries>
                    <mx:GradientEntry color="#64574A"/>
                    <mx:GradientEntry color="#FFFFCC"/>
                </mx:entries>
            </mx:LinearGradient>
        </s:fill>
    </s:Rect>
    
    
    

    您是否尝试过在样式中添加rotation=“90”?

    在Flex 3中,向元素应用渐变的最简单方法是使用Degrafa及其优秀的CSSSkin类。这里有一些很好的灵活性示例:

    在Flex3中,向元素应用渐变的最简单方法是使用Degrafa及其优秀的CSSSkin类。其灵活性的一些好例子如下: