Detecting parent URL with AS3 and jQuery - redux

In an earlier article I spoke about changing the stage size based on the URL of the page that loads the ShockWave.


Well as it turns out the simple approach I outline there won’t work in IE7 for some reason (no don’t ask me why, I didn’t find any explanation no matter how much googling I did).

For some reason the ShockWave somehow loads quicker or something and the externalInterface.call function doesn’t get the URL. That I forgot to check in IE7 and the customer had to come complaining back to me is another story, it made me feel like renaming the site devtips instead of prodevtips. Ah now I remember, the only reason the site has that pro is that devtips was already taken, I’m Swedish after all, hesitant to put anything anywhere that might hint at me actually being able to do a good job. It was actually an American who thought that I should use prodevtips. Hardly surprising…

A solution is using flashvars instead, let’s first take a look at how they work and are retrieved in the ActionScript:

var curPage:String = this.loaderInfo.parameters.curPage.split('/').pop();

You can probably recognize the line in question from the earlier example/article. So loaderInfo has a member variable called parameters that in turn contains all flash variables as member variables. In our case the variable name in question is called curPage. The jQuery Flash JavaScript looks like this:

$(document).ready(function(){
  $("#menucont").flash(
    {
      src: 'menu.swf',
      width: '725',
      height: '297',
      wmode: 'transparent',
      flashvars: {curPage: window.location.href}
    },
    {expressInstall: true}
  );
});

Kinda neat huh?

Related Posts

Tags: , , , ,