<?xml version="1.0" encoding="utf-8"?>

<!--
Copyright (c) 2007 FlexLib Contributors.  See:
    http://code.google.com/p/flexlib/wiki/ProjectContributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->

<!--
	The IconLoader component behaves in much the same way as mx:Image, except that it parses icon files 
	instead of png, jpeg, etc. Both Macintosh .icns and Windows .ico files are supported. Only 32 bit
	icons from either format are supported. For Windows, this means that Windows XP icons are supported,
	but not the older style. For Macintosh, this means that icon formats 'il32', 'ih32', etc. and their
	correspnding masks are supported, but not il8, etc.
	
	The 'source' property of an IconLoader object can be set either to a String representing a URL,
	in which case the icon is loaded using a URLLoader object, or to a subclass of ByteArray, 
	created using the @Embed(...) directive. Note that the mime-type of the @Embed directive must
	be 'application/octet-stream'.
-->
 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
	xmlns:iconloader="flexlib.controls.*">
		
	<mx:HBox>
		<mx:VBox>	
			<mx:Panel title="Embedded .icns" width="250" height="250" layout="absolute">	
				<iconloader:IconLoader width="16" height="16" verticalCenter="0" horizontalCenter="0"
					id="il1" 
					scaleContent="false"
					source="@Embed( source='icons/GenericApplicationIcon.icns', mimeType='application/octet-stream' )]"/>						
				<mx:ControlBar>
					<mx:HSlider width="120" value="16" minimum="16" maximum="128" liveDragging="true" snapInterval="1"
						change="il1.width = event.target.value;il1.height = event.target.value"/>
					<mx:CheckBox label="Scale" selected="{il1.scaleContent}" change="il1.scaleContent = event.target.selected"/>
				</mx:ControlBar>	
			</mx:Panel>
			<mx:Panel title="Linked .icns" width="250" height="250" layout="absolute">		
				<iconloader:IconLoader width="128" height="128" verticalCenter="0" horizontalCenter="0"
					id="il2" 
					scaleContent="false"
					source="icons/GenericApplicationIcon.icns"/>		
				<mx:ControlBar>
					<mx:TextInput id="ti2" width="100%" text="{il2.source}"/>
					<mx:Button label="Load" click="il2.source = ti2.text"/>
				</mx:ControlBar>
			</mx:Panel>
		</mx:VBox> 
		<mx:VBox>	
			<mx:Panel title="Embedded .ico" width="250" height="250" layout="absolute">	
				<iconloader:IconLoader width="16" height="16" verticalCenter="0" horizontalCenter="0"
					id="il3" 
					scaleContent="false"
					source="@Embed( source='icons/Computer.ico', mimeType='application/octet-stream' )]"/>						
				<mx:ControlBar>
					<mx:HSlider width="120" value="16" minimum="16" maximum="128" liveDragging="true" snapInterval="1"
						change="il3.width = event.target.value;il3.height = event.target.value"/>
					<mx:CheckBox label="Scale" selected="{il3.scaleContent}" change="il3.scaleContent = event.target.selected"/>
				</mx:ControlBar>	
			</mx:Panel>
			<mx:Panel title="Linked .ico" width="250" height="250" layout="absolute">		
				<iconloader:IconLoader width="128" height="128" verticalCenter="0" horizontalCenter="0"
					id="il4" 
					scaleContent="false"
					source="icons/Computer.ico"/>		
				<mx:ControlBar>
					<mx:TextInput id="ti4" width="100%" text="{il4.source}"/>
					<mx:Button label="Load" click="il4.source = ti4.text"/>
				</mx:ControlBar>
			</mx:Panel>
		</mx:VBox>
	</mx:HBox>	
	
</mx:Application>
