Jan
29
2007

problem solved

I just came across a baffling problem in Flash … and a simple, but equally baffling solution.

The Set-Up:

I’m building a Flash widget that displays links to photo galleries, with photo thumbnails. This widget is fed by an external textfile that looks something like this:

&photo1img=imgs/photo_thumb.jpg&
&photo1hed=Photo Headline&
&photo1text=Photo description lorem ipsum dolor sit amet.&
&photo1link=840&

(Yes, I know I should probably be using XML, rather than a textfile. But, in this case, it was the simplest (and quickest) thing to do.)

You might notice that the photo link is just a number, rather than a real URL. The real link to the photo gallery is a crazy-long JavaScript call for a popup window. However, when crazy-long URLs like that are passed into Flash, the application tends to cut off the link after a certain number of characters, breaking the link. To circumvent that, I’ve hardcoded the full link into the Flash file, with a placeholder variable for the gallery photo link — the only part of the link that’s specifically unique to that photo gallery.

In the Flash widget, there are two ways someone can access the link: 1) click on the photo thumbnail; 2) click on the link in the text next to the thumbnail. The link and the desired behavior are the same, but the way to get there is a bit different.

And here my troubles begin.

The Problem:

My code looks something like this:

photos.photo1.pic.loadMovie(photoInfo.photo1img);
photos.blurb1.htmlText = 
     '<a href="asfunction:_root.openVideoLink,' 
     + photoInfo.photo1link + '">' 
     + photoInfo.photo1hed + '</a><br>' 
     + photoInfo.photo1text;
photos.photo1.onRelease = function() { 
     openVideoLink(photoInfo.photo1link;
}
function openVideoLink(myLink) {
     getURL("javascript:open_PhotoGallery('http://myurl.com/gallery?id=" + myLink 
     + "','photos','toolbar=no,scrollbars=no,resizable=no,width=600,height=400');");
}

Then I load everything up in the browser for testing. When I click on the photo thumbnail, everything works as expected: The Flash file calls the JavaScript, which then spawns the correct popup window.

However, when I click on the HTML version of the link, nothing happens. Or, rather, something tries to happen, but Firefox’s popup blocker kills it. The browser somehow sees the asfunction version of the link differently than the getURL version — even though the desired result is exactly the same.

The Solution:

Baffled, I consulted Google … and found this nugget of wisdom within a messageboard exchange about this very issue:

I just tried it and they both work fine for me, I had to change my publish setting to “Network Access” instead of “Local Access” to get it to work, but before both where giving the popup and after both work

I went into the Publishing Settings for my Flash movie and changed my Local Playback Security setting from “Access local files only” to “Access network only.” I republished my files and reloaded my browser.

And it worked.

I have no clue why — and nothing I’ve found so far has been able to help explain it — but it worked. I suppose the answer to that is the next mystery to solve.

Update: The fix works in Firefox, but the Safari popup blocker still kills the popup. However, Safari’s popup blocker is a lot easier to toggle on and off (cmd-K) than Firefox’s.

Post a comment

As a spam-control measure, your comment may require my approval before it will appear on the entry. Thanks for waiting. To avoid the moderation delay, consider filling in your e-mail address. It won't appear on the site, but I use it to whitelist frequent commenters so their comments appear automatically.


The following HTML tags are permitted (if you want to use them):
p, br, a href, b, strong, u, i, em, ol, ul, li, cite, blockquote

TrackBack

TrackBack URL for this entry: http://www.morethanthis.net/mtadmin/mt-tb.cgi/1747