Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

ActionScript 3

Mask in as2 setMask

1
2
3
4
box.cacheAsBitmap = true;
m.cacheAsBitmap = true;

box.setMask("m");
https://snipt.net/embed/9ee1f374521dd897ffc98d4d2ec3106c/
https://snipt.net/raw/9ee1f374521dd897ffc98d4d2ec3106c/
9ee1f374521dd897ffc98d4d2ec3106c
as3
ActionScript 3
4
2016-12-02T15:47:37
True
False
False
/api/public/snipt/35158/
mask-in-as2-setmask
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">box</span><span class="o">.</span><span class="na">cacheAsBitmap</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span> </span><span id="L-2"><a name="L-2"></a><span class="n">m</span><span class="o">.</span><span class="na">cacheAsBitmap</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="n">box</span><span class="o">.</span><span class="na">setMask</span><span class="o">(</span><span class="s2">&quot;m&quot;</span><span class="o">);</span> </span></pre></div> </td></tr></table>
as2, utility

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-12-02T13:43:08
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></span><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-12-02T13:43:10
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></span><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 [email protected].