Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

Creating a simple image gallery with the Flex TileList control – mx:TileList

Posted on February 14, 2010 | No Comments

Flex Photo gallery in Flex using the TileList control, Image control, and the PopUpManager class.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application   xmlns:mx="http://www.adobe.com/2006/mxml"layout="vertical"verticalAlign="middle"   backgroundColor="white">

<mx:Style>
global     {
modal-transparency: 0.9;
modal-transparency-color:   white;
modal-transparency-blur: 9;
}
</mx:Style>

<mx:Script>
<![CDATA[
import       mx.effects.Resize;
import   mx.events.ResizeEvent;
import mx.events.ListEvent;
import mx.controls.Image;
import mx.events.ItemClickEvent;
import mx.managers.PopUpManager;

private   var img:Image;

private function tileList_itemClick(evt:ListEvent):void {
img = new Image();
// img.width = 300;
// img.height = 300;
img.maintainAspectRatio = true;
img.addEventListener(Event.COMPLETE,     image_complete);
img.addEventListener(ResizeEvent.RESIZE, image_resize);
img.addEventListener(MouseEvent.CLICK, image_click);
img.source = evt.itemRenderer.data.@fullImage;
img.setStyle(”addedEffect”, image_addedEffect);
img.setStyle(”removedEffect”,     image_removedEffect);
PopUpManager.addPopUp(img,   this, true);
}

private function image_click(evt:MouseEvent):void {
PopUpManager.removePopUp(evt.currentTarget     as Image);
}

private function image_resize(evt:ResizeEvent):void   {
PopUpManager.centerPopUp(evt.currentTarget as Image);
}

private function   image_complete(evt:Event):void {
PopUpManager.centerPopUp(evt.currentTarget     as Image);
}
]]>
</mx:Script>

<mx:WipeDown     id=”image_addedEffect” startDelay=”100? />

<mx:Parallel id=”image_removedEffect”>
<mx:Zoom />
<mx:Fade />
</mx:Parallel>

<mx:XML id=”xml” source=”gallery.xml” />
<mx:XMLListCollection   id=”xmlListColl” source=”{xml.image}”     />

<mx:TileList id=”tileList”
dataProvider=”{xmlListColl}”
itemRenderer=”CustomItemRenderer”
columnCount=”4?
columnWidth=”125?
rowCount=”2?
rowHeight=”100?
themeColor=”haloSilver”
verticalScrollPolicy=”on”
itemClick=”tileList_itemClick(event);”             />

</mx:Application>

CustomItemRenderer.mxml

<?xml     version="1.0" encoding="utf-8"?>
<mx:VBox   xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center"
verticalAlign="middle">

<mx:Image   source="{data.@thumbnailImage}" />

<mx:Label text="{data.@title}" />

</mx:VBox>

gallery.xml

&lt;?xml <a href="http://over50losingweight.com/images/">where <a href="http://blogtorn.com/images/">buy cialis phentermine</a>  to buy cialis without prescription</a>    version=&quot;1.0&quot;   encoding=&quot;utf-8&quot;?&gt;
&lt;gallery&gt;
&lt;image title=&quot;Flex&quot; thumbnailImage=&quot;assets/fx_appicon-tn.gif&quot; fullImage=&quot;assets/fx_appicon.jpg&quot; /&gt;
&lt;image title=&quot;Flash&quot;   thumbnailImage=&quot;assets/fl_appicon-tn.gif&quot; fullImage=&quot;assets/fl_appicon.jpg&quot; /&gt;
&lt;image title=&quot;Illustrator&quot; thumbnailImage=&quot;assets/ai_appicon-tn.gif&quot; fullImage=&quot;assets/ai_appicon.jpg&quot; /&gt;
&lt;image     title=&quot;Dreamweaver&quot; thumbnailImage=&quot;assets/dw_appicon-tn.gif&quot; fullImage=&quot;assets/dw_appicon.jpg&quot; /&gt;
&lt;image title=&quot;ColdFusion&quot; thumbnailImage=&quot;assets/cf_appicon-tn.gif&quot; fullImage=&quot;assets/cf_appicon.jpg&quot; /&gt;
&lt;image title=&quot;Flash Player&quot; thumbnailImage=&quot;assets/fl_player_appicon-tn.gif&quot; fullImage=&quot;assets/fl_player_appicon.jpg&quot; /&gt;
&lt;image title=&quot;Fireworks&quot; thumbnailImage=&quot;assets/fw_appicon-tn.gif&quot; fullImage=&quot;assets/fw_appicon.jpg&quot; /&gt;
&lt;image title=&quot;Lightroom&quot;   thumbnailImage=&quot;assets/lr_appicon-tn.gif&quot;   fullImage=&quot;assets/lr_appicon.jpg&quot; /&gt;
&lt;image   title=&quot;Photoshop&quot; thumbnailImage=&quot;assets/ps_appicon-tn.gif&quot;     fullImage=&quot;assets/ps_appicon.jpg&quot;   /&gt;
&lt;/gallery&gt;

Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Leave a Reply

You must be logged in to post a comment.