Force an Absolute ViewSource URL Flex 3.0

When adding the examples to the blog for Efflex I totally forgot why I usually only provide a link here instead of adding the movie to the post itself. Once this movie is running in a post, depending on whether you are viewing the front page, a category, the post itself etc, the URL to the source changes.

This is due to you only being able to specify a relative path to the source files using the export settings, you can try and specify the full path, but Flex Builder will strip out double forward slashes leaving a single forward slash. You could define it in AS but this would muddy the source.

ForceAbsoluteViewSourceURL.swc is a monkey patch of the Application class for Flex 3.0 which gets the URL of the SWF and appends this onto the relative path that was specified as the path to the source. This means it always has the same path, and therefore isn’t affected by the location of the HTML page its embedded in.

More Flex with the source enabled in blog posts! Hooray!

11 Responses to “Force an Absolute ViewSource URL Flex 3.0”

  1. Josh Tynjala says:

    Try out setting base parameter in the embed code to “.”

    This will tell Flash Player to search relative to the SWF rather than to the document URL. More info at TechNote: Flash OBJECT and EMBED tag attributes.

  2. [...] s-flex-apps-in-pdfs/”>Portable RIAs – Flex Apps in PDFs (from James Ward – RIA Cowboy) Force an Absolute ViewSource URL Flex 3.0 (from Tink) [...]

  3. Alex Cook says:

    Why didn’t you show a usage example?

  4. Russ Back says:

    Using Josh’s solution, you can achieve this with swfobject as follows:

    var flashvars = {};
    var params = {
    base: “.
    };

    swfobject.embedSWF(“myContent.swf”, “myContent”, “300″, “120″, “9.0.0″,”expressInstall.swf”, flashvars, params);

    More info at http://code.google.com/p/swfobject/wiki/documentation

  5. Tink says:

    yep but the plugin im using for wordpress doesn’t have this option.

  6. I must ask Alex’s same question: how using your solution?

  7. Tink says:

    You can see usage examples at http://www.efflex.org/.

    All the examples there use the method above, again because the plugin I’m using in WordPress (WP-SWFObject) doesn’t give me the ability the change the base parameter.

  8. [...] m the HTML page the SWF is embedded in and not relative to itself. Firstly to solve this I monkey patched the Flex Application class, but patching WP-SWFObject makes more [...]

  9. Tink says:

    I updated WP-SWFObject so you could add this base param http://www.tink.ws/blog/wp-swfobject-patch/

Leave a Reply