Hi, i'm tryin' to flip an image using the displacementmap filter (I
know I have other ways to ahieve the same results, but i really do
need a BitmapFilter). I'm using a white-to-black gradient, but the
closest I can get is with the following code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            private function init():void
            {
                var displacementMap:DisplacementMapFilter;
               
                var gradient:Sprite = new Sprite();
               
                var fillType:String = GradientType.LINEAR;
                var colors:Array = [0xffffff, 0x000000];
                var alphas:Array = [100, 100];
                var ratios:Array = [0x00, 0xFF];
                var matr:Matrix = new Matrix();
               
                matr.createGradientBox(img.width, img.height, 0, 0, 0);
               
                gradient.graphics.beginGradientFill(fillType, colors,
alphas, ratios, matr); 
                gradient.graphics.drawRect(0,0,img.width,img.height);
               
                var mapImage:BitmapData = new
BitmapData(gradient.width, gradient.height, true);
                mapImage.draw(gradient);
               
                displacementMap = new DisplacementMapFilter();
                displacementMap.mode = DisplacementMapFilterMode.IGNORE;
                displacementMap.mapBitmap = mapImage;
                displacementMap.mapPoint = new Point(0, 0);
                displacementMap.componentX = BitmapDataChannel.RED;
                displacementMap.scaleX = img.width*2;
               
                img.filters = [displacementMap];
            }
        ]]>
    </mx:Script>
    <mx:Image id="img" source="@Embed('imagen.png')"/>
</mx:Application>

The result is not a clear flipped image, but a "rough" one.

Anyone can help me?


Lots of thanks in advanced,

Alberto

Reply via email to