<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hjælp mig nu &#187; Tutorial og artikler</title>
	<atom:link href="http://blog.hjaelpmignu.dk/category/tutorial-og-artikler/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hjaelpmignu.dk</link>
	<description>Hjælp til Adobes programmer</description>
	<lastBuildDate>Fri, 13 Jan 2012 11:28:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mapping coordinates from one range to another in ActionScript 3.0</title>
		<link>http://blog.hjaelpmignu.dk/2011/11/mapping-coordinates-from-one-range-to-another-in-actionscript-3-0/</link>
		<comments>http://blog.hjaelpmignu.dk/2011/11/mapping-coordinates-from-one-range-to-another-in-actionscript-3-0/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 11:51:57 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Tips og tricks]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[www.hjaelpmignu.dk]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=389</guid>
		<description><![CDATA[I am very fond of Processing, and the way it easily makes it possible to experiment with design ideas. One of the powerful features are it&#8217;s map() function, that takes a value and remaps it from one range to another. I haven&#8217;t seen a similar function in the ActionScript 3.0 reference, so &#8230;<p><a href="http://blog.hjaelpmignu.dk/2011/11/mapping-coordinates-from-one-range-to-another-in-actionscript-3-0/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>I am very fond of Processing, and the way it easily makes it possible to experiment with design ideas. One of the powerful features are it&#8217;s<a title="map function" href="http://processing.org/reference/map_.html"> map()</a> function, that takes a value and remaps it from one range to another. I haven&#8217;t seen a similar function in the ActionScript 3.0 reference, so I decided to make one to my own utils-library, because it is something the can come in handy in many situations. First I looked at using the Point() class, and interpolation to describe the ratios, but actually found it easier to just do it with regular math.</p>
<p>I haven&#8217;t looked at performance yet, and there is possibly a lot of ways to optimize this code &#8211; this article can be a start for further fine tuning. The helper function looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>val<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> inMin<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> inMax<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> outMin<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> outMax<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> decimals<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> returnVal<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Sets the total range for both in and out</span>
<span style="color: #6699cc; font-weight: bold;">var</span> inRange<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = inMax <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> outRange<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = outMax <span style="color: #000066; font-weight: bold;">-</span> outMin<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//calculates the ratio for the value in relation to the in range</span>
<span style="color: #6699cc; font-weight: bold;">var</span> ratio<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>val <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span>inRange<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//makes sure that the value is within range</span>
val = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>inMin<span style="color: #000066; font-weight: bold;">,</span> val<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
val = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>inMax<span style="color: #000066; font-weight: bold;">,</span> val<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//Finds the same ratio in the out range and shift it into place</span>
returnVal = <span style="color: #000000;">&#40;</span>outRange <span style="color: #000066; font-weight: bold;">*</span> ratio<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> outMin<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//rounding of the decimals</span>
<span style="color: #6699cc; font-weight: bold;">var</span> factor<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span>decimals<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
returnVal = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>returnVal<span style="color: #000066; font-weight: bold;">*</span>factor<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span>factor<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">return</span> returnVal<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The function takes the the following arguments:</p>
<ul>
<li>val: the number to be remapped</li>
<li>inMin and inMax: The original range, in which the value is measures in relation to.</li>
<li>outMin and outMax: The destination range, that the value will be re-mapped to</li>
<li>decimals: sets the precision in decimals (optional)</li>
</ul>
<div>First it calculates the ranges with</div>
<div>
<pre>var inRange:Number = inMax - inMin;
var outRange:Number = outMax - outMin;</pre>
</div>
<div>These variables are defining the total range for both the incoming number, and the range of number is eventually will be placed within.</div>
<div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">val = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>inMin<span style="color: #000066; font-weight: bold;">,</span> val<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
val = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>inMax<span style="color: #000066; font-weight: bold;">,</span> val<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

</div>
<div>In this function I have decided to make sure, that the value is within the boundaries of the inRange. If i took the value 4, and sets the range of number to be within 10 and 100, I would get some unexpected results. You could treat this differently, or even make it possible by omitting these lines.</div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> ratio<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>val <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span>inRange<span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<div>ratio holds a number between 0 and 1 that defines where in the original range it is located. The closer to zero it gets, the lower the value &#8211; closer to one goes towards inMax.</div>
<pre>returnVal = (outRange * ratio) + outMin;</pre>
<div>Then the number is multiplied to the outRange to find the same relative point in the target range, and finally shifted into place by adding the outMin value. Negative values are treated fine in these ranges &#8211; when you add -200 to something, it is actually subtracted from the number.</div>
<div>
<pre>var factor:int = Math.pow(10,decimals);
returnVal = Math.round(returnVal*factor)/factor;</pre>
<div>The last part of the function is meant to round of the values. For performance, this could easily be removed, but it may be useful in some cases to have odd long numbers rounded and presented with only a few digits precition. First, the variable factor holds the value to be used in the rounding proces. For 1 digit it should be &#8220;10&#8243;, 2 digits is &#8220;100&#8243;, 3 is &#8220;1000&#8243; and so forth. That value is used in the line below, where it first multiplies the final value by the factor and then rounds it to an integer. Then it divides with the factor again. It goes something like this:</div>
</div>
<div>
<ol>
<li>factor is 1000 (3 digits)</li>
<li>value is <strong>134.744637</strong></li>
<li>Multiplication results in<strong> 134744.637</strong></li>
<li>Rounding returns <strong>134745</strong></li>
<li>divided by 1000 gives the result <strong>134.745</strong></li>
</ol>
<div>Finally the value is returned as a Number.</div>
</div>
<h4>Optimization</h4>
<div>There are a lot of code shortening, that can produce a speed improvement. You could also work with int or uint exclusively to gain some performance i suppose. Finally, you can remove the decimals and the lines that check if the number is in range. I have left the to show what functionality that could come in handy.</div>
<h4>An example</h4>
<div>As a practical example of the map() function you can  copy the following code into a Flash document. Here the map() fuction is directly inside the main code, but you could start building your own utils-library with the helper functions as public static function for easier access.</div>
<div>The code draws two squares with different sizes. When the mouse moves over the small square, it draw lines in the larger square, while maintaining the relative coordinates inside the squares.</div>
<div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//make the small square and color it dark grey</span>
<span style="color: #6699cc; font-weight: bold;">var</span> inArea<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
inArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x333333<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
inArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
inArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>inArea<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//make the large square and color it black</span>
<span style="color: #6699cc; font-weight: bold;">var</span> outArea<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x000000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xFFFFFF<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>outArea<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = inArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//adds a listener for the small square, that listens for mouse movement</span>
inArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_MOVE</span><span style="color: #000066; font-weight: bold;">,</span> updateDrawing<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #339966; font-weight: bold;">function</span> updateDrawing<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//Map the local coordinates from the mouse movement to the size of the large square</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> targetX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">localX</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> targetY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">localY</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//Draws the line in the large square.</span>
	outArea<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>targetX<span style="color: #000066; font-weight: bold;">,</span> targetY<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//Helper function</span>
<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>val<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> inMin<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> inMax<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> outMin<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> outMax<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> decimals<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> returnVal<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #009900; font-style: italic;">// Sets the total range for both in and out</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> inRange<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = inMax <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> outRange<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = outMax <span style="color: #000066; font-weight: bold;">-</span> outMin<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//makes sure that the value is within range</span>
	val = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>inMin<span style="color: #000066; font-weight: bold;">,</span>val<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	val = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>inMax<span style="color: #000066; font-weight: bold;">,</span>val<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//calculates the ratio for the value in relation to the in range</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> ratio<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span>val <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> inRange<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//Finds the same ratio in the out range and shift it into place</span>
	returnVal = <span style="color: #000000;">&#40;</span>outRange <span style="color: #000066; font-weight: bold;">*</span> ratio<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> outMin<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//rounding of the decimals</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> factor<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span>decimals<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	returnVal = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>returnVal<span style="color: #000066; font-weight: bold;">*</span>factor<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span>factor<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">return</span> returnVal<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2011/11/mapping-coordinates-from-one-range-to-another-in-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling a function dynamically in ActionScript 3.0</title>
		<link>http://blog.hjaelpmignu.dk/2011/06/calling-a-function-dynamically-in-actionscript-3-0/</link>
		<comments>http://blog.hjaelpmignu.dk/2011/06/calling-a-function-dynamically-in-actionscript-3-0/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 16:26:57 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Adobe Flash Professional]]></category>
		<category><![CDATA[Tips og tricks]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[www.hjaelpmignu.dk]]></category>
		<category><![CDATA[array access operator]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[dynamic function]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=345</guid>
		<description><![CDATA[Have you ever wondered, how you could use a String to decide, which function to be called. You could go so far to let the user enter the function name in an input field and call a function by that name, if it exists. I have made a short article &#8230;<p><a href="http://blog.hjaelpmignu.dk/2011/06/calling-a-function-dynamically-in-actionscript-3-0/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>Have you ever wondered, how you could use a String to decide, which function to be called. You could go so far to let the user enter the function name in an input field and call a function by that name, if it exists.</p>
<p>I have made a short article with an example on how that is done in Flash and ActionScript 3.0. You can read the article at <a title="Article about dynamic function call" href="http://www.hjaelpmignu.dk/content/dynamic-call-functions">http://www.hjaelpmignu.dk/content/dynamic-call-functions</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2011/06/calling-a-function-dynamically-in-actionscript-3-0/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adobe Creative Suite 5/5.5 &#8211; Printing guide</title>
		<link>http://blog.hjaelpmignu.dk/2011/06/adobe-creative-suite-55-5-printing-guide/</link>
		<comments>http://blog.hjaelpmignu.dk/2011/06/adobe-creative-suite-55-5-printing-guide/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 12:01:05 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[Adobe Creative Suite]]></category>
		<category><![CDATA[Adobe Illustrator]]></category>
		<category><![CDATA[Adobe InDesign]]></category>
		<category><![CDATA[Adobe Photoshop]]></category>
		<category><![CDATA[CS5]]></category>
		<category><![CDATA[CS5.5]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[adobe printing guide]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[illustrator]]></category>
		<category><![CDATA[indesign]]></category>
		<category><![CDATA[jdf]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=350</guid>
		<description><![CDATA[If you are using Adobe software to create design for print production or receive documents as a print provider, this guide is a must read for you. All relevant info on color handling, trapping, handling transparency and effects are there. Info on Job Definition Format (JDF) and how to print &#8230;<p><a href="http://blog.hjaelpmignu.dk/2011/06/adobe-creative-suite-55-5-printing-guide/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>If you are using Adobe software to create design for print production or receive documents as a print provider, <a title="Adobe Creative Suite 5/5.5 - printing guide" href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/creativesuite/design/pdfs/cs5-5-final-print-guide.pdf" target="_blank">this guide</a> is a must read for you. All relevant info on color handling, trapping, handling transparency and effects are there. Info on Job Definition Format (JDF) and how to print and edit PDF files is there. Best practise &#8211; what and how to expand objects in Illustrator are there. The Forensic Tools in the various software is explained.</p>
<p>All in all. 138 pages of action packed printing info available. Questions to the guide are welcomed <a title="www.hjaelpmignu.dk forum" href="http://www.hjaelpmignu.dk/forum">in the forums</a></p>
<p><a title="Adobe Creative Suite 5/5.5 Printing guide" href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/creativesuite/design/pdfs/cs5-5-final-print-guide.pdf" target="_blank">Link to guide</a></p>
<p>Happy reading</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2011/06/adobe-creative-suite-55-5-printing-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transparens i filer fra Photoshop til brug på Internettet</title>
		<link>http://blog.hjaelpmignu.dk/2010/06/transparens-i-filer-fra-photoshop-til-brug-pa-internettet/</link>
		<comments>http://blog.hjaelpmignu.dk/2010/06/transparens-i-filer-fra-photoshop-til-brug-pa-internettet/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 11:16:18 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[Adobe Photoshop]]></category>
		<category><![CDATA[CS4]]></category>
		<category><![CDATA[CS5]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[videotutorial]]></category>
		<category><![CDATA[www.hjaelpmignu.dk]]></category>
		<category><![CDATA[devices]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[transparens]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=223</guid>
		<description><![CDATA[Jeg har uploadet en kort demonstration som svar til dette spørgsmål på www.hjaelpmignu.dk. Den gennemgår gennemsigtighed i PNG-filer og hvordan du forholder dig til farvetabellen (Color Table) i dialogen. Du kan se videoen på adressen http://www.hjaelpmignu.dk/node/211 Du kan læse mere om Save for Web and Devices i Adobe Creative Suite &#8230;<p><a href="http://blog.hjaelpmignu.dk/2010/06/transparens-i-filer-fra-photoshop-til-brug-pa-internettet/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>Jeg har uploadet en kort demonstration som svar til dette spørgsmål på www.hjaelpmignu.dk. Den gennemgår gennemsigtighed i PNG-filer og hvordan du forholder dig til farvetabellen (Color Table) i dialogen.</p>
<p>Du kan se videoen på adressen <a href="http://www.hjaelpmignu.dk/node/211">http://www.hjaelpmignu.dk/node/211</a></p>
<p>Du kan læse mere om <strong>Save for Web and Devices</strong> i Adobe Creative Suite 5 på adressen <a href="http://help.adobe.com/en_US/creativesuite/cs/using/WSEE78023B-9077-4276-9D82-B7ABD0F9AE32.html">http://help.adobe.com/en_US/creativesuite/cs/using/WSEE78023B-9077-4276-9D82-B7ABD0F9AE32.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2010/06/transparens-i-filer-fra-photoshop-til-brug-pa-internettet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video tutorial om at sende data fra Flash til mail via PHP</title>
		<link>http://blog.hjaelpmignu.dk/2010/06/video-tutorial-om-at-sende-data-fra-flash-til-mail-via-php/</link>
		<comments>http://blog.hjaelpmignu.dk/2010/06/video-tutorial-om-at-sende-data-fra-flash-til-mail-via-php/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 13:56:55 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Adobe Flash Professional]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[www.hjaelpmignu.dk]]></category>
		<category><![CDATA[formular]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[videotutorial]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=218</guid>
		<description><![CDATA[Jeg har fået gang i gode gamle Camtasia og snedkereret en tutorial der viser, hvordan en række input felter, samlet i en formular, kan sendes fra en Flash-film, via et php-script og hen til din mail boks. Det er som svar på forum indlæget Contact Form Vejledningen tager dels udgangspunkt &#8230;<p><a href="http://blog.hjaelpmignu.dk/2010/06/video-tutorial-om-at-sende-data-fra-flash-til-mail-via-php/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>Jeg har fået gang i gode gamle <a title="Camtasia Studio" href="http://www.techsmith.com/camtasia.asp" target="_blank">Camtasia </a>og snedkereret en tutorial der viser, hvordan en række input felter, samlet i en formular, kan sendes fra en Flash-film, via et php-script og hen til din mail boks. Det er som svar på forum indlæget <a href="http://www.hjaelpmignu.dk/node/194">Contact Form</a></p>
<p>Vejledningen tager dels udgangspunkt i det link til en tutorial på Flashforum, der blev nævnt, og dels en gammel video tutorial af Lee Brimelow.</p>
<p><a href="http://www.hjaelpmignu.dk/node/208">Se den på www.hjaelpmignu.dk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2010/06/video-tutorial-om-at-sende-data-fra-flash-til-mail-via-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://media.hjaelpmignu.dk/video/actionscript/serverside/mailer/mailer.mp4" length="147218393" type="video/mp4" />
		</item>
		<item>
		<title>Pixel Bender har fået sin egen plads</title>
		<link>http://blog.hjaelpmignu.dk/2010/01/pixel-bender-har-faet-sin-egen-plads/</link>
		<comments>http://blog.hjaelpmignu.dk/2010/01/pixel-bender-har-faet-sin-egen-plads/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 09:53:36 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[Adobe AfterEffects]]></category>
		<category><![CDATA[Adobe Flash Professional]]></category>
		<category><![CDATA[Adobe Photoshop]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Adobe Developer Connection]]></category>
		<category><![CDATA[Devnet]]></category>
		<category><![CDATA[filtre]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=189</guid>
		<description><![CDATA[Pixel Bender har længe været en del af Creative Suite og er blevet installeret sammen med suiten som standard. Det har dog stået lidt småt til med at udvikle plug-ins i programmet. For det første skal der læres et nyt sprog, og for det andet skal man finde ud af, &#8230;<p><a href="http://blog.hjaelpmignu.dk/2010/01/pixel-bender-har-faet-sin-egen-plads/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>Pixel Bender har længe været en del af Creative Suite og er blevet installeret sammen med suiten som standard. Det har dog stået lidt småt til med at udvikle plug-ins i programmet. For det første skal der læres et nyt sprog, og for det andet skal man finde ud af, hvilken type plug-in man har tænkt sig at udvikle. Derfor har det kun været et værktøj for de eksperimenterende personer, men det vil Adobe lave om på.</p>
<p>Pixel Bender kan bruges til at få computerens hardware til at regne på pixelinformationer. Det kan resultere i regulære filtre til billeder og video, men kan reelt være alle typer af data. Pixel Bender kernels kan umiddelbart bruges i Photoshop, After Effects og Flash.</p>
<p>Indtil nu har Pixel Bender og al information om den været på labs.adobe.com, men nu har den fået et værelse på Adobes Developer Connection.</p>
<p>Kig ind på http://www.adobe.com/devnet/pixelbender/ hvor du kan se en masse tutorials og videoklip, der kan forklare om mulighederne i programmet.</p>
<p>God fornøjelse</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2010/01/pixel-bender-har-faet-sin-egen-plads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nyt website til www.hjaelpmignu.dk</title>
		<link>http://blog.hjaelpmignu.dk/2009/06/nyt-website-til-www-hjaelpmignu-dk/</link>
		<comments>http://blog.hjaelpmignu.dk/2009/06/nyt-website-til-www-hjaelpmignu-dk/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 07:25:55 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[www.hjaelpmignu.dk]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=162</guid>
		<description><![CDATA[Tiden var kommet til at jeg måtte flytte www.hjaelpmignu.dk til et nyt system. Tidligere brugte jeg XOOPS til at holde styr på artikler og forum, men havde svært ved at få det passet ind med min lyst til at skrive flere artikler og ligge videotutorials op, som svar på spørgsmål. &#8230;<p><a href="http://blog.hjaelpmignu.dk/2009/06/nyt-website-til-www-hjaelpmignu-dk/" class="more-link"><span>Continue Reading &#8594;</span></a></p>]]></description>
			<content:encoded><![CDATA[<p>Tiden var kommet til at jeg måtte flytte www.hjaelpmignu.dk til et nyt system. Tidligere brugte jeg XOOPS til at holde styr på artikler og forum, men havde svært ved at få det passet ind med min lyst til at skrive flere artikler og ligge videotutorials op, som svar på spørgsmål. Derudover ville jeg gerne kunne integrere medskribenter og bruger på en mere social måde.</p>
<p>Resultatet er blevet Drupal, som giver mig en meget åben ramme at arbejde indenfor. Meget af det var selvfølgelig også muligt med den tidligere version, men jeg føler det nemmere at begå mig i Drupal &#8211; både hvad gælder den normale vedligeholdese af indhold, men også når det kommer til videreudvikling og opdatering af plugins osv.</p>
<p>Jeg håber at i vil tage godt i mod sitet, og stille en masse interessante spørgsmål &#8211; meningen med sitet er jo at lave tutorials, der i vid udstrækning baserer sig på dine spørgsmål. Et eksempel kan være, <a href="http://www.hjaelpmignu.dk/node/141">dette spørgsmål</a>, der blev til <a href="http://www.hjaelpmignu.dk/node/142">dette svar</a>.</p>
<p>Her er et par link til de vigtige sektioner</p>
<ul>
<li><a href="http://www.hjaelpmignu.dk/forum">http://www.hjaelpmignu.dk/forum</a> (Forum)</li>
<li><a href="http://www.hjaelpmignu.dk/artikler">http://www.hjaelpmignu.dk/artikler</a> (Artikler)</li>
<li><a href="http://www.hjaelpmignu.dk/contact">http://www.hjaelpmignu.dk/contact</a> (Kontakt)</li>
</ul>
<p>Vel mødt på sitet</p>
<p>/ockley</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2009/06/nyt-website-til-www-hjaelpmignu-dk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ny Photoshop tutorial &#8211; fordybning i overflade</title>
		<link>http://blog.hjaelpmignu.dk/2009/06/ny-photoshop-tutorial-fordybning-i-overflade/</link>
		<comments>http://blog.hjaelpmignu.dk/2009/06/ny-photoshop-tutorial-fordybning-i-overflade/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 21:52:46 +0000</pubDate>
		<dc:creator>ockley</dc:creator>
				<category><![CDATA[Adobe Photoshop]]></category>
		<category><![CDATA[Tutorial og artikler]]></category>
		<category><![CDATA[undervisning]]></category>
		<category><![CDATA[artikel]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[www.hjaelpmignu.dk]]></category>

		<guid isPermaLink="false">http://blog.hjaelpmignu.dk/?p=151</guid>
		<description><![CDATA[Der er lagt en ny tutorial på www.hjaelpmignu.dk. Den viser hvordan du kan tage et silhouet og gøre det til en fordybning i en overflade eller en tekstur. du kan se artiklen på http://www.hjaelpmignu.dk/node/137 /ockley]]></description>
			<content:encoded><![CDATA[<p>Der er lagt en ny tutorial på <a href="http://www.hjaelpmignu.dk">www.hjaelpmignu.dk</a>. Den viser hvordan du kan tage et silhouet og gøre det til en fordybning i en overflade eller en tekstur. du kan se artiklen på <a href="http://www.hjaelpmignu.dk/node/137">http://www.hjaelpmignu.dk/node/137</a></p>
<p>/ockley</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hjaelpmignu.dk/2009/06/ny-photoshop-tutorial-fordybning-i-overflade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

