Use iconFunction to determine the icon to display : Icon « Graphics « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Graphics » IconScreenshots 
Use iconFunction to determine the icon to display
Use iconFunction to determine the icon to display
         
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        [Embed(source="logo.jpg")]
        public var imageIcon1:Class;
        [Embed(source="logo.jpg")]
        public var normalSymbol:Class;
        private var myData: Array;
        private function initList():void {
            myData = [{Artist:'A', Album:'AA',Price:1.99},
                      {Artist:'B', Album:'BB',Price:1.99},
                      {Artist:'C', Album:'CC',Price:5.99}];
            list1.dataProvider = myData;
        }
        private function myiconfunction(item:Object):Class{
            var type:String = item.Artist;
            if (type == "A") {
                return imageIcon1;
            }
            return normalSymbol;
        }
      
    </mx:Script>
    <mx:VBox>
        <mx:List id="list1" initialize="initList()" labelField="Artist" iconFunction="myiconfunction" />
    </mx:VBox>
</mx:Application>

   
    
    
    
    
    
    
    
    
  
Related examples in the same category
1.Bind icon to classBind icon to class
2.Set the default leaf icon to null to hide it, and uses custom icons for the folder open and closed iconsSet the default leaf icon to null to hide it, and uses custom icons for the folder open and closed icons
3.Adding an icon to the buttonAdding an icon to the button
w___w__w_.j___a___v_a___2__s___.___c___o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.