Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The answers were right... what you need is a <code>DisplacementMapFilter</code>!!</p> <p>The displacementImage should be grey in general -> means no distortion, and add a white and a gray radial gradient to each lower and upper edgelike this:</p> <p><img src="https://i.stack.imgur.com/2E7VL.jpg" alt="Distortion map for this very effect"></p> <p><img src="https://i.stack.imgur.com/uzFc9.jpg" alt="The image i used to be distortet"></p> <p><img src="https://i.stack.imgur.com/lqn2R.jpg" alt="Final result after distortion"></p> <p>And with the Map you go like this:</p> <pre><code>package { import flash.display.BitmapData; import flash.display.BitmapDataChannel; import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.filters.DisplacementMapFilter; import flash.filters.DisplacementMapFilterMode; import flash.geom.Point; import flash.net.URLRequest; public class DistortImage extends Sprite { private var sourceImage:Loader; private var distortMap:Loader; public function DistortImage() { super(); // Loading the Image to be distorted sourceImage = new Loader(); var requ: URLRequest = new URLRequest("text.jpg"); sourceImage.contentLoaderInfo.addEventListener(Event.COMPLETE, loadMap); sourceImage.load(requ); } private function loadMap( E:Event = null ):void{ // loading distortion map ( grayscale ) distortMap = new Loader(); var requ: URLRequest = new URLRequest("distortMap.jpg"); distortMap.contentLoaderInfo.addEventListener(Event.COMPLETE, applyDistortion); distortMap.load(requ); } private function applyDistortion( E:Event = null ):void{ // get jpg as BitmapData var bmpData:BitmapData = new BitmapData( distortMap.content.width,distortMap.content.height); bmpData.draw(distortMap); // create the filter - notice gray(128,128,128) means no distortion white is negative black is positive distortion var offsetOfMap:Point = new Point(0,0); var redChannelCode:uint = BitmapDataChannel.RED; // is not important cause you just need oneway distortion var yDistortion:int = 20; // strength var distortFilter:DisplacementMapFilter = new DisplacementMapFilter(bmpData,offsetOfMap,0,redChannelCode,0,yDistortion,DisplacementMapFilterMode.COLOR,0xffffff,0); // filters need to be included in an array to add on display Object var filters:Array = new Array(); filters.push(distortFilter); // adding filter to image sourceImage.filters = filters; addChild(sourceImage); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload