Linux is for Lovers

Archive for the ‘flash + powerpoint’ Category

One of the cool things I learned about Powerpoint the other day is that it’s possible to create interactions between an embedded Flash movie and the presentation itself.  This allows you to coordinate animations across the movie and the slide, e.g. to have a mouse click sometimes advance the slide and sometimes trigger some action in the movie.

The reason all this works is because you can do function calls up from the Flash movie, through the ActiveX container and into VBA code attached to the Powerpoint presentation.   You can also call down from Powerpoint into Flash in a similar manner, though I haven’t experimented with this.

The Easy Part

Perhaps surprisingly, writing the code is the easy part.  The Visual Basic code attached to the Powerpoint slide looks like this:


Private Sub ShockwaveFlash1_FlashCall(ByVal request As String)
  'request looks like:
  '<invoke name="foo" returntype="xml"><arguments></arguments></invoke>;
  If InStr(request, "gotoNextSlide") > 0 Then
    ActivePresentation.SlideShowWindow.View.Next
  ElseIf InStr(request, "gotoPrevSlide") > 0 Then
    ActivePresentation.SlideShowWindow.View.Previous
  End If
End Sub

ShockwaveFlash1 is the name of the ActiveX control for the Flash movie. If you only have one of these on a slide, this will be its name. But if you have more than one, the names will be ShockwaveFlash2 and so on.

In ActionScript land, the code that calls out of the Flash movie looks like this:


import flash.external.ExternalInterface;

if ( ExternalInterface.available ) {
   ExternalInterface.call( "gotoNextSlide" );
}

The Hard Part

Unfortunately, this code won’t do anything out of the box.

This is because of the Flash player security model, with which I became overly familiar over the course of this project. There are several different security sandboxes in which a Flash movie can potentially be running.  In order for ExternalInterface function calls to work, the movie needs to be, sensibly, in the most trusted sandbox: the LOCAL_TRUSTED sandbox. Fortunately, a movie can check what sandbox it’s running in with the following code:

import flash.system.Security;
trace( Security.sandboxType );

If you run a Flash movie in the standalone Flash player, it runs with LOCAL_TRUSTED privileges. However, if you run that same movie via an ActiveX control in Powerpoint, the default security settings put it in the LOCAL_WITH_NETWORK sandbox, which is insufficiently privileged to allow Powerpoint-Flash interaction to work. Instead, things will fail silently.  And no amount of tinkering with Powerpoint’s security settings (trusting ActiveX content, macros, etc.) will fix things. After much anguish, I discovered that you have to talk directly to the Flash runtime to get a movie into the LOCAL_TRUSTED sandbox when running inside an ActiveX control.

There are several ways of telling the Flash runtime to put a particular movie in the LOCAL_TRUSTED sandbox, all of them documented at the Adobe link above. Probably the easiest way is via the Flash Security Settings Manager gui: it’s a Flash applet that runs in your browser to control your local Flash settings – spooky!  You can decide to trust particular .swf files, or directories, or even the Powerpoint executable itself which will automatically trust all movies that are included in Powerpoint slides.  I’ve blogged previously about how to do this, but there are a few tricky parts I haven’t covered before.

If you’re embedding Flash movies into Powerpoint (as opposed to just linking to the movies), then you have to trust the Powerpoint binary, as the Flash movies don’t have a real filesystem location – if you check where an embedded movie lives via root.loaderInfo.url you will get the path to the Powerpoint binary. Trusting the Powerpoint binary is a hack that allows the movie, indirectly, to be trusted as well.  Trusting Powerpoint will also enable non-embedded Flash movies to run in the LOCAL_TRUSTED sandbox.

If your Powerpoint slides just link to the Flash movies, then you can have finer-grained control over security, but of course you have to ensure the links are always valid or the movies won’t work.

Other security considerations

Getting the Flash player security settings right was definitely the trickiest part, because they’re a bit out of the way and not terribly popular topics of conversation according to Google.  But to make Powerpoint and Flash play nice together you also need to (clearly) enable macros in Powerpoint and allow ActiveX controls to run.  ActiveX controls don’t need any special treatment however: they can run in Safe Mode with privileges that prompt you before they are enabled with “minimal restrictions”.  I never saw a prompt, because I don’t think the Flash ActiveX control requires any special privileges.

Once you get the security settings resolved things work great. It is highly unlikely, however, that things will work out-of-the-box if you move the presentation to a new computer, due to the default security settings. But once you get things integrated, you get the power of Flash for doing complicated animations with the ease of Powerpoint for the simple stuff. Pretty much the best of both worlds!

Here are some instructions to help you run the presentation I gave on Deterministic Shared Memory Multiprocessing at ASPLOS 2009.  The presentation itself can be downloaded here.  This presentation uses Shockwave Flash movies embedded in Powerpoint, and interaction between the two, so there are a few steps you have to go through to get everything to work right.

Software you need installed:

  1. Microsoft Powerpoint, 1997 or newer.  I’ve only tested this on Powerpoint 2007 however (on Vista, but hopefully that doesn’t matter).
  2. Install the Adobe Flash 10 ActiveX control, if you want to play the Flash movies inside Powerpoint.

There are macros on the slides with Flash movies that synchronize the advancing of the slide with the animation being played by Flash.  Essentially, any slide with a Flash movie is “driven by” the movie – clicking on the movie will either advance the movie or the animated elements (e.g. bullet points appearing) on the Powerpoint slide, as appropriate.  The Flash movies need enhanced privileges to be able to call code outside their ActiveX container, and you need Powerpoint macros enabled so that the Flash movies have some code to call.

I just wanted to look at your slides…

If you just want to look over the slides and/or play the Flash movies in a standalone Flash player, you can ignore all the nonsense below.  This is also helpful if you don’t want to run Powerpoint macros or trust any Flash content to run with local privileges.

To get things to work with macros disabled and the Flash content remaining untrusted: just click on the movie as usual and, if nothing happens, that click was supposed to animate something on the slide instead.  You can just click on the slide (not the Flash movie! – clicking on the slide title text is safe) to animate the slide manually.  It requires moving the mouse around, so I didn’t want to do that for my actual presentation, but it works just as well for a less formal setting.

If you don’t want to install or run any ActiveX plugins in Powerpoint, you can also just play the Flash movies in a standalone Flash player.  Synchronizing this with the slides is kind of klunky though.

I want things to work seamlessly…

First off, I’m pretty sure this only works on Windows, due to the dependence on the Flash ActiveX Control.  I’ve tested it on Windows Vista, but XP should be okay too.  There are 4 things you need for this to work seamlessly.

  1. Powerpoint 1997 or newer, and the Flash Player 10 ActiveX Control (installation instructions for the latter here).
  2. Enable macros in Powerpoint.
  3. ActiveX controls can be set to run with their default privileges, i.e. you will get a prompt before they do anything scary, and they can also run in Safe Mode.
  4. The Flash movies need to be trusted so that they can interact with the Powerpoint presentation.  This is described below.

The Easy Way (slightly less secure)

Visit the Flash Security Settings Manager web page and specify that you trust the Powerpoint executable via the “Add location” dropdown.  With Office 2007 on Vista, my Powerpoint executable was at C:\Program Files\Microsoft Office\Office12\POWERPNT.EXE

Why is this way less secure?  By setting Powerpoint as a trusted source for Flash, any Flash content that gets embedded into Powerpoint will run with the highest privileges (which includes access to local files).  You may or may not feel comfortable with this.  The upside is that you can move the presentation to a new directory without breaking anything.

The Secure Way (slightly less easy)

Visit the Flash Security Settings Manager web page and specify that you trust only the directory where the Flash movies for the presentation are (e.g. C:\Users\Admin\Desktop\dmp-asplos2009-presentation\ if you downloaded the presentation and unzipped it onto your Desktop).  You do this via the “Add location” dropdown.

This is more secure because only the Flash content in the specified directory will be trusted, but if you move the movies or the presentation to a new directory, things will stop working (and silently!).

Eep – something doesn’t work…

There’s a test slide at the end of the presentation which has an embedded Flash movie in it.  The movie runs some basic sanity checks on your configuration and displays the results.  If everything appears ok, then the presentation itself should run fine.

Interacting with the movies

Clicking on a Flash movie will advance the animation one step forward.  Pressing the ‘c’ key makes the animation go one step backward.  That’s all there is to it!

Here’s how I got the Adobe Flash Player 10 ActiveX Control to install under Windows Vista, so I could embed Flash movies in Powerpoint.

  1. Go to the Flash Player download site.  Download the “Adobe Flash Player 10 Update for Flash CS4 Professional” zipfile – 44MB.
  2. Unzip the archive somewhere, and go to the Players/Release/ directory.
  3. You’ll find an executable named Install Flash Player 10 ActiveX.exe, which will do just what the name says!

This is kind of convoluted; maybe people have found easier ways?

I recently attended ASPLOS 2009 in Washington, D.C., and put together some slides for the presentation I gave on Deterministic Shared Memory Multiprocessing. To appease my endless thirst for new technologies, I figured I’d try using Powerpoint with embedded Shockwave Flash movies for the presentation, instead of the traditional vanilla-Powerpoint. Why bother making my life so complicated? Well, there were 5 main reasons.

  1. I like complicated things.
  2. The animations I wanted to do were, in my opinion, just too complicated (see above point) to create in regular Powerpoint. I wanted to move shapes in very precise ways. Doing motion paths in Powerpoint is particularly tricky, because the motion path is based on the center-point of the shape, so it’s hard to judge what the motion will look like until you actually see it.
  3. Even more importantly, animations in Powerpoint are hard to change. It’s hard to keep things consistent, because changes don’t propagate. By doing things in Flash instead, I could write code to script my animations, so my toolkit was now limited only by the power of the abstractions I could build.
  4. The animation engine in Powerpoint is a bit sluggish – I observed a fair amount of graphical tearing when moving shapes around (especially large ones), even though I was running the presentation on a Core2 dual-core laptop, had the CPU running at full power with nothing in the background, had hardware acceleration enabled in Powerpoint, etc. Flash just brings a little extra crispness that’s hard to justify until you see it running at a beautiful 30 fps.  Worth all the pain I went through to make it work? Probably. Easy on the eyes? Definitely.
  5. Finally, Adobe has graciously open-sourced the toolchain needed to compile your own Flash movies from Actionscript. This, coupled with the excellent FlashDevelop Flash IDE, was all I needed to convince myself that this crazy adventure was going to be worth it. Convincing my adviser, however, was a different story… ;-)

So, the next series of posts will describe how I got Flash, Powerpoint, ActiveX and other buzzwords to play nicely together.  I hope this will prove useful to others who might be crazy enough to try this out – I can definitely see myself doing this again someday.



  • Nelson Nahum (@nnahum): Andrew, check Zadara Storage. This is a NFS/iSCSI HA server, accessible from EC2 instances. You can even have dedicated drives and data encryption as
  • Andrew Brampton: Thanks for this post. This has been useful for sharing a large read-only EBS filesystem with multiple EC2 instances. No need to set up a HA NFS server
  • Joe Devietti: I mostly use the AWS web console, which has a 1-click menu option to create an AMI from a running instance. Just right click on the instance and sele

Categories

Follow

Get every new post delivered to your Inbox.