Category: web

Flash Event.COMPLETE sometimes doesn’t fire in Firefox

3:24 pm on December 14th, 2009, by Ryan Gibson

I have run into some strange behaviour in Flash and Firefox recently. We had a Flash movie (AS3) that loads up, in its document classes constructor it sets a few event handlers on loaderInfo:

this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, progress);
this.loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
this.loaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

The problem taht seemed to be happening (most of the time, ie not 100% reproducible) was that the movie was failing to fire the Event.COMPLETE event handler. After some browsing I found Marguera’s post which suggests adding another event handler, Event.INIT and pointing it at the same handler as the Event.COMPLETE event.

this.loaderInfo.addEventListener(Event.INIT, loadComplete);

Then updating the loadComplete method to check if we had actually finished loading, if so remove the event handlers and carry on setting up the movie.

private function loadComplete(e:Event):void {
  if(this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal){
    this.loaderInfo.removeEventListener (Event.INIT, loadComplete);
    this.loaderInfo.removeEventListener (Event.COMPLETE, loadComplete);
    // Finish setting up the movie
    // ...
  }
}

This approach fixed our issue, and hopefully this post will point anyone else seeing similar irregularities in the right direction. The Flash documentation states that the Event.INIT event is fired when:

  • All properties and methods associated with the loaded object and those associated with the LoaderInfo object are accessible.
  • The constructors for all child objects have completed.

And that the init event always precedes the complete event. That wasn’t what we were seeing in practice, as our complete event was failing to fire completely. hth.

8 comments » | Adobe, development, flash, web

html5 under the radar; or a standards compliant way to embed video on the web

6:01 pm on July 2nd, 2009, by Ryan Gibson

With the release of Mozilla’s Firefox 3.5 another browser—along with Apple’s Safari and Google’s Chrome—now supports html5’s video tag. We’re still a long way from complete browser support, and a working standard. Ian Hickson, among other things, editor of the html5 spec lays the land out as follows:

“Apple refuses to implement Ogg Theora in Quicktime by default (as used by Safari), citing lack of hardware support and an uncertain patent landscape.

Google has implemented H.264 and Ogg Theora in Chrome, but cannot provide the H.264 codec license to third-party distributors of Chromium, and have indicated a belief that Ogg Theora’s quality-per-bit is not yet suitable for the volume handled by YouTube.

Opera refuses to implement H.264, citing the obscene cost of the relevant patent licenses.

Mozilla refuses to implement H.264, as they would not be able to obtain a license that covers their downstream distributors.

Microsoft has not commented on their intent to support <video> at all.”

So where does this leave us, still embedding video with the propriety Flash pluggin, well not exactly. Kroc Camen has a standards compliant, non-javascript alternative that takes advantage of html object-fallback. Yes the code is a little verbose, and adding non-native controls still requires javascript—but the concept seems sound and the extra work of compressing an Ogg Theora video is nothing to bork at.

This seems like a really cool way of allowing video for those without Flash, or unwilling to use Flash. I’d argue against it needing any attribution—as its a collection of html used in the expected way—although Kroc is the first to suggest this particular series of embeds.

Anyway, check it out and have fun with Video for Everyone.

2 comments » | flash, html, web

fbjs-bridge over troubled waters.

1:07 pm on October 21st, 2008, by Gareth Evans

Well I know that’s a bad title, but when you develop Facebook apps you need something to lighten your day and I’ve been developing them for the past six months.

The one thing I’ve noticed over all things is that nothing is simple, not even the simple things. You see Facebook take it upon themselves to screw with all of your code and what’s worse is that the documentation for what and how they’ve ‘altered’ it just seems quite cold and unnurturing.

For example, we developed an application that had a form, you see, a nice simple form sending POST data. If I was to tell you how long it took to figure out my code was fine and that Facebook had changed it to GET, then I’d probably blush.

It’s the accumulation of marginal dis-advantages that can grind Facebook development to a sickening halt. You sometimes feel like you spend more time discovering (the hard way) what you can’t do rather than getting on with the things you think you already can.

If I’m honest, it’s something I love to hate. Maybe it’s because every pit of despair has ended with a high-five, or maybe I’m just a masochist, either way here’s my latest  Facebook exploit:

Flash in Facebook isn’t that difficult, once you realise you need to use an Fb:swf tag that is. But one thing that could quite possibly bake your noodle is that no matter what you put in your AS3, navigating to a URL will always open in a new window.

In order to open a page in the same window via Flash, you are required to call Facebook JavaScript (fbjs.) This is achieved by using a LocalConnection method to call the fbjs method “document.setLocation” to navigate to the url passed, in this case “http://www.google.com.”

var connectionName:String = stage.loaderInfo.parameters.fb_local_connection;
var connection:LocalConnection = new LocalConnection();
var cResult = connection.send(connectionName, "callFBJS", "document.setLocation", ["http://www.google.com"]);

But it doesn’t stop there, no that would be too easy, you need to enable the fbjs bridge by putting the fbjs:bridge tag on your HTML page and this must also (no I don’t know why either, but it works) be accompanied by an empty script tag:

<fb:fbjs-bridge/>
<script> <!-- --> </script>

Ta da, a simple button in Flash that opens a URL in the same window.

8 comments » | development, flash, web

Share and Share alike at Acrobat.com

2:20 pm on June 3rd, 2008, by Gareth Evans

Adobe have launched a new ‘beta’ site under the strangely title Acrobat.com.

The site includes:

  • The acquired Buzzword which is basically an online word processor that allows a collaborative approach to writing documents etc.
  • Connect Now, which seems to be a rebranded version of Breeze, which includes screen sharing.
  • Share, if you can imagine Drop Send done by Adobe in Flash then you’re getting close. Share also includes ‘My Files’ and ‘Create PDF’ which as they sound enable you to get to your files and create PDF’s on the fly.

I’ve seen both Buzzword and Share before in their respective betas and both seem very polished. Acrobat.com has it’s own blog and like every good web 2.0 web application there’s nice API under the hood called ‘Document Services

Adobe Acrobat.com

Comment » | Adobe, web

Back to top