flash on 2013-3-11
♥0 |
Line 38 |
Modified 2014-02-15 16:40:14 |
MIT License
archived:2017-03-20 05:03:01
ActionScript3 source code
/**
* Copyright hacker_tmbt9fl2 ( http://wonderfl.net/user/hacker_tmbt9fl2 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vgBh
*/
package {
import flash.text.TextFormat;
import flash.text.TextField;
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var _time:Number;
public function FlashTest() {
// write as3 code here..
var txt:TextField = new TextField();
var fmt:TextFormat = new TextFormat(null, 20);
txt.defaultTextFormat = fmt;
txt.width = stage.stageWidth;
txt.x = txt.y = 20;
addChild(txt);
var b:Boolean = (checkio([1, 2, 3, 1, 3]) == [1, 3, 1, 3]);
txt.text = String(b);
var msg:String = ": result = " + checkio([1, 2, 3, 1, 3]);
txt.appendText(msg);
}
private function checkio(arr:Array):Array
{
var res:Array = [];
var unique:Object = {};
var listA:Array = arr.concat();
var i:int;
for (i = 0; i < listA.length; i++)
{
var key:int = listA[i];
unique[key] = 0;
if (!(key in unique))
{
unique[key] += 1;
if (unique[key] >= 1) res.push(key);
}
}
return res;
}
}
}