{"id":8827,"date":"2014-12-12T06:02:06","date_gmt":"2014-12-12T06:02:06","guid":{"rendered":"http:\/\/2slick.com\/web\/?p=8827"},"modified":"2014-12-12T06:02:06","modified_gmt":"2014-12-12T06:02:06","slug":"remove-duplicate-variable-from-array-in-as3","status":"publish","type":"post","link":"https:\/\/2slick.com\/web\/remove-duplicate-variable-from-array-in-as3\/affordablewebsitestips\/tutorials","title":{"rendered":"Remove duplicate variable from array in as3"},"content":{"rendered":"<p>Below is a function that removes duplicated from an array in ActionScript 3. Just pass the function a variable name.<\/p>\n<p><!--DEVFMTCODE--><pre class=\"devcodeblock\" title=\"Javascript\"><table class=\"devcodetools\"><tbody><tr><td>&nbsp;Javascript&nbsp;|&nbsp;<\/td><td style=\"background-image:url('https:\/\/2slick.com\/web\/wp-content\/plugins\/devformatter\/img\/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;\"\/><embed id=\"ZeroClipboard1\" src=\"https:\/\/2slick.com\/web\/wp-content\/plugins\/devformatter\/_zclipboard.swf\" loop=\"false\" menu=\"false\" quality=\"best\" bgcolor=\"#ffffff\" width=\"16px\" height=\"16px\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" flashvars=\"id=1&width=16&height=16\" wmode=\"transparent\" \/><\/td><td>&nbsp;copy&nbsp;code&nbsp;|<\/td><td style=\"cursor:pointer\" title=\"DevFormatter Plugin\" onclick=\"devfmt_credits()\">?<\/td><td width=\"99%\">&nbsp;<\/td><\/tr><\/tbody><\/table><div class=\"devcodeoverflow\"><table class=\"devcodearea\" width=\"100%\"><tr><td class=\"devcodelines\" width=\"1%\">01<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\"><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">02<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\"><span style=\"color: #003366; font-weight: bold;\">function<\/span> removeDuplicate<span style=\"color: #009900;\">&#40;<\/span>arr<span style=\"color: #339933;\">:<\/span>Array<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">void<\/span><span style=\"color: #009900;\">&#123;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">03<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">    <span style=\"color: #003366; font-weight: bold;\">var<\/span> i<span style=\"color: #339933;\">:<\/span>int<span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">04<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">    <span style=\"color: #003366; font-weight: bold;\">var<\/span> j<span style=\"color: #339933;\">:<\/span> int<span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">05<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">    <span style=\"color: #000066; font-weight: bold;\">for<\/span> <span style=\"color: #009900;\">&#40;<\/span>i <span style=\"color: #339933;\">=<\/span> <span style=\"color: #CC0000;\">0<\/span><span style=\"color: #339933;\">;<\/span> i <span style=\"color: #339933;\">&lt;<\/span> arr.<span style=\"color: #660066;\">length<\/span> <span style=\"color: #339933;\">-<\/span> <span style=\"color: #CC0000;\">1<\/span><span style=\"color: #339933;\">;<\/span> i<span style=\"color: #339933;\">++<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">06<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">        <span style=\"color: #000066; font-weight: bold;\">for<\/span> <span style=\"color: #009900;\">&#40;<\/span>j <span style=\"color: #339933;\">=<\/span> i <span style=\"color: #339933;\">+<\/span> <span style=\"color: #CC0000;\">1<\/span><span style=\"color: #339933;\">;<\/span> j <span style=\"color: #339933;\">&lt;<\/span> arr.<span style=\"color: #660066;\">length<\/span><span style=\"color: #339933;\">;<\/span> j<span style=\"color: #339933;\">++<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">07<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">            <span style=\"color: #000066; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span>arr<span style=\"color: #009900;\">&#91;<\/span>i<span style=\"color: #009900;\">&#93;<\/span> <span style=\"color: #339933;\">===<\/span> arr<span style=\"color: #009900;\">&#91;<\/span>j<span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">08<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">                arr.<span style=\"color: #660066;\">splice<\/span><span style=\"color: #009900;\">&#40;<\/span>j<span style=\"color: #339933;\">,<\/span> <span style=\"color: #CC0000;\">1<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">09<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">            <span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">10<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">        <span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">11<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">    <span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">12<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\"><span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">13<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\"><\/pre><\/td><\/tr><\/table><\/div><\/pre><!--END_DEVFMTCODE--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below is a function that removes duplicated from an array in ActionScript 3. Just pass the function a variable name. &nbsp;Javascript&nbsp;|&nbsp;&nbsp;copy&nbsp;code&nbsp;|?&nbsp;0102function removeDuplicate&#40;arr:Array&#41; : void&#123;03 var i:int;04 var j: int;05 for &#40;i = 0; i &lt; arr.length &#8211; 1; i++&#41;&#123;06 for &#40;j = i + 1; j &lt; arr.length; j++&#41;&#123;07 if &#40;arr&#91;i&#93; === arr&#91;j&#93;&#41;&#123;08 arr.splice&#40;j, 1&#41;;09 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[749],"class_list":["post-8827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-flash-professional"],"_links":{"self":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/comments?post=8827"}],"version-history":[{"count":1,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8827\/revisions"}],"predecessor-version":[{"id":8828,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8827\/revisions\/8828"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/media\/8748"}],"wp:attachment":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/media?parent=8827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/categories?post=8827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/tags?post=8827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}