Over a million developers have joined DZone.

ActionScript Workers Now Work Under Chrome/PPAPI

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

I did a lot of tinkering with ActionScript Workers towards the end of last year. However, because I'd swapped out the PPAPI Flash Player in Google Chrome, I was oblivious to the fact that Workers weren't supported under PPAPI. Since I spend my working days bemoaning browser fragmentation with HTML and JavaScript and more than half my blog visitors use Chrome, I was pretty peeved.

So, today I am over the moon to say that ActionScript Workers now properly work under Chrome. You may need to force an update; at the time of writing, I'm on 25.0.1364.172 under Mac OS 10.8.2.

Workers are separate virtual instances of the Flash runtime that allow long running code to execute concurrently, i.e. in the background without impacting the UI. Here's a little retrospective of the work I did last year.

Multiple ActionScript Workers for Image Handling: here's an example of what not to do with Workers. I'd initially hoped to be able to spawn hundreds of workers and manipulate images using ActionScript like I can with Pixel Bender. Since each one is essentially an AVM, that was a tad optimistic. My machine choked at around ten Workers.

Multi Threaded Sound Synthesis in Flex with AS Workers: now we're getting sexy. I love a node based interface and here's an example with such an interface using Workers to generate  audio data in the background. Great demo of constructive and destructive interference too. 

Mutually Gravitationally Attractive Particles in Flex with AS Workers: I love particles even more than I love a node based interface. Getting every particle in a system to be aware of every other one is computationally expensive. What better use for Workers? 

Optimising AS Worker Particle System with Bin-Lattice Spatial Spatial Subdivision: Using bin-lattice subdivision to reduce the number of inter-particle calculations by an order of magnitude and give a 'good enough' result.

Concurrent Fluid Dynamics and Box2D Physics with AS Workers: I love fluid dynamics even more than I love particles (unless of course we're talking SPH a saucy combination of the pair) - so here I create one AS Worker to handle a simple Box2D physics task and another that uses the output of the first to act as heat/density source for a fluid dynamics task. There's a second play with this here.

More Flex Morphogenesis: Gray Scott with AS Workers: Well, if there's something I love more than node based interfaces, particles and CFD combined, it's reaction diffusion models. Again, a pretty computationally expensive business and if you don't fancy diving into AGAL, Workers offer a great way to do those long running computations without sending your users to sleep.

You may have guessed, I blooming love Workers, sure there may be neater ways to implement concurrency in the Flash Player, but they do a fantastic job and leverage all that ActionScript goodness we know and love.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Published at DZone with permission of Simon Gladman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}