2 Replies Latest reply on Jul 16, 2007 7:13 PM by BishopNeo

    Help with beginGradientFill

    BishopNeo
      I can't get the gradients to render correctly, can someone proof my code and tell me what my blind arse missed?. The code is as follows:

      var fillType:String = GradientType.LINEAR;
      var spreadMethod:String = SpreadMethod.PAD;
      var interpolationMethod:String = InterpolationMethod.LINEAR_RGB;
      var xPos:Number = 100;
      var yPos:Number = 100;
      var height:Number = 100;
      var width:Number = 500;

      var overlay:Shape = new Shape();
      var overlayMatrix:Matrix = new Matrix();
      overlayMatrix.createGradientBox(20,20,0,0,0);
      var overlayColors:Array = [0x0000FF,0x00FF00];
      var overlayAlphas:Array = [100,100];
      var overlayRatios:Array = [0,255];
      overlay.graphics.beginGradientFill(fillType,overlayColors,overlayAlphas,overlayRatios,matr ix,spreadMethod,interpolationMethod);
      overlay.graphics.drawRect(xPos,yPos,width,height);


      However this displays a little bit of blue and about 95% of the rectangle is green. I'm *trying* to get it more like 60/4o, maybe even 70/30 (blue being the larger of the 2)

      Thanks for your help!

      _Anthony
        • 1. Re: Help with beginGradientFill
          peterent Level 2
          First, your alphas should be [1,1] (100 was the alpha from Flex 1.5). Your ratios look correct for what you describe. So if you want 60/40 you'll need to move the location of the ratios. Try something like [30,255] - in other words, start the blue a little later than zero. The gradient really isn't hard to do, it just has lots of parts.
          • 2. Re: Help with beginGradientFill
            BishopNeo Level 1
            Peter,

            Thanks for the help, I finally figured it out later in the evening. I didn't realize that I needed to set the x and y to the same x and y as the rectangle I was attempting to draw.