Wonder how to apply smoothing, read and write pixels on a image loaded from a different domain name?
Quite simple, load as binary first and than load the ByteArray as Bitmap.
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, urlLoaderComplete);
var url:String = "http://www.adobe.com/images/shared/product_mnemonics/50x50/flash_player_50x50.gif";
urlLoader.load(new URLRequest(url));
function urlLoaderComplete(e:Event):void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
loader.loadBytes(urlLoader.data as ByteArray);
}
function loaderComplete(e:Event):void
{
var bmp:Bitmap = e.currentTarget.content as Bitmap;
addChild(bmp);
var bitmapData:BitmapData = bmp.bitmapData
bitmapData.applyFilter(bitmapData, bitmapData.rect, new Point(0, 0),
new ColorMatrixFilter([
0, 0, 0, 0, 0,
1, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, -1, -1, 1, 0
]));
}
Well, I went to the Flash On The Beach for the first time this year. Was really cool and inspiring.
The first night, I had some inspiration, nothing to deal to any of the presentations I saw, but just something that I wanted to test. I couldn’t upload it because I didn’t have internet at the hotel, and at the venue the firewall was blocking me to connect to my FTP.
So, what was my experiment this time?
Gesture!
I think it’s working quite nice for a code I took less than an hour to write. It was much easier than I thought.
Just click and try to draw a Triangle, Circle or Square.
Enjoy!
I’ll post the source code later… let me take a nap now.
And the source files zipped with the demos I showed.
http://www.hellokeita.in/presentations/LFPUG/20090827/examples.zip
The contents are:
Example01-SineWaveExample: Simple example generating a sine wave
Example02-KeyboardExample: Example of a piano keyboard
Example03-WaveformExample: Changing the waveform of a sound
Example04-TimePitchExample: Changing pitch and tempo of a mp3
Example05-HeliumBalloon: Real time pitch shifting using Java