Getting JavaScript and ActionScript back together
Have you noticed that since the last round of browsers came out earlier this year your JavaScript functions can no longer call ActionScript in your Flash applications? If you’re like most people, you were probably using Adobe’s sample function to grab your Flash document in the DOM. Unfortunately, the latest couple Firefoxs and the latest Internet Explorer both decided to change what type of object they returned in regards to embedded objects, which requires a function that’s a bit more complex. Here’s what I threw together quickly a while ago. There’s probably a more elegant solution if you want to put some time into it, but this code will work if you want to use it:
function getInternetExplorerVersion()
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
function getFlashMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
var ver = getInternetExplorerVersion();
if (ver > 8 ) {
return window[movieName][0];
} else {
return window[movieName];
}
} else {
if(document[movieName].length != undefined){
return document[movieName][1];
}
return document[movieName];
}
}
Categories
- ActionScript (1)
- books (1)
- design (1)
- Donald Glover (1)
- Flash (1)
- Google (1)
- HTML5 (3)
- iOS (2)
- JavaScript (1)
- marketing (1)
- Memphis (1)
- programming (4)
- random (3)
- site updates (2)
- vanity (1)
- web development (5)
Friends
- I Love Memphis Blog I read this daily. Lots of good info. And I hear Kerry’s in a band with an awesome drummer.
- Recovery on Water They hate breast cancer. And so do I. And Jenn’s cool.
- Ryan Null A developer guy I used to work with. He usually doesn’t have anything on his blog.
Games
- UltraCorps A game I play. It’s fun.
Memphis
- I Love Memphis Blog I read this daily. Lots of good info. And I hear Kerry’s in a band with an awesome drummer.
Projects
- Impressto A site I made with some other dudes.
- Social Owl Another site I’m making with some other dudes.
Really cool
- Simulation Argument The answer to the question of Life, the Universe, and Everything. It’s not 42.
- UltraCorps A game I play. It’s fun.
Web development
- Impressto A site I made with some other dudes.
- Ryan Null A developer guy I used to work with. He usually doesn’t have anything on his blog.
- Social Owl Another site I’m making with some other dudes.
Websites
- Diggnation I like this show.
- Donald Glover This guy is cool.
- Reddit I spend far too much time here. I don’t even enjoy it. It’s an addiction.
- Simulation Argument The answer to the question of Life, the Universe, and Everything. It’s not 42.
- UltraCorps A game I play. It’s fun.



