<?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: Center Registration Point &#8211; Another Recipe for the Flex CookBook</title>
	<atom:link href="http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/</link>
	<description>A RIA developer's late night ramblings and other nonsense</description>
	<lastBuildDate>Sun, 09 May 2010 09:59:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: Dave</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3499</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 09 May 2009 17:11:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3499</guid>
		<description>Cool, glad it worked :) 

If you&#039;re setting the _doc x and y, width and height, but not scaling the _wrap, the _wrap canvas will cut off the _doc canvas&#039;s overlap by default. But it sounds like you got it working well. 

Let me know if you come up with something cool based on the ImageResizer class.</description>
		<content:encoded><![CDATA[<p>Cool, glad it worked <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>If you&#8217;re setting the _doc x and y, width and height, but not scaling the _wrap, the _wrap canvas will cut off the _doc canvas&#8217;s overlap by default. But it sounds like you got it working well. </p>
<p>Let me know if you come up with something cool based on the ImageResizer class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taniguchi, J.</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3498</link>
		<dc:creator>Taniguchi, J.</dc:creator>
		<pubDate>Sat, 09 May 2009 17:05:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3498</guid>
		<description>Hey Dave, your example worked just fine but... (there&#039;re always a but :) ) it displays only 1/4 of the _doc when zoomed at 200%.
So I tried a different approach. Insted of using slider (which is messing up the values), I&#039;m using 2 buttons and listening for the buttonDown and setting autoRepeat to true. I figured if I get the value by pushing a button, it will return EXACLY the value I set, ex. +1 or +10. That way, I make sure the value is static. So, I tested this new approach and it worked just as I expect it to work. It re-scale the canvas and keep the scrollbar exacly at the center which allows you to scroll to the left and right, up and down. The &quot;zoom effect&quot; will always be focused on the center :)

The function:
&lt;code&gt;
private function alignDoc():void {
	
	if(_doc.width &gt; _wrap.width){
		_doc.x = 0;
		_wrap.horizontalScrollPosition = (_doc.width / 2) - (_wrap.width / 2);
	}
	if(_doc.height &gt; _wrap.height){
		_doc.y = 0;
		_wrap.verticalScrollPosition = (_doc.height / 2) - (_wrap.height / 2);
	}
	if(_doc.width &lt; _wrap.width) {
		_doc.x = (_wrap.width / 2) - (_doc.width / 2);
	}
	if(_doc.height &lt; _wrap.height){
		_doc.y = (_wrap.height / 2) - (_doc.height / 2);
	}
}
&lt;/code&gt;

 I also called this function from creationComplete on the application tag which fix the center of the _doc when the application loads. I&#039;ll try to implement this concept into your class to see what I can accomplish :)

  Thanks for your time and sorry for making so many questions.
Best regards!</description>
		<content:encoded><![CDATA[<p>Hey Dave, your example worked just fine but&#8230; (there&#8217;re always a but <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) it displays only 1/4 of the _doc when zoomed at 200%.<br />
So I tried a different approach. Insted of using slider (which is messing up the values), I&#8217;m using 2 buttons and listening for the buttonDown and setting autoRepeat to true. I figured if I get the value by pushing a button, it will return EXACLY the value I set, ex. +1 or +10. That way, I make sure the value is static. So, I tested this new approach and it worked just as I expect it to work. It re-scale the canvas and keep the scrollbar exacly at the center which allows you to scroll to the left and right, up and down. The &#8220;zoom effect&#8221; will always be focused on the center <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The function:<br />
<code><br />
private function alignDoc():void {</p>
<p>	if(_doc.width &gt; _wrap.width){<br />
		_doc.x = 0;<br />
		_wrap.horizontalScrollPosition = (_doc.width / 2) - (_wrap.width / 2);<br />
	}<br />
	if(_doc.height &gt; _wrap.height){<br />
		_doc.y = 0;<br />
		_wrap.verticalScrollPosition = (_doc.height / 2) - (_wrap.height / 2);<br />
	}<br />
	if(_doc.width &lt; _wrap.width) {<br />
		_doc.x = (_wrap.width / 2) - (_doc.width / 2);<br />
	}<br />
	if(_doc.height &lt; _wrap.height){<br />
		_doc.y = (_wrap.height / 2) - (_doc.height / 2);<br />
	}<br />
}<br />
</code></p>
<p> I also called this function from creationComplete on the application tag which fix the center of the _doc when the application loads. I&#8217;ll try to implement this concept into your class to see what I can accomplish <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>  Thanks for your time and sorry for making so many questions.<br />
Best regards!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3496</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 09 May 2009 16:29:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3496</guid>
		<description>Well to center the _doc inside the _wrap Canvas, you&#039;d likely use this:

if(_doc.width &gt; _wrap.width){
_doc.width = ImageResizer.calcX(_wrap.x,_wrap.width,_doc.width);
_doc.height = ImageResizer.calcY(_wrap.y,_wrap.height,_doc.height);

}

Keep in mind one thing though, if you&#039;re setting the scroll position, you&#039;re probably also forcing the _doc Canvas to change its position without knowing how it will interact with the ImageResizer static functions.

Right now, you&#039;re changing _doc.x explicitly and you&#039;re setting the scroll position. So really, you just told Flex to change _doc.x twice.

You&#039;ll either have to remove that explicit setting of _doc.x and use the calcX calcY functions instead (I would try that first and comment the rest out as a test) or just make sure you&#039;re not changing _doc.x two times by just tracing _doc.x right where you set the scroll bar position.

To sum it up, I think the problem you&#039;re having is by changing scroll position explicitly, Flex is changing _doc.x within its parent _wrap Canvas AND you&#039;re explicitly setting _doc.x at the same time, so they&#039;re fighting each other. 

Let me know how the test goes :) but that should work fine.</description>
		<content:encoded><![CDATA[<p>Well to center the _doc inside the _wrap Canvas, you&#8217;d likely use this:</p>
<p>if(_doc.width > _wrap.width){<br />
_doc.width = ImageResizer.calcX(_wrap.x,_wrap.width,_doc.width);<br />
_doc.height = ImageResizer.calcY(_wrap.y,_wrap.height,_doc.height);</p>
<p>}</p>
<p>Keep in mind one thing though, if you&#8217;re setting the scroll position, you&#8217;re probably also forcing the _doc Canvas to change its position without knowing how it will interact with the ImageResizer static functions.</p>
<p>Right now, you&#8217;re changing _doc.x explicitly and you&#8217;re setting the scroll position. So really, you just told Flex to change _doc.x twice.</p>
<p>You&#8217;ll either have to remove that explicit setting of _doc.x and use the calcX calcY functions instead (I would try that first and comment the rest out as a test) or just make sure you&#8217;re not changing _doc.x two times by just tracing _doc.x right where you set the scroll bar position.</p>
<p>To sum it up, I think the problem you&#8217;re having is by changing scroll position explicitly, Flex is changing _doc.x within its parent _wrap Canvas AND you&#8217;re explicitly setting _doc.x at the same time, so they&#8217;re fighting each other. </p>
<p>Let me know how the test goes <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  but that should work fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taniguchi, J.</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3489</link>
		<dc:creator>Taniguchi, J.</dc:creator>
		<pubDate>Sat, 09 May 2009 13:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3489</guid>
		<description>By the way, you said: &quot; - Either way, if you do your conditionals and use the static calcX and calcY methods in the ImageResizer class, it’ll correctly position the Canvas in its parent.&quot;

Could you give me an example?</description>
		<content:encoded><![CDATA[<p>By the way, you said: &#8221; &#8211; Either way, if you do your conditionals and use the static calcX and calcY methods in the ImageResizer class, it’ll correctly position the Canvas in its parent.&#8221;</p>
<p>Could you give me an example?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taniguchi, J.</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3487</link>
		<dc:creator>Taniguchi, J.</dc:creator>
		<pubDate>Sat, 09 May 2009 12:44:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3487</guid>
		<description>Hi Dave, thanks for replying!

  The code it&#039;s just it :) Allow me to explain it:
  _wrap = Canvas
  _doc  = Canvas inside _wrap ( _wrap.addChild(_doc) )

if(_doc.width &gt; _wrap.width){
//&gt; add 30px to _doc.x and adjust the scrollbar position to 50%, like this: 
_doc.x = 30;
_wrap.horizontalScrollPosition = _wrap.horizontalScrollBar.width / 2;
}
if(_doc.height &gt; _wrap.height){
//&gt; add 30 px to y and fix the vertical scrollbar (center just like the horizontal. The point is, when you zoom it, the scrollbar should be placed always at the middle so you can scroll to the left and right.
_doc.y = 30;
_wrap.verticalScrollPosition = _wrap.verticalScrollBar.height / 2;
}

if(_doc.width  this line makes the _doc be centere inside the _wrap. The +8 its the pixels relative to the shadow effect which I already excluded.
_doc.x = (_wrap.width / 2) - (_doc.width / 2);
}
if(_doc.width  this line also do the centering.
_doc.y = (_wrap.height / 2) - (_doc.height / 2);
}
}

 So, as you see, its a really straight forwards and simple function. The way I see it, it supposed to work but it don&#039;t. The last 2 IFs works fine because the _doc is smaller than _wrap. There is no scrollbar to fix and A/2 - B/2 works just fine. My best guess its that the first 2 IFs are wrong.
 Or maybe the problem is with the slider. I tested the same function using 2 buttons and autoRepeat and everything worked OK. Then, I tested the slider values and I found out that when I change the slider from one side to the another (-10 to 200) by clicking the track or by slinding it really fast, the slider will always return different values. Before you ask, I put the slider.value inside a int().

Thanks and sorry for the looong text :)</description>
		<content:encoded><![CDATA[<p>Hi Dave, thanks for replying!</p>
<p>  The code it&#8217;s just it <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Allow me to explain it:<br />
  _wrap = Canvas<br />
  _doc  = Canvas inside _wrap ( _wrap.addChild(_doc) )</p>
<p>if(_doc.width &gt; _wrap.width){<br />
//&gt; add 30px to _doc.x and adjust the scrollbar position to 50%, like this:<br />
_doc.x = 30;<br />
_wrap.horizontalScrollPosition = _wrap.horizontalScrollBar.width / 2;<br />
}<br />
if(_doc.height &gt; _wrap.height){<br />
//&gt; add 30 px to y and fix the vertical scrollbar (center just like the horizontal. The point is, when you zoom it, the scrollbar should be placed always at the middle so you can scroll to the left and right.<br />
_doc.y = 30;<br />
_wrap.verticalScrollPosition = _wrap.verticalScrollBar.height / 2;<br />
}</p>
<p>if(_doc.width  this line makes the _doc be centere inside the _wrap. The +8 its the pixels relative to the shadow effect which I already excluded.<br />
_doc.x = (_wrap.width / 2) &#8211; (_doc.width / 2);<br />
}<br />
if(_doc.width  this line also do the centering.<br />
_doc.y = (_wrap.height / 2) &#8211; (_doc.height / 2);<br />
}<br />
}</p>
<p> So, as you see, its a really straight forwards and simple function. The way I see it, it supposed to work but it don&#8217;t. The last 2 IFs works fine because the _doc is smaller than _wrap. There is no scrollbar to fix and A/2 &#8211; B/2 works just fine. My best guess its that the first 2 IFs are wrong.<br />
 Or maybe the problem is with the slider. I tested the same function using 2 buttons and autoRepeat and everything worked OK. Then, I tested the slider values and I found out that when I change the slider from one side to the another (-10 to 200) by clicking the track or by slinding it really fast, the slider will always return different values. Before you ask, I put the slider.value inside a int().</p>
<p>Thanks and sorry for the looong text <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3469</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 09 May 2009 00:11:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3469</guid>
		<description>@Taniguchi, J.
Can&#039;t stay mad at Flex :) Flex is your friend.

It&#039;s probably just the math. Without seeing more of your code, I can&#039;t say for sure. But I did notice in the code you pasted:

if(_doc.width &lt; _wrap.width) {
_doc.x = (_wrap.width - (_doc.width + 8)) /2;
}
if(_doc.width &lt; _wrap.width){
_doc.y = (_wrap.height - _doc.height) /2;
}

You have two conditionals to check if(_doc.width &lt; _wrap.width){} Did you mean to check height on the second conditional?

Either way, if you do your conditionals and use the static calcX and calcY methods in the ImageResizer class, it&#039;ll correctly position the Canvas in its parent.</description>
		<content:encoded><![CDATA[<p>@Taniguchi, J.<br />
Can&#8217;t stay mad at Flex <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Flex is your friend.</p>
<p>It&#8217;s probably just the math. Without seeing more of your code, I can&#8217;t say for sure. But I did notice in the code you pasted:</p>
<p>if(_doc.width < _wrap.width) {<br />
_doc.x = (_wrap.width &#8211; (_doc.width + 8)) /2;<br />
}<br />
if(_doc.width < _wrap.width){<br />
_doc.y = (_wrap.height &#8211; _doc.height) /2;<br />
}</p>
<p>You have two conditionals to check if(_doc.width < _wrap.width){} Did you mean to check height on the second conditional?</p>
<p>Either way, if you do your conditionals and use the static calcX and calcY methods in the ImageResizer class, it&#8217;ll correctly position the Canvas in its parent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taniguchi, J.</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-3460</link>
		<dc:creator>Taniguchi, J.</dc:creator>
		<pubDate>Fri, 08 May 2009 20:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-3460</guid>
		<description>Hi, I&#039;m just starting with Flex Builder 3 and after reading a couple of books, I&#039;m trying to build my own RIA. Everything was wonderful and I was happy with the results until I got stuck with a Canvas problem. I got a canvas(A) within another canvas(B) which B can be scaled using a Slider. It worked fine but the thing is, to center the scale it making me mad. I&#039;ve been searching the net for a week and I couldn&#039;t find anything to help me figure it out. My code works but when I try to slide from 200% to 10%, to position from B gets all mess up.
My code:
/* ----------------------- */
private function alignDoc():void {
	
	if(_doc.width &gt; _wrap.width){
		_doc.x = 30;
		_wrap.horizontalScrollBar.setStyle(&quot;thumbWidth&quot;, 100);
		_wrap.horizontalScrollPosition = _wrap.horizontalScrollBar.width / 2;
	}
	if(_doc.height &gt; _wrap.height){
		_doc.y = 30;
		_wrap.verticalScrollPosition = _wrap.verticalScrollBar.height / 2;
	}
	
	if(_doc.width &lt; _wrap.width) {
		_doc.x = (_wrap.width - (_doc.width + 8)) /2;
	}
	if(_doc.width &lt; _wrap.width){
		_doc.y = (_wrap.height - _doc.height) /2;
	}
}
/* ----------------------- */

I wonder... it is a bug on Flex or in my head...? :)

I appreciate ANY help... Thanks!</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;m just starting with Flex Builder 3 and after reading a couple of books, I&#8217;m trying to build my own RIA. Everything was wonderful and I was happy with the results until I got stuck with a Canvas problem. I got a canvas(A) within another canvas(B) which B can be scaled using a Slider. It worked fine but the thing is, to center the scale it making me mad. I&#8217;ve been searching the net for a week and I couldn&#8217;t find anything to help me figure it out. My code works but when I try to slide from 200% to 10%, to position from B gets all mess up.<br />
My code:<br />
/* &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; */<br />
private function alignDoc():void {</p>
<p>	if(_doc.width &gt; _wrap.width){<br />
		_doc.x = 30;<br />
		_wrap.horizontalScrollBar.setStyle(&#8220;thumbWidth&#8221;, 100);<br />
		_wrap.horizontalScrollPosition = _wrap.horizontalScrollBar.width / 2;<br />
	}<br />
	if(_doc.height &gt; _wrap.height){<br />
		_doc.y = 30;<br />
		_wrap.verticalScrollPosition = _wrap.verticalScrollBar.height / 2;<br />
	}</p>
<p>	if(_doc.width &lt; _wrap.width) {<br />
		_doc.x = (_wrap.width &#8211; (_doc.width + 8)) /2;<br />
	}<br />
	if(_doc.width &lt; _wrap.width){<br />
		_doc.y = (_wrap.height &#8211; _doc.height) /2;<br />
	}<br />
}<br />
/* &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; */</p>
<p>I wonder&#8230; it is a bug on Flex or in my head&#8230;? <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I appreciate ANY help&#8230; Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-37</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 03 Mar 2008 18:55:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-37</guid>
		<description>Hi Aleks,
I actually never put in the code for the track click as it&#039;s just a quick sample to show the resize from center. But if you want the pic to change on track click, just add this line to the HSlider in the ResizeFromCenter.mxml (around line 33 or anywhere inside the HSlider).

change=&quot;doChangeSize(event)&quot;

problem solved :)</description>
		<content:encoded><![CDATA[<p>Hi Aleks,<br />
I actually never put in the code for the track click as it&#8217;s just a quick sample to show the resize from center. But if you want the pic to change on track click, just add this line to the HSlider in the ResizeFromCenter.mxml (around line 33 or anywhere inside the HSlider).</p>
<p>change=&#8221;doChangeSize(event)&#8221;</p>
<p>problem solved <img src='http://www.davidflatley.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aleks</title>
		<link>http://www.davidflatley.com/2007/12/27/center-registration-point-another-recipe-for-the-flex-cookbook/comment-page-1/#comment-36</link>
		<dc:creator>Aleks</dc:creator>
		<pubDate>Mon, 03 Mar 2008 08:27:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidflatley.com/?p=28#comment-36</guid>
		<description>It has a bug. If i do not move triangle, but i click on scroll line the picture will be not resized</description>
		<content:encoded><![CDATA[<p>It has a bug. If i do not move triangle, but i click on scroll line the picture will be not resized</p>
]]></content:encoded>
	</item>
</channel>
</rss>
