Calling ActionScript Function from JavaScript

I was working on a small project where I am integrating a new Flex component with an existing HTML site. I am gradually rewriting the application in Flex but want to keep some of it in HTML during the migration.

I needed a way to have the HTML content access the Flash movie for the menu system. I found alot of code for the ExternalInterface that dealt with the ActionScript calling JavaScript but I was looking the do the opposite. I ran across an example but it was all in Flash and was giving me some fits. After figuring things out, I thought I would put together a small demo to help people out.

So here is an example of a JavaScript function in an HTML page calling an ActionScript function in a Flash movie via Flex 2. You can right click on the movie and view the source code for your enjoyment.

View Application