2017-02-28 12 views
-1

에있는 ArrayCollection에서 중복 값을 제거합니다. \ 을 내 코드는 여기에, 그 작동하지 저에게 알려주십시오, 저는 유연한 초보자입니다. 고맙습니다.이 난 제품 이름의 중복 값이이 배열 내 ArrayCollection에</p> <pre><code>o = JSON.parse(event.result.toString()); jsonarray = new ArrayCollection(o as Array); </code></pre> <p>, 그래서 내가 duplicacy을 제거하고 싶어 flex4

function removeDuplicates(item:Object):Boolean 
{ 
    var returnValue:Boolean = false; 
    if (!myObject.hasOwnProperty(item.ProductName)) 
    { 
     myObject[item.ProductName] = item; 
     returnValue = true; 
    } 
    prodArray.push(myObject); 
    return returnValue; 
} 
+0

VAR 오 : 개체; 최대한 빨리 회신 해주십시오. 그것의 긴급한 –

+0

가능한 중복의 [플래시 as3 어떻게 내가 배열에서 중복을 제거합니까?] (http://stackoverflow.com/questions/5997822/flash-as3-how-do-i-remove-duplicates-in-an- 정렬) – Clintm

답변

0

전화 아래에 그에서 주어진 filterCollection 방법은 중복

를 제거 filterFunction의를 사용
private var tempObj:Object = {}; 

private function filterCollection():void { 
    // assign the filter function 
    jsonarray.filterFunction = removeDuplicates; 
    //refresh the collection 
    jsonarray.refresh(); 
} 

private function removeDuplicates(item:Object):Boolean { 
    return (tempObj.hasOwnProperty(item.ProductName) ? false : tempObj[item.ProductName] = item && true); 
}