MXML FILE
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderColor="#8E9294" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#676767, #464444]">
<mx:Script>
<![CDATA[
public var arraydata:Array;
public function retriveUniqueVal():void
{
arraydata=new Array(1,2,4,1,"kaniskar",4,5,6,"kaniskar",8,1,2,4,5);
removeDuplicates(arraydata);
outputVal.text=removeDuplicates(arraydata).toString();
trace(removeDuplicates(arraydata).toString());
}
/* Unique Value function */
public var tempArray:Array;
private function removeDuplicates(arr:Array):Array
{
var currentValue:String = "";
tempArray=new Array();
arr.sort(Array.CASEINSENSITIVE);
arr.forEach(
function(item:*, index:uint, array:Array):void {
if (currentValue != item) {
tempArray.push(item);
currentValue= item;
}
}
);
return tempArray.sort(Array.CASEINSENSITIVE);
}
]]>
</mx:Script>
<mx:Button x="429" y="234" label="Take Value" click="retriveUniqueVal()"/>
<mx:Label x="133" y="181" text="Input Values are:" color="#FFFFFF" fontStyle="normal" fontWeight="normal" fontFamily="Arial" fontSize="16"/>
<mx:Label x="120" y="231" text="Output Values are:" color="#FFFFFF" fontStyle="normal" fontWeight="normal" fontFamily="Arial" fontSize="16"/>
<mx:TextInput x="262" y="184" editable="false" id="inputVal" text="1,2,4,1,kaniskar,4,5,6,kaniskar,8,1,2,4,5"/>
<mx:TextInput x="263" y="234" editable="false" id="outputVal"/>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderColor="#8E9294" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#676767, #464444]">
<mx:Script>
<![CDATA[
public var arraydata:Array;
public function retriveUniqueVal():void
{
arraydata=new Array(1,2,4,1,"kaniskar",4,5,6,"kaniskar",8,1,2,4,5);
removeDuplicates(arraydata);
outputVal.text=removeDuplicates(arraydata).toString();
trace(removeDuplicates(arraydata).toString());
}
/* Unique Value function */
public var tempArray:Array;
private function removeDuplicates(arr:Array):Array
{
var currentValue:String = "";
tempArray=new Array();
arr.sort(Array.CASEINSENSITIVE);
arr.forEach(
function(item:*, index:uint, array:Array):void {
if (currentValue != item) {
tempArray.push(item);
currentValue= item;
}
}
);
return tempArray.sort(Array.CASEINSENSITIVE);
}
]]>
</mx:Script>
<mx:Button x="429" y="234" label="Take Value" click="retriveUniqueVal()"/>
<mx:Label x="133" y="181" text="Input Values are:" color="#FFFFFF" fontStyle="normal" fontWeight="normal" fontFamily="Arial" fontSize="16"/>
<mx:Label x="120" y="231" text="Output Values are:" color="#FFFFFF" fontStyle="normal" fontWeight="normal" fontFamily="Arial" fontSize="16"/>
<mx:TextInput x="262" y="184" editable="false" id="inputVal" text="1,2,4,1,kaniskar,4,5,6,kaniskar,8,1,2,4,5"/>
<mx:TextInput x="263" y="234" editable="false" id="outputVal"/>
</mx:Application>
OUTPUT