{"id":8825,"date":"2014-12-12T05:59:19","date_gmt":"2014-12-12T05:59:19","guid":{"rendered":"http:\/\/2slick.com\/web\/?p=8825"},"modified":"2014-12-12T05:59:19","modified_gmt":"2014-12-12T05:59:19","slug":"remove-variable-from-array-based-on-variable-name-in-as3","status":"publish","type":"post","link":"https:\/\/2slick.com\/web\/remove-variable-from-array-based-on-variable-name-in-as3\/affordablewebsitestips\/tutorials","title":{"rendered":"Remove variable from array based on variable name in as3"},"content":{"rendered":"<p>Below is a function that allowed you to remove a variable from an array based on the variable name in ActionScript 3. The as3 function takes 2 variables to work, the 'varName' and the 'arrayName'. The 'varName' is the name of your variable you want to delete from the array. The 'arrayName' is the name of the array.<\/p>\n<p>&nbsp;<\/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: #006600; font-style: italic;\">\/\/remove array variable from array based on the variable name<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">03<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">\t\t<span style=\"color: #003366; font-weight: bold;\">function<\/span> removeArrayVar<span style=\"color: #009900;\">&#40;<\/span>varName<span style=\"color: #339933;\">,<\/span> arrayName<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">:<\/span><span style=\"color: #000066; font-weight: bold;\">void<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">04<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">\t\t<span style=\"color: #009900;\">&#123;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">05<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">\t\t\t<span style=\"color: #003366; font-weight: bold;\">var<\/span> countD<span style=\"color: #339933;\">:<\/span>Number <span style=\"color: #339933;\">=<\/span> <span style=\"color: #CC0000;\">0<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #000066; font-weight: bold;\">for<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #003366; font-weight: bold;\">var<\/span> t3<span style=\"color: #339933;\">:<\/span>Object <span style=\"color: #000066; font-weight: bold;\">in<\/span> arrayName<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\">\t\t\t\t\t\t<span style=\"color: #000066; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">&#40;<\/span>varName <span style=\"color: #339933;\">==<\/span> arrayName<span style=\"color: #009900;\">&#91;<\/span>t3<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\" width=\"1%\">07<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">\t\t\t\t\t\t\ttrace<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #3366CC;\">&quot;removed &quot;<\/span><span style=\"color: #339933;\">+<\/span>varName<span style=\"color: #339933;\">+<\/span><span style=\"color: #3366CC;\">&quot; from array!&quot;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">08<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">\t\t\t\t\t\t\tarrayName.<span style=\"color: #660066;\">splice<\/span><span style=\"color: #009900;\">&#40;<\/span>t3<span style=\"color: #339933;\">,<\/span><span style=\"color: #CC0000;\">1<\/span> <span style=\"color: #009900;\">&#41;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">09<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">\t\t\t\t\t\t<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\">\t\t\t\t\t\tcountD<span style=\"color: #339933;\">++;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">11<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">\t\t\t\t\t\t<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\">\t\t<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 allowed you to remove a variable from an array based on the variable name in ActionScript 3. The as3 function takes 2 variables to work, the &#8216;varName&#8217; and the &#8216;arrayName&#8217;. The &#8216;varName&#8217; is the name of your variable you want to delete from the array. The &#8216;arrayName&#8217; is the name [&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-8825","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\/8825","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=8825"}],"version-history":[{"count":1,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8825\/revisions"}],"predecessor-version":[{"id":8826,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8825\/revisions\/8826"}],"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=8825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/categories?post=8825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/tags?post=8825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}