0 Replies Latest reply on Apr 9, 2010 1:50 PM by GregVerm

    Cannot create gradient wipe?

    GregVerm

      Ok so basicly i'm just trying to change the wipe

      effect to one with a mask containing a gradient

       

      the following code should do just that:

      var transition:WipeRight = new WipeRight();

      transition.createMaskFunction = this.testMask;

      transition.xFrom = -200;

      transition.xTo = 700;//target width is 700

      transition.yFrom = 0;

      transition.yTo = 0;

       

      public function testMask(targ:Object, bounds:Rectangle):Shape {

       

      var targetWidth:Number = 700;

      var targetHeight:Number = 500;

       

      var newMask:Shape = new Shape();

      newMask.cacheAsBitmap = true;

       

       

       

      var maskMatrix:Matrix = new Matrix();

      maskMatrix.createGradientBox(targetWidth, targetHeight, 0, targetWidth, 0);

       

      newMask.graphics.beginGradientFill(GradientType.LINEAR, [0x000000, 0xFFFFFF], [1, 0], [0, 255], maskMatrix, SpreadMethod.PAD, InterpolationMethod.LINEAR_RGB);

      newMask.graphics.drawRect(-200, 0, 200, targetHeight);

      newMask.graphics.beginFill(0xFFFF00);

      newMask.graphics.drawRect(0, 0, targetWidth, targetHeight);

       

      newMask.graphics.endFill();

       

      newMask.width = targetWidth;

      newMask.height = targetHeight;

       

      return newMask;

      }

       

       

       

       

      This does seem to draw something but it's not moving and tracing the effect values doesn't really help.

      Removing the line "newMask.cacheAsBitmap=true;" shows the mask as it should but then the alpha of the gradient won't work...

       

      I was wondering if anyone else has tried this before, or can tell me what i'm doing wrong?

       

      Thank you in advance!