실제로는 바인딩을 처리하는 적절한 방법 인 FlexEvent.DATA_CHANGE
처리기를 사용하고 훨씬 더 많은 제어권을 제공합니다.
public function CustomItemRenderer() {
this.addEventListener(FlexEvent.DATA_CHANGE, this.dataChangeHandler);
this.addEventListener(FlexEvent.CREATION_COMPLETE, this.creationCompleteHandler);
}
private function creationCompleteHandler(e:FlexEvent) {
if (this.data) {
this.image.source = this.data.itemRendererData.imageURL;
}
}
private function dataChangeHandler(e:FlexEvent) {
if (this.data && this.initialized) {
this.image.source = this.data.itemRendererData.imageURL;
}
}
FlexEvent.CREATION_COMPLETE
에 대한 처리기가 있습니다. 이는 구성 요소가 작성되기 전에 데이터가 실제로 설정되기 때문입니다. 따라서 처음 렌더러가로드 될 때 this.image
은 null이고 this.image.source
은 오류가 발생합니다.
그래도 작동하지 않는 경우 Image
/BitmapImage
이 렌더러의 직접 하위가 아닌지 확인해야합니다. 왜 이렇게되었는지 알아 내지 못했지만, Group
의 자식으로 이미지를 설정했지만 렌더링하지 않는 문제가 수정되었습니다. 다시 한 번, 나는 이것이 왜 있었는지 전혀 알지 못한다. 그리고 나는 그것을 이해하려고 몇 시간 동안 시험했다.
추가 팁으로 모바일 애플리케이션에서 MXML 기반 ItemRenderer를 사용하지 마십시오. 순수 AS3 렌더러보다 눈에 띄게 느립니다.
솔루션이 효과적입니다. 그리고 내 솔루션에서 오류를 찾을 수있었습니다. itemRendererData를 전달하기 때문에 소스의 "data"는 이제 "itemRendererData"를 참조합니다. 그래서 옳은 것은 source = {data.imageURL}; – akashrajkn