Mastercard Priceless Travel Flex app now live

After many weeks of hard work the Mastercard Priceless Travel Flex 3 application I’ve been working on has now also gone live. I worked on the project as sole Flex developer / Flex architect, together with a team of talented and enthusiastic people. It was another project I completed for MRM Worldwide in London and I thoroughly enjoyed it as always.

Apart from Flex 3, the project also uses the PureMVC framework. I’ve been using it for a few projects now and have to say that overall I’m very happy with it’s structure. The Priceless Travel application had some major changes applied to it during the development lifecycle and architecturally speaking they were all handled with ease.

You can view the project via the link from my online portfolio.

Intel GameOn video/image gallery now live

The newly developed Intel GameOn site has now gone live – and with it the two Flash components that I developed for it.

Both components are used extensively throughout the site to show pictures and videos related to particular games, articles and other content.

Read further details on the updated portfolio page.

Flex UIComponent subclass needs to resize images

The title could do with some improving – what I’m trying to say is that when subclassing UIComponent, any Image component instances need to be given an appropriate width/height. I have overlooked this time and time again, only to find that the image doesn’t appear – because it’s width and height are initialised to zero.

The following code will result in an image with zero width/height, so the image won’t show:

var img:Image = new Image();
img.source = "myfile.jpg";

Solutions:

  1. Assign specific values for width and height:
    img.width = 100;
    img.height = 100;
  2. Set the ‘scaleContent’ property to false – the image will then resize its container automatically, once it has loaded. Note that this technique has no effect if loading image from non-trusted domains!
    img.scaleContent = false;
     
    // or, if loading cross-domain, provided a crossdomain policy file allows access
    img.trustContent = true;
    img.scaleContent = false;
  3. Use an event listener to detect when the image has finished loading, then assign the correct width and height. Again, this will only work if the image has been loaded from a trusted domain.
    img.addEventListener(Event.COMPLETE, onImageComplete);
     
    protected function onImageComplete(evt:Event):void
    {
        var img:Image = evt.target as Image;
        img.removeEventListener(Event.COMPLETE, onImageComplete);
        img.width = img.content.width;
        img.height = img.content.height;
    }

I’ve mainly blogged about it so I remember the next time I write some code – but maybe it will also help somebody else debug their missing image problems.

Crossdomain Flex and Flash SOAP Webservice access

Here’s a quick guide on how to get crossdomain access working for SOAP Webservices from Flash and Flex. Obviously you need to allow access to the domain, however it’s more difficult to realise that you also need to allow the SOAP headers to be sent to the foreign server.

Here is an example crossdomain file that does just that – amend to suit your own requirements, the * wildcard is probably not what you need for your production server.

 

Accessing flashvars in a custom Flex preloader

Here’s a little code snippet that allows you to access flashvar parameters inside a custom Flex preloader.

The custom preloader class extends Sprite and implements the IPreloaderDisplay class. Once the Sprite’s ‘root’ property becomes available, you can use the standard AS3 way of accessing flashvars, namely:

var flashvars:Object = root.loaderInfo.parameters;

This code should be used once the ‘root’ property has been initialised – for example in the ‘initialize()’ method defined by the IPreloaderDisplay interface:

public function initialize():void
{
     var flashvars:Object = root.loaderInfo.parameters;
}

Just for reference, compare the above approach with the standard Flex method of accessing flashvar parameters – which becomes possible once the main Application instance has been created:

var flashvars:Object = Application.application.parameters