Tile List Custom Effect and Default Effect
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".
This user guide is licensed for use under the terms of the Creative Commons Attribution
Non-Commercial 3.0 License.
This License allows users to copy, distribute, and transmit the user guide for noncommercial
purposes only so long as
(1) proper attribution to Adobe is given as the owner of the user guide; and
(2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms.
The best way to provide notice is to include the following link.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
-->
<!-- dataEffects\TileListEffectCustomDefaultEffect.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"
height="500">
<s:layout>
<s:VerticalLayout />
</s:layout>
<fx:Script>
import mx.effects.DefaultTileListEffect;
import mx.effects.easing.Elastic;
import mx.collections.ArrayCollection;
import mx.effects.Move;
[Bindable]
private var myDP:ArrayCollection = new ArrayCollection(["A","B",'C','D','E','F','G','H','I','J','K','L','M','N','O','P']);
private function deleteItems():void {
// As each item is removed, the index of the other items changes.
// So first get the items to delete, and then determine their indices
// as you remove them.
var toRemove:Array = [];
for (var i:int = 0; i < tlist0.selectedItems.length; i++)
toRemove.push(tlist0.selectedItems[i]);
for (i = 0; i < toRemove.length; i++)
myDP.removeItemAt(myDP.getItemIndex(toRemove[i]));
}
private var zcount:int = 0;
private function addItems():void {
myDP.addItemAt("Z"+zcount++,Math.min(2,myDP.length));
}
</fx:Script>
<fx:Declarations>
<!--
Define an instance of the DefaultTileListEffect effect, and set its
moveDuration and color properties.
-->
<mx:DefaultTileListEffect id="myDTLE"
moveDuration="100" />
</fx:Declarations>
<mx:TileList id="tlist0" height="400" width="400"
columnCount="4" rowCount="4" fontSize="30" fontWeight="bold"
direction="horizontal" dataProvider="{myDP}" allowMultipleSelection="true"
offscreenExtraRowsOrColumns="2" itemsChangeEffect="{myDTLE}" />
<mx:Button label="Delete Selected Item(s)" click="deleteItems();" />
<mx:Button label="Add Item" click="addItems();" />
</s:Application>
Related examples in the same category