Note: There is a tuturial buried in here, but the first portion of this article is background on my recent project. To find out how to compile a flash 10 movie with APE, scroll down the page a bit.
I recently spent some time in CS5 attempting to realize a concept for a new interactive web instrument. I did my first one in Java via Processing. I’m crazy about Processing because it makes fleshing out ideas fast and simple. A lot of the more complex bits of initialization and library integration are built into the development environment. The one thing I didn’t quite like was how it dealt with audio. Afterall, Processing is primarily aimed at graphical functions. As much as I dislike how bloated flash applications can become, I ultimately decided that I would need to give flash another shot.
I had spent some time in college working in flash – mostly doing silly things, although I did make one little app for our school’s composition department website
[Click the keys and be amazed.]
One big issue I had to face was where to even begin. ActionScript3 was very different than the original back when I was using Macromedia Studio. After spending quite some time grappling with the language (and in the end actually feeling quite comfortable with the new OOP bent) eventually I figured out that I would need an external library for the physics simulation I wanted. My searching paid off when I found the ActionScript Physics Engine (APE) for AS3. Many people were writing about how natural and straightforward it was, and now after using it I can agree that it’s pretty slick. After working out the simulation and everything else needed to make it functional I started to think about the audio engine. My original plan was to just use files that could be triggered and played back whenever necessary, although I had started to think of how large the movie would be to have all the files I wanted. Out of nowhere I sort of stumbled upon an audio library called SiON. I’m planning on making another post about SiON because it’s really quite an amazing library and I’ve got a lot to say about it. For now, the main thing I need to point out is that because of changes to audio handling in flash 10, SiON is not usable in any earlier flash version.
One thing I had ended up doing initially in trying to make APE work was to set the flash version to flash 9 under the publish settings. This made APE work like a dream, but as soon as I started to prototype with SiON things fell apart. What I came to understand was that APE was built to work first and foremost in flash 9, while SiON worked only in flash 10. Not something you might expect to be a big issue, but it really was.
How to configure APE to work in Flash 10
Because it took me some trial and error to get this worked out, I thought I’d spell it out here as clearly as I can for anyone else having the same problems I had. Let me say up front that the root of my problems was a compatibility issue between flash 10 and earlier versions. If you’re getting thrown some compile errors that are a little unclear, play around with the publish settings. That’s what eventually led me to this solution. This is not something I discovered myself – I’m taking what I’ve read on some different forums and putting it all here.
What you will need to do to make APE compile into flash 10 is to open up the .as files and replace all occurrences of the “Vector” function call. Apparently flash 10 introduced it’s own function called “Vector” and now everytime APE tries to call it it will throw up an error. I would recommend using a text editor such as Notepad++ for this job. This program in particular has a feature that allows you to search and replace for multiple documents at once. Even without this functionality this is still an easy fix, it’ll just take a little more time.
Look in the folder that has all of the APE files you use to link with your project (should be under org/cove/APE). Open all of the files with the extension “.as” in Notepad++ (or if using another editor just one file at a time). Search and replace for the word ‘Vector’ and replace with something unique, such as ‘APEVector’. I’m a bit paranoid when editing stuff like this so rather than using the “replace all” option I instead elected to verify each one. Once I’d replaced each occurrence, I recompiled the movie and everything worked smoothly in flash 10.
I know that was a lot of information for such a quick fix, but I always appreciate it when people provide a little perspective to help set the context.
Next time I’ll talk a bit about SiON and why it’s the only sound library flash will ever need.







