3 Replies Latest reply on Jun 3, 2008 9:08 AM by Newsgroup_User

    Class for background gradient

    brian914 Level 1
      I am new to writing classes, but am trying to learn. I want to write a class that creates a gradient for the whole stage. I want to be able to pass in the two color values in the beginning.

      Like I said, I am new to this, but here is what I have. Obviously, it is not working yet. What do I need to change?

      In my Fla, I have the following:
      myBG = new BgColor(0x000000, 0xCCCCCC);
      They are not in the same directory. How do I do that? I have a class path to a folder on my desktop. But there is a structure within that. Using the import it would look like this: import com.brianf.BgColor

      My class looks like this:

      class BgColor
      public var color01:Number;
      public var color02:Number;

      private var fillType:String = "linear";
      private var colors:Array = [color01, color02];
      private var alphas:Array = [100, 100];
      private var ratios:Array = [0, 255];
      private var matrix:Object = {matrixType:"box", x:0, y:0, w:Stage.width, h:Stage.height, r:(90/180)*Math.PI};
      private var spreadMethod:String = "pad";
      private var interpolationMethod:String = "linearRGB";
      private var focalPointRatio:Number = 1;

      public function BgColor()
      beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio);
      moveTo(0, 0);
      lineTo(Stage.width, 0);
      lineTo(Stage.width, Stage.height);
      lineTo(0, Stage.height);
      lineTo(0, 0);

      What do I need to change to make this work? Right now, the class does not even get instantiated.

      Thank you so much for the help!