Luke
Luke

Reputation: 21236

Flash Player deep linking problem

I'm working on this Flash project and I've constructed a swf where all the assets are exported into frame 5 and the first frame contains the pre-loader. When the pre-loader is finished it jumps to frame 10 where the actual site begins. This works great.

However, in every browser I've tested so far (FF, IE, Chrome and Safari) when I place a # on the url the behaviour seems to be that the browser is downloading the entire swf first and then starts playing it with the end result that it takes a while for the swf to load (blank screen), the pre-loader kicks at a 100% and then the swf continues to the site.

I would appreciate it if anyone could confirm this behaviour and any input to shed some light on this problem.

UPDATE:

Thanks to rhtx for pointing out this annoying Flash Player behaviour. In a way I can understand why this is but it only works if you make linear movies, which I don't. Currently it means that I need to create a label for every deep link location on the first frame which is of course impossible if your path is content driven.

Is there a way to overcome this second problem?

Upvotes: 0

Views: 830

Answers (4)

Les
Les

Reputation: 2316

I've known about this bug a while now and use the container method to circumvent it. But I hate the container method so I sporadically search the web for solutions.

Rhtx to the rescue..

Not really as clean as it should be, but im quite happy the way it works..

The way I implemented it now is I have a frame label type anchor named "loading" on frame 1 (frame 2 is where my application lives).

Then I use a piece of javascript to load my flash site, which basically does this:

//pseudo javascript
var path = "";
function buildFlash() {
   path = location.hash.length > 1 ? location.hash.substr(1) : "";
   location.hash = "loading";
   $(document).ready(onDOMReady); //could probably directly load the swf now
}

function onDOMReady() {
   swfobject.embedSWF(... with path flashvar ...);
}

The reason this works for me is I call a function ExternalInterface("setPath", path) from flash to set the hash, which in turn also passes the path to googleanalytics.

A person visiting the url http://www.site.com/#about/ will see the url /#loading while the site loads, when the loading is finished, the flash application determines where the user should go and changes the url accordingly.

Upvotes: 1

jedierikb
jedierikb

Reputation: 13089

My guess is that this bug is causing you problems. This guy has been reporting on the nature of this bug for a while.

While it sounds like you are not using flex, I would not be surprised if this bug effects pure as3 flash too.

The bug was recently closed. The solution: make a small swf preloader to load your main swf (like asperous.us) suggests.

Also see this s.o. q & a.

Upvotes: 1

Ross Henderson
Ross Henderson

Reputation: 1779

I had a pretty crazy issue with writing and reading local SharedObjects when there was a # in the URL. It was painful, and I couldn't ever fully nail it down. Not the same as what you're dealing with, but I can confirm that the FP may act differently in some cases when there is a '#' in the URL.

I think what may be happening in your case is that the Flash Player is looking for an anchor, due to the '#' symbol. My guess is that it keeps looking until the entire SWF has loaded and it sees that there is no anchor anywhere in the SWF for it to match up with.

You might try something like this:

Add a new layer in your FLA on the main timeline. On the first frame, create an anchor (add keyframe, name the frame and select the 'Anchor' option when you name it). Try loading up your page again, but put the name of the anchor after the hash symbol. If it loads up as desired, then there may be something to my guess.

Hope that helps.

Upvotes: 2

Andy Chase
Andy Chase

Reputation: 1368

You could make a "container" swf whose only job is to load the real swf. That way it wouldn't matter if the swf on the page gets loaded completely before it runs, since it would only be a few kb in size.

Upvotes: 1

Related Questions