Encoding PNG Data
Wednesday, August 09th, 2006 | Author: dehash
I read that AS3 gives Flash the ability to encode binary data. For example that it is possible using ByteArray to encode a png from a BitmapData object.
I wanted to make a quick example to test this. So I grabbed an AS3 png encoder. Then I needed a dynamically changing BitmapData object so I grabbed a nice computeSpectrum example. For speed and convenience I also used Senocular’s EasyButton and these three files (slightly modified) make up most of the code I used.
The resulting png data could be sent to the server and saved as a file but I chose to load the png data in the ByteArray into the current movie it using Loader.
There is a slight pause sometimes in the spectrum data when the button is pressed presumably because of the load and there may well be better ways to do it. But for a quick test it at least shows that it works in principle.
Here is a screenshot of the final movie and below is the swf. Just click the button once the audio has loaded and the png data will be encoded and output beneath the spectrumdata.


