Search code examples
flex3swfobjectdeep-linking

How to embed flash files in HTML using SWFObject (and to get deeplinking to work!)


I have a problem that I have been trying to solve since days! I don't seem to get the BrowserManager.url property after I embed using SWFObject! the purpose is, to get the URL of the HTML where the SWF file is embedded and not where the swf file itself is!
explanation:
I mean the SWF file is only in the root, and the file is embedded in many pages on the website. Every time the flash file is loaded, it needs to know on which page exactly it has been called! would be great if you could help me! cheers Ali


Solution

  • The better way to do this is to use ExternalInterface:

    ExternalInterface.call('function() {try {return window.location.href;} catch (err) {}}');
    

    You'll need to make sure that you have allowscriptaccess set to always, like so:

    <script type='text/javascript'>
    var so = new SWFObject('player.swf','ply','470','320','9','#000000');
    so.addParam('allowfullscreen','true');
    so.addParam('allowscriptaccess','always');
    so.addParam('wmode','opaque');
    so.write('mediaspace');
    </script>
    

    Best,

    Zach