0 Replies Latest reply on Sep 8, 2011 4:18 PM by Slaygeist

    Creating Gradient-filled shapes via JSFL CS5.5?


      I'm trying to use JSFL to create a number of oval shapes on a layer, that have a gradient fill applied to them.  I've stripped down the JSFL to very bare bones which I will post here:


      var flashDoc = fl.getDocumentDOM();
      var flashLib = flashDoc.library;
      var flashTimeline = flashDoc.getTimeline();


      // Set fill color for all shapes
      var fill = flashDoc.getCustomFill();
      fill.style = "radialGradient";
      fill.color = "#FFFFFF";    // For some reason if I don't assign at least *something* here, the color array doesn't work and I get fully black shapes
      fill.colorArray = ["#0033CC", "#FFFFFF"];
      fill.posArray = [0, 255];
      fill.focalPoint = 0;
      fill.linearRGB = true;
      flashDoc.setCustomFill( fill );


      for( var i = 0; i < 10; ++i )
          var x = Math.random() * 500;
          var y = Math.random() * 400;
          var radius = Math.random() * 25 + 25;
          var left = x - radius;
          var top = y - radius;
          var right = x + radius;
          var bottom = y + radius;
          flashDoc.addNewOval( {left:left, top:top, right:right, bottom:bottom}, false, true );


      When I run this script I do not get the results I'm expecting.  I get a number of oval shapes that all share the same gradient transform, i.e., each shape only gets part of the gradient.  The documentation says this function should be equivalent to using the draw oval tool, yet when you use that tool each oval you draw is associated with its own gradient transform.

      My Questions:

      1. Am I missing a piece here to create shapes each with their own gradient transform?

      2. Is it a bug that I have to set something into fill.color, even though I'm supplying a color array?  If I set nothing there, all the shapes will draw in full black.

      3. Is there a way to specify gradient colors that include alpha?


      Thanks for your time.