SWFObject 2.0, SWFAddress 2.1, Flex 3 and getting the starting path

I have a test project running with Flex 3 and SWFAddress 2.1 and SWFObject 1.5. It worked but I noticed that SWFObject was updated to 2.0 and SWFAddress is supposed to work with it. So I upgraded. And getting the first initial URL stopped working. Couldn’t figure it out. Then I saw this:

joeberkovitz.com » UrlKit 0.70 with various fixes and Flex 3 Support on Google Code

One possible caveat is that you must pass a unique object ID to SWFObject for the / tag (this ID is the second arg to the SWFObject constructor). Hope this helps — let me know if you’re still stuck and I’ll try and post something.

In my SWFObject 1.5 code, I wasn’t setting the attributes. SWFObject 2.0 is more strict about it. So after changing this:

var attributes = {};

to this:

var attributes = {};
attributes.id = "content";
attributes.name = "content";

It worked. The actual swfobject call is like so:

swfobject.embedSWF("path/to/app.swf", "content", "100%", "100%", "9.0.0", "path/to/expressinstall.swf", flashvars, params, attributes);

Hope that helps someone out there! Oh yes, thanks to Joe for mentioning the caveat as well. :-)

2 Responses

  1. Thank you, thank you, thank you. I’ve been struggling with this for the last hour. After spending 3 hours getting swfaddress to work in the first place!

    After some testing, it turns out that you only need the ID set, not the name.

    Cheers.

  2. No problem. Glad it helped!

    I have to look at the generated script/code to see how it’s actually using the name and id. Thanks for the insight on that bit.

Leave a Reply

You must be logged in to post a comment.