Apache flex 如何从火花中走出来

Apache flex 如何从火花中走出来,apache-flex,flex3,flex4,Apache Flex,Flex3,Flex4,我在试着翻译这段直线 <s:LinearGradient rotation="90" scaleX="44.2931" x="10.294" y="-0.276" > <s:GradientEntry color="#FFD500" ratio="0"/> <s:GradientEntry color="#F5A106" ratio="1"/> </s:LinearGradient> 但我不确定这是否正确,也不知道盒子的大小(上面

我在试着翻译这段直线

<s:LinearGradient rotation="90" scaleX="44.2931" x="10.294" y="-0.276" >
    <s:GradientEntry color="#FFD500" ratio="0"/>
    <s:GradientEntry color="#F5A106" ratio="1"/>
</s:LinearGradient>
但我不确定这是否正确,也不知道盒子的大小(上面代码中的两个20只是我在尝试的东西)。会喜欢任何专家的意见

<s:LinearGradient rotation="90" scaleX="44.2931" x="10.294" y="-0.276" >
    <s:GradientEntry color="#FFD500" ratio="0"/>
    <s:GradientEntry color="#F5A106" ratio="1"/>
</s:LinearGradient>

谢谢大家!

此示例可以说明如何绘制与
s:LinearGradient
中相同的填充:

<s:LinearGradient rotation="90" scaleX="44.2931" x="10.294" y="-0.276" >
    <s:GradientEntry color="#FFD500" ratio="0"/>
    <s:GradientEntry color="#F5A106" ratio="1"/>
</s:LinearGradient>
<?xml version="1.0" encoding="utf-8"?>
<s:Application creationComplete="init()" xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script>
    <![CDATA[
        public static const GRADIENT_DIMENSION:Number = 1638.4;

        private static const GRADIENT_SCALE_X:Number = 44.2931;
        private static const GRADIENT_X:Number = 10.294;
        private static const GRADIENT_Y:Number = 0.276;
        private static const ROTATION_DEGREES:Number = 90;

        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            var g:Graphics = drawingTarget.graphics;
            g.clear();
            var matrix:Matrix = getMatrix(ROTATION_DEGREES, GRADIENT_X, -GRADIENT_Y, GRADIENT_SCALE_X);
            g.beginGradientFill(GradientType.LINEAR, [ 0xFFD500, 0xF5A106 ], [ 1, 1 ], [ 0, 255 ], matrix);
            g.drawRect(0, 0, drawingTarget.width, drawingTarget.height);
            g.endFill();
        }

        private function getMatrix(rotationDegrees:Number, x:Number, y:Number, scaleX:Number = 1):Matrix
        {
            var commonMatrix:Matrix = new Matrix();
            commonMatrix.translate(GRADIENT_DIMENSION / 2, GRADIENT_DIMENSION / 2);
            commonMatrix.scale(1 / GRADIENT_DIMENSION, 1 / GRADIENT_DIMENSION);
            var compoundTransform:Matrix = new Matrix();
            compoundTransform.scale(scaleX, 1);
            compoundTransform.rotate(rotationDegrees * Math.PI / 180);
            compoundTransform.translate(x, y);
            commonMatrix.concat(compoundTransform);
            return commonMatrix;
        }

        private function init():void
        {
            invalidateDisplayList();
        }
    ]]>
    </fx:Script>
    <s:layout>
        <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle" />
    </s:layout>
    <s:Rect height="50%" width="50%">
        <s:fill>
            <s:LinearGradient rotation="{ROTATION_DEGREES}" scaleX="{GRADIENT_SCALE_X}" x="{GRADIENT_X}"
                y="{GRADIENT_Y}">
                <s:GradientEntry color="#FFD500" ratio="0" />
                <s:GradientEntry color="#F5A106" ratio="1" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>
    <mx:UIComponent height="50%" id="drawingTarget" width="50%" />
</s:Application>


看看执行所有计算的
getMatrix()
方法。

等等。。。出于好奇,你是从哪里得到1638.4这个神奇数字的?:)你不觉得我从脑子里得到这个数字很聪明吗?:)我刚刚完成了LinearGradent类的逆向工程:),所以所有的问题都应该问Adobe工程师:)
<s:LinearGradient rotation="90" scaleX="44.2931" x="10.294" y="-0.276" >
    <s:GradientEntry color="#FFD500" ratio="0"/>
    <s:GradientEntry color="#F5A106" ratio="1"/>
</s:LinearGradient>