Load an AVIs IMDB page with Flex/Actionscript

by mattm on February 1, 2009

in Software

I’m working a bit more on my media manager, and cooked up this useful code that others may benefit from. It uses the TRYNT Movie IMDB Web Service (v2) which, given a search term will return some IMDB URLs. Surprisingly, IMDB has no public API, so the TRYNT guys are using a data replica from IMDB on their own database I think… Here is the first pass code… I’m cleaning it up locally but it is good enough to see how this works…

private function openIMDB(aviName:String):void {
  var movieName:String = aviName.slice(0, aviName.indexOf("."));
  var svc:HTTPService = new HTTPService();
  var vars:URLVariables = new URLVariables();
  vars.t = movieName;
  svc.url = "http://www.trynt.com/movie-imdb-api/v2/?" + vars.toString();
  svc.resultFormat = "e4x";
  svc.addEventListener("result",handleIMDBQuery);
  svc.send();
}
private function handleIMDBQuery(event:ResultEvent):void {
  if (event.result['movie-imdb'].error == "true") {
    mx.controls.Alert.show("Unable to find this movie on IMDB.", "IMDB error");
  }
  else {
    var url:String = event.result['movie-imdb']['matched-url'];
    navigateToURL(new URLRequest(url), "_blank");
  }
}

Note to the TRYNT people… My application is for personal use, so I’ll put the attribution right here. If I ever publish the AIR app, I’ll include your icon and a link to it…

Leave a Comment

Previous post:

Next post: