Displaying External Images in Flex

by adam

Recently I had to find a method to include external images in a flex project.
After much searching I found the following which was the simplest:

First, you must check the domain you are pulling images from to make sure
that they allow access in their crossdomain.xml file:

<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>

Now the code…

	[Bindable]
	var loaderContext:LoaderContext;
	private function imageInit():void {
    	 loaderContext = new LoaderContext();
     	 loaderContext.checkPolicyFile = true;
	}

and the mxml for the image…

<mx:Image source="{your-picture-here}"
initialize="imageInit()" loaderContext="{loaderContext}"/>