/* * IMAGESLIDE * * This thingie displaces an image horizontally using a sine-wave. * * To recreate, you'll need to have the Flash9 ActionScript3 Preview installed, you can get it at http://labs.adobe.com/technologies/flash9as3preview/ * Create a new 300x256 FLA, and put 'ImageSlide' (without quotes) as its Document Class. Test Movie et voila! * * @author Edwin Heijmen * @version 0.1 */ package { import flash.display.*; import flash.net.*; import flash.events.*; import flash.geom.*; import flash.utils.Timer; public class ImageSlide extends MovieClip { private var imageW:Number; // width private var imageH:Number; // height private var offset:uint; // amplitude of sine-wave private var count:uint = 0; // used for displacing sine-wave // used for loading image, loading mp3, displaying progress and visuals private var img:Loader; private var image:Bitmap; private var origData:BitmapData; private var bmd:BitmapData; private var bm:Bitmap = null; public function ImageSlide () { // constructor // // load in picture img = new Loader(); img.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingCompleted); var requestImage:URLRequest = new URLRequest("ggoo_300x256.jpg"); img.load(requestImage); } private function loadingCompleted (event:Event):void { // loading is done, start working // // get width & height imageW = img.contentLoaderInfo.width; imageH = img.contentLoaderInfo.height; offset = uint(imageW/3); // first make sure we can distort image image = Bitmap(img.content); origData = image.bitmapData; bmd = origData.clone(); bm = new Bitmap(bmd); addChild(bm); // // start executing function var myTimer:Timer = new Timer(0); myTimer.addEventListener("timer",doNext); myTimer.start(); } private function doNext (event:TimerEvent):void { // distort rectangles inside image based on sound channels // // var i:Number = 0; var float:Number; var o:Number; var rect1:Rectangle; var rect2:Rectangle; var point1:Point; var point2:Point; // loop over all rows and start sliding while (i