About
Projects
Photos
Links


Latest Blog Entries:
Text Flow Images
Posted: 2009-11-28 16:45:28

The problem came up where I needed to figure out how to use Base64 embedded images within text layout format xml that would then be imported into a text flow.

My first attempts were trying to use the id attribute so that I could use getElementById(), then attempting to use the IConfiguration inlineGraphicResolver; at one point I even tried wrapping the whole thing into a span tag and trying to link that tag with a dictionary of the Base64 images. All of those didn't seem to do the trick, mainly because each time the inlineGraphicElement.graphic property was null, and, of course, that property is read only.

The way I finally was able to make it work was to use the event listener from the StatusChangeEvent. Immediately after the text flow is created (via the TextConverter.importToFlow), add in the event listener:
textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE, updateImages);

Then, the function updateImages:
private function updateImages(event:StatusChangeEvent):void
{
  var element:InlineGraphicElement = event.element as InlineGraphicElement;
  if(element.graphic != null && event.status != InlineGraphicElementStatus.READY)
  {
    var graphic:Loader = element.graphic as Loader;
    var source:String = element.source as String;
    if(source != null)
    {
      var subSource:String = source.substr(-4,4);
      if(subSource != ".jpg" && subSource != ".gif" && subSource != ".png" && subSource != "jpeg")
      {
        var decoder:Base64Decoder = new Base64Decoder();
        decoder.decode(source);
        graphic.loadBytes(decoder.toByteArray());
      }
    }
  }
  textFlow.flowComposer.updateAllControllers();
}

This solves the issue of the graphic element being null and at the same time will only replace the loader once (as it won't try to replace the whole thing again when the image status is ready). This will also allow regular paths to pass through without being turned into base64 strings, so that you don't just have to use one or the other.

Silver Clio Award
Posted: 2009-11-28 05:17:45
Link: http://www.penbaymedia.com/news/news_detail.htm?id=50

A project I worked on a year or so back has just been awarded a silver Clio Award! The link will take you to the press release from PenBay.

The project was for the AAOS 75th anniversary - I created the interactive timeline application that was shown during the conference on some large displays as people entered (you can see it on my projects page). There were multiple kiosks set up to use the application and if they became inactive over a period of a couple minutes, each would join together to form one large timeline image that used all screens.

It was really just a small piece of the overall project (a project that spanned a couple of years for many involved), and most of the praise goes to POE and the team that they have for putting it all together. Pretty exciting though to get some national recognition like that for a small company in the state of Maine!