<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: AS3 &#8211; Amazing Map Function.</title>
	<atom:link href="http://www.lawriecape.co.uk/theblog/index.php/archives/209/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lawriecape.co.uk/theblog/index.php/archives/209</link>
	<description>Flash, Actionscript, Design, Games and Programming.</description>
	<lastBuildDate>Sun, 04 Dec 2011 13:10:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Lawrie</title>
		<link>http://www.lawriecape.co.uk/theblog/index.php/archives/209/comment-page-1#comment-1148</link>
		<dc:creator>Lawrie</dc:creator>
		<pubDate>Mon, 26 Sep 2011 21:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.lawriecape.co.uk/theblog/?p=209#comment-1148</guid>
		<description>Glad you got it working :)</description>
		<content:encoded><![CDATA[<p>Glad you got it working :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.lawriecape.co.uk/theblog/index.php/archives/209/comment-page-1#comment-1147</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 26 Sep 2011 20:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.lawriecape.co.uk/theblog/?p=209#comment-1147</guid>
		<description>Yeah, had to do this first:

var mc:MovieClip = MovieClip(this.parent);
trace(map(mc.mouseY, 0, stage.stageHeight, -100, 100));

Working great, thanks.</description>
		<content:encoded><![CDATA[<p>Yeah, had to do this first:</p>
<p>var mc:MovieClip = MovieClip(this.parent);<br />
trace(map(mc.mouseY, 0, stage.stageHeight, -100, 100));</p>
<p>Working great, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.lawriecape.co.uk/theblog/index.php/archives/209/comment-page-1#comment-1146</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 26 Sep 2011 20:50:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.lawriecape.co.uk/theblog/?p=209#comment-1146</guid>
		<description>It&#039;s a Gaia project, and I can see now that I&#039;m getting the mouseY based on the child, and not the stage as I thought i was.

Have to figure out how to get the mouseY from the stage and not the child. So there&#039;s a reason it »didn&#039;t work«.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a Gaia project, and I can see now that I&#8217;m getting the mouseY based on the child, and not the stage as I thought i was.</p>
<p>Have to figure out how to get the mouseY from the stage and not the child. So there&#8217;s a reason it »didn&#8217;t work«.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.lawriecape.co.uk/theblog/index.php/archives/209/comment-page-1#comment-1145</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 26 Sep 2011 20:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.lawriecape.co.uk/theblog/?p=209#comment-1145</guid>
		<description>Yeah, the 550 is the default. I&#039;ve changed it for a &#039;bigger&#039; project.

I can get it to work in a clean fla. But not in the project I&#039;m working on.

Basically I&#039;m moving a navigation based on the mouseY, and I&#039;m using the script in attempt to add a bit of top- and bottom margin to the navigation. So I&#039;m calling:

private function navigationHandler(event:Event):void
{
	trace(mouseY, map(mouseY, 0, stage.stageHeight, -100, 100));
	var _offstage = height / stage.stageHeight;
	var _ypos = -((_offstage * stage.mouseY) - (stage.mouseY - (map(mouseY, 0, stage.stageHeight, -100, 100))));
	TweenLite.to(this, .5, {y: _ypos});
		}

private function map(v:Number, a1:Number, b1:Number, a2:Number = 0, b2:Number = 1):Number
{
	return (v == a1) ? a2 : (v - a1) * (b2 - a2) / (b1 - a1) + a2;
}


But it simply return an odd value. And by the way it&#039;s 500, not 550 as stated. But that seems not to be of any point; as it should return 100.</description>
		<content:encoded><![CDATA[<p>Yeah, the 550 is the default. I&#8217;ve changed it for a &#8216;bigger&#8217; project.</p>
<p>I can get it to work in a clean fla. But not in the project I&#8217;m working on.</p>
<p>Basically I&#8217;m moving a navigation based on the mouseY, and I&#8217;m using the script in attempt to add a bit of top- and bottom margin to the navigation. So I&#8217;m calling:</p>
<p>private function navigationHandler(event:Event):void<br />
{<br />
	trace(mouseY, map(mouseY, 0, stage.stageHeight, -100, 100));<br />
	var _offstage = height / stage.stageHeight;<br />
	var _ypos = -((_offstage * stage.mouseY) &#8211; (stage.mouseY &#8211; (map(mouseY, 0, stage.stageHeight, -100, 100))));<br />
	TweenLite.to(this, .5, {y: _ypos});<br />
		}</p>
<p>private function map(v:Number, a1:Number, b1:Number, a2:Number = 0, b2:Number = 1):Number<br />
{<br />
	return (v == a1) ? a2 : (v &#8211; a1) * (b2 &#8211; a2) / (b1 &#8211; a1) + a2;<br />
}</p>
<p>But it simply return an odd value. And by the way it&#8217;s 500, not 550 as stated. But that seems not to be of any point; as it should return 100.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lawrie</title>
		<link>http://www.lawriecape.co.uk/theblog/index.php/archives/209/comment-page-1#comment-1144</link>
		<dc:creator>Lawrie</dc:creator>
		<pubDate>Mon, 26 Sep 2011 15:20:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.lawriecape.co.uk/theblog/?p=209#comment-1144</guid>
		<description>It works for me, using the following demo AS - 

this.addEventListener(Event.ENTER_FRAME, mapMouse);

function mapMouse(e:Event):void{
	trace(map(mouseY,0,stage.stageHeight,-100,100));
}

function map(v:Number, a:Number, b:Number, x:Number = 0, y:Number = 1):Number {
    return (v == a) ? x : (v - a) * (y - x) / (b - a) + x;
}


Are you sure 550 is your stage height? It&#039;s the default flash stage width which might be throwing you off?</description>
		<content:encoded><![CDATA[<p>It works for me, using the following demo AS &#8211; </p>
<p>this.addEventListener(Event.ENTER_FRAME, mapMouse);</p>
<p>function mapMouse(e:Event):void{<br />
	trace(map(mouseY,0,stage.stageHeight,-100,100));<br />
}</p>
<p>function map(v:Number, a:Number, b:Number, x:Number = 0, y:Number = 1):Number {<br />
    return (v == a) ? x : (v &#8211; a) * (y &#8211; x) / (b &#8211; a) + x;<br />
}</p>
<p>Are you sure 550 is your stage height? It&#8217;s the default flash stage width which might be throwing you off?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

