Flex 실행 시 ICON 로드

2077 단어 Flex

import com.benstucki.utilities.IconUtility;   
import mx.controls.Button;   
import mx.controls.ButtonBar;   
import mx.events.ChildExistenceChangedEvent;   
  
public function childAddedHandler(event:ChildExistenceChangedEvent):void  
{   
var buttonBar:ButtonBar = event.target as ButtonBar;   
var button:Button = event.relatedObject as Button;   
var data:Object = buttonBar.dataProvider;   
var key:String = "icon";   
  
var iconSource:String = data[buttonBar.getChildIndex(button)][key];   
button.setStyle("icon", IconUtility.getClass(button, iconSource));   
}  

import com.benstucki.utilities.IconUtility;
import mx.controls.Button;
import mx.controls.ButtonBar;
import mx.events.ChildExistenceChangedEvent;

public function childAddedHandler(event:ChildExistenceChangedEvent):void
{
var buttonBar:ButtonBar = event.target as ButtonBar;
var button:Button = event.relatedObject as Button;
var data:Object = buttonBar.dataProvider;
var key:String = "icon";

var iconSource:String = data[buttonBar.getChildIndex(button)][key];
button.setStyle("icon", IconUtility.getClass(button, iconSource));
}
  
<mx:Array id="testData">  
    <mx:Object id="button1"  
        label="Red Button"  
        icon="assets/redIcon.jpg" />  
    <mx:Object id="button2"  
        label="Green Button"  
        icon="assets/greenIcon.jpg" />  
    <mx:Object id="button3"  
        label="Blue Button"  
        icon="assets/blueIcon.jpg" />  
</mx:Array>  
  
<mx:ButtonBar id="buttonBar"  
    dataProvider="{testData}"  
    childAdd="childAddedHandler(event);">  
</mx:ButtonBar>

참고: 첨부 파일에서 제공하는 IconUtility 구성 요소에 의존합니다.

좋은 웹페이지 즐겨찾기