That’s right, it’s not a typo! This experiment started out as me simply trying to learn how to include Flash in a WPF project. There are many resources out there for doing this. Once I got that done I decided to take it further by incorporating some of the great new
Actionscript 3 features in
Flash Professional 9. If you saw my other experiments where I took audio spectrum data from After Effects and used it drive to WPF animations, you’ll remember me wondering if we could do this type of analysis on-the-fly. Well after a bunch of research I found out that it is possible but *very* complicated.
Then last week Adobe released a preview version of
Flash Professional 9 which supports
Actionscript 3It contains a new
computeSpectrum() function that will do this very type of real-time audio analysis. I have done a
few experiments using this and it is FAST! So this experiment is a WPF app that embeds a Flash 9 SWF. That SWF is playing and analyzing a music file. It is sending that information to the WPF app using the ExternalInterface API. The WPF app is then using that data to do some 3D animation on the 4 torus meshes which I built in
ZAM3D. It also includes the Trackball class so you can zoom and rotate the objects as they animate.
Unbelievably it works like a charm! And not only that, but it is really fast and could probably handle much more data traffic between these two rival technologies

Below is a rundown of the process I used and exactly what is happening here:
- The WPF app creates a regular windows form containing the Flash ActiveX control. It doesn’t actually get added to the visual tree however.
- It then loads the SWF file into the ActiveX control. I am hosting the SWF online because I couldn’t figure out how to include it with the build.
- The SWF file first loads the music file which is also hosted online. Due to sandbox restrictions you can only analyze files on the same domain.
- It then creates an EnterFrame event which analyzes the music file. The computeSpectrum() method returns 256 channels of audio data. Since I’m only using 4 graphics in WPF, I break the data into four bands and average them so that I end up with four bands of information.
- The SWF then calls a C# function and sends the data as XML using the ExternalInterface API.
- Lastly, I’m using this audio data to perform RotateTransform3D transforms on the four 3D shapes
This could open up so many possiblities as you can basically use Actionscript 3 in your WPF apps. Flash acts as the data provider to your application for things like animation and rich media. Of course I have no idea about performance or scalability. But it’s still a potential workflow for certain things.