2009-10-27 1 views
1

Flex에 익숙하지 않고 ArrayCollection에 바인딩 된 TileList를 사용하고 있습니다. 로드 할 때 배열 컬렉션이 비어 있고 오전 HTTPService 호출의 결과로 업데이트됩니다. 문제는 항목 렌더러가 예상대로 렌더링되지 않는다는 것입니다.로드 타임에 처음 렌더링 될 때 데이터가 없었기 때문에 짐작할 수 있습니다. 여기서 간단한 예이다 :Flex :로드시 빈 ArrayCollection에 바인딩 된 구성 요소가 ArrayCollection이 업데이트 될 때 예상대로 렌더링되지 않습니다.

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

    <mx:Script> 
    <![CDATA[ 

     import mx.collections.ArrayCollection; 

     [Bindable] 
     public var myList1:ArrayCollection = new ArrayCollection(); 

     [Bindable] 
     public var myList2:ArrayCollection = new ArrayCollection([{item:"foo"}, {item:"bar"}]); 

     public function updateMyList():void 
     { 
      myList1.source = [{item:"foo"}, {item:"bar"}]; 
     } 

    ]]> 
    </mx:Script> 

<mx:Button id="myButton" label="Update My List" 
      click="updateMyList();"/> 


    <mx:TileList dataProvider="{myList1}" 
      direction="vertical" 
      width="800" > 

    <mx:itemRenderer> 

     <mx:Component > 

    <mx:Canvas backgroundColor="yellow" > 
     <mx:Label text="{data.item}" width="800" /> 
    </mx:Canvas> 

     </mx:Component> 

    </mx:itemRenderer> 

    </mx:TileList> 


<!-- This one renders as expected --> 

    <mx:TileList dataProvider="{myList2}" 
      direction="vertical" 
      width="800" > 

    <mx:itemRenderer> 

     <mx:Component > 

    <mx:Canvas backgroundColor="yellow" > 
     <mx:Label text="{data.item}" width="800" /> 
    </mx:Canvas> 

     </mx:Component> 

    </mx:itemRenderer> 

    </mx:TileList> 

</mx:Application> 

하면 그 바인딩로드시 데이터가 (폭 800 픽셀)를 예상대로 렌더링 제 TileList 구성은 정확한 폭 아니며 주위 스크롤바를 가지고 렌더링 제 TileList 구성 비트 알 것이다.

아무도 왜 이것이 일어나고 있는지 또는 이것을 피하기 위해 몇 가지 해결 방법을 제공 할 수 있습니까?

감사합니다,

크리스

답변

1

는이 섹션이 문제를 일으키는 가능성이 높습니다 :

public function updateMyList():void 
      { 
       myList1.source = [{item:"foo"}, {item:"bar"}]; 
      } 

here에서 : ArrayCollection에 데이터의

소스. ArrayCollection 객체는 을 소스 배열에 직접 변경 한 내용을 으로 나타내지 않습니다. 항상 ICollectionView 또는 IList 메서드를 사용하여 컬렉션을 수정하십시오.

이 속성은 데이터 바인딩을위한 소스로 사용할 수 있습니다. 이 속성이 수정되면 listChanged 이벤트를 전달합니다.

myList1= new ArrayCollection([{item:"foo"}, {item:"bar"}]);

:

그래서 나는 아마도 라인을 변경할 것

0

http://livedocs.adobe.com/flex/3/langref/mx/controls/TileList.html 확인 API.

<mx:TileList dataProvider="{myList1}" 
        direction="vertical" 
        width="800" columnWidth="800" rowHeight="25"> 

아마 그것을 할 수있는 더 "적절한"방법이있다,이 같은 columnWidth의 property 및 rowHeight 속성을 설정하지만, 그건 당신이 시작할 수 있어야합니다.

관련 문제