snipt

Ctrl+h for KB shortcuts

ActionScript 3

AS3 Click Tag

click_btn.addEventListener(
  MouseEvent.CLICK,
  function():void {
    
    if (root.loaderInfo.parameters.clickTag.substr(0,5) == "http:") {
		navigateToURL(
		new URLRequest(root.loaderInfo.parameters.clickTag), "_blank"
		);
	}
	
  }
);
https://snipt.net/embed/620c86068f96a53486e1fe343a53ae15/
https://snipt.net/raw/620c86068f96a53486e1fe343a53ae15/
620c86068f96a53486e1fe343a53ae15
as3
ActionScript 3
1
2016-09-21T10:24:57
True
False
False
Jul 12, 2012 at 03:41 PM
/api/public/snipt/43838/
as3-click-tag
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="n">click_btn</span><span class="o">.</span><span class="na">addEventListener</span><span class="o">(</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">MouseEvent</span><span class="o">.</span><span class="na">CLICK</span><span class="o">,</span> </span><span id="L-3"><a name="L-3"></a> <span class="kd">function</span><span class="o">():</span><span class="kc">void</span> <span class="o">{</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> <span class="k">if</span> <span class="o">(</span><span class="n">root</span><span class="o">.</span><span class="na">loaderInfo</span><span class="o">.</span><span class="na">parameters</span><span class="o">.</span><span class="na">clickTag</span><span class="o">.</span><span class="na">substr</span><span class="o">(</span><span class="mi">0</span><span class="o">,</span><span class="mi">5</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;http:&quot;</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">navigateToURL</span><span class="o">(</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">new</span> <span class="kt">URLRequest</span><span class="o">(</span><span class="n">root</span><span class="o">.</span><span class="na">loaderInfo</span><span class="o">.</span><span class="na">parameters</span><span class="o">.</span><span class="na">clickTag</span><span class="o">),</span> <span class="s2">&quot;_blank&quot;</span> </span><span id="L-8"><a name="L-8"></a> <span class="o">);</span> </span><span id="L-9"><a name="L-9"></a> <span class="o">}</span> </span><span id="L-10"><a name="L-10"></a> </span><span id="L-11"><a name="L-11"></a> <span class="o">}</span> </span><span id="L-12"><a name="L-12"></a><span class="o">);</span> </span></pre></div> </td></tr></table>
as3, button

ActionScript 3

3d Projection

1
2
3
scale = focalLength / (focalLength + posZ)
targetX = posX * scale
targetY = posY * scale
https://snipt.net/embed/fa1f8ff708c964ccd7724dd3b12f07ba/
https://snipt.net/raw/fa1f8ff708c964ccd7724dd3b12f07ba/
fa1f8ff708c964ccd7724dd3b12f07ba
as3
ActionScript 3
3
2016-09-25T00:49:29
True
False
False
/api/public/snipt/34000/
3d-projection
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="n">scale</span> <span class="o">=</span> <span class="n">focalLength</span> <span class="o">/</span> <span class="o">(</span><span class="n">focalLength</span> <span class="o">+</span> <span class="n">posZ</span><span class="o">)</span> </span><span id="L-2"><a name="L-2"></a><span class="n">targetX</span> <span class="o">=</span> <span class="n">posX</span> <span class="o">*</span> <span class="n">scale</span> </span><span id="L-3"><a name="L-3"></a><span class="n">targetY</span> <span class="o">=</span> <span class="n">posY</span> <span class="o">*</span> <span class="n">scale</span> </span></pre></div> </td></tr></table>
3d, as3, utility

ActionScript 3

Copy Array

1
2
3
4
5
6
7
8
private function copyArray(arrayToCopy:Array):Array {
	var tempArray:Array = new Array();
	for each (var thing:* in arrayToCopy) {
		tempArray.push(thing);
	}
	//trace(arrayToCopy.length + " of "+ tempArray.length +" items copied");
	return tempArray;
}	
https://snipt.net/embed/a06236fd986256889166d721d957acfa/
https://snipt.net/raw/a06236fd986256889166d721d957acfa/
a06236fd986256889166d721d957acfa
as3
ActionScript 3
8
2016-09-26T11:29:42
True
False
False
/api/public/snipt/33944/
copy-array
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="kd">private</span> <span class="kd">function </span><span class="nf">copyArray</span><span class="o">(</span><span class="n">arrayToCopy</span><span class="o">:</span><span class="kt">Array</span><span class="o">):</span><span class="kt">Array</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">var</span> <span class="n">tempArray</span><span class="p">:</span><span class="kt">Array</span> <span class="o">=</span> <span class="k">new</span> <span class="kt">Array</span><span class="o">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">for</span> <span class="k">each</span> <span class="o">(</span><span class="n">var</span> <span class="n">thing</span><span class="o">:*</span> <span class="k">in</span> <span class="n">arrayToCopy</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">tempArray</span><span class="o">.</span><span class="na">push</span><span class="o">(</span><span class="n">thing</span><span class="o">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="o">}</span> </span><span id="L-6"><a name="L-6"></a> <span class="c1">//trace(arrayToCopy.length + &quot; of &quot;+ tempArray.length +&quot; items copied&quot;);</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">return</span> <span class="n">tempArray</span><span class="o">;</span> </span><span id="L-8"><a name="L-8"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
array, as3, utility
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.