Return to Snippet

Revision: 43234
at March 19, 2011 18:42 by kanuwadhwa


Initial Code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
	<mx:Script>
		<![CDATA[
			// second highest element in an array
			public var arr:Array = new Array("23", "12", "45", "22", "42", "87", "97", "13")
			public function init():void{
				arr.sort();
				txt.text = arr[arr.length - 2] // 87
				for(var i=0;i<arr.length;i++){
					txt.text += "\n "+arr[i];					
				}
			}
		]]>
	</mx:Script>
	<mx:TextArea x="118" y="57" width="553" height="412" id="txt"/>
</mx:Application>

Initial URL


Initial Description
Looking forward for the most optimized solution for the same

Initial Title
Second highest element in an array

Initial Tags
actionscript, flash, Flex

Initial Language
ActionScript 3