<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Flex Resizable Panel Component</title>
	<atom:link href="http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/feed/" rel="self" type="application/rss+xml" />
	<link>http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/</link>
	<description>Flex Tricks - Tips - Code Snippets</description>
	<lastBuildDate>Sat, 14 Nov 2009 18:48:46 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: rkdd</title>
		<link>http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/#comment-169</link>
		<dc:creator>rkdd</dc:creator>
		<pubDate>Tue, 08 Sep 2009 14:17:29 +0000</pubDate>
		<guid isPermaLink="false">http://flexscript.wordpress.com/?p=88#comment-169</guid>
		<description>No problem.

I noticed my copy/paste seems to have been messed up a little... here&#039;s what the scalePanel function should be:

private function scalePanel(e:MouseEvent):void {
	if ((stage.mouseX - x) &gt; minWidth
		&amp;&amp; (stage.mouseX - x)  minHeight
		&amp;&amp; (stage.mouseY - y) &lt; maxHeight) {
		height = (stage.mouseY - y);
	}
}</description>
		<content:encoded><![CDATA[<p>No problem.</p>
<p>I noticed my copy/paste seems to have been messed up a little&#8230; here&#8217;s what the scalePanel function should be:</p>
<p>private function scalePanel(e:MouseEvent):void {<br />
	if ((stage.mouseX &#8211; x) &gt; minWidth<br />
		&amp;&amp; (stage.mouseX &#8211; x)  minHeight<br />
		&amp;&amp; (stage.mouseY &#8211; y) &lt; maxHeight) {<br />
		height = (stage.mouseY &#8211; y);<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shrikant Patil</title>
		<link>http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/#comment-168</link>
		<dc:creator>Shrikant Patil</dc:creator>
		<pubDate>Mon, 07 Sep 2009 04:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://flexscript.wordpress.com/?p=88#comment-168</guid>
		<description>Thanks rkdd,
Thanks lot for additions for this component, which gives perfect meaning for this component. :)</description>
		<content:encoded><![CDATA[<p>Thanks rkdd,<br />
Thanks lot for additions for this component, which gives perfect meaning for this component. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rkdd</title>
		<link>http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/#comment-167</link>
		<dc:creator>rkdd</dc:creator>
		<pubDate>Fri, 04 Sep 2009 15:30:38 +0000</pubDate>
		<guid isPermaLink="false">http://flexscript.wordpress.com/?p=88#comment-167</guid>
		<description>Shrikant,

   Great simple component - was almost exactly what I was looking for! However to achieve the functionality my project requires, I made a few minor tweaks.

   Firstly, I implemented Stephen Stulov&#039;s suggestion about checking the existence of the resizer button in createChildren() so as to prevent duplicate creation of the resize button.
   
   Secondly, I changed the resize method to obey the minWidth/minHeight &amp; maxWidth/maxHeight properties. Nothin&#039; fancy, just additional constraint checking.

   Thirdly, added a resize corner/handle icon (made a transparent PNG from the corner handle of Safari). You&#039;ll need to create &amp; correctly embed your handle image you want one.


Code:


package flexscript {

	import flash.events.MouseEvent;

	import mx.containers.Panel;
	import mx.controls.Button;
	import mx.managers.CursorManager;

	public class ResizablePanel extends Panel {

		[Embed(source=&quot;../../../../../assets/imgs/resize_handle.png&quot;)] public var resizeIcon:Class;

		private var resizer:Button;

		public function ResizablePanel() {
			super();
		}

		override protected function createChildren():void {
			super.createChildren();

			if (resizer == null) {
				resizer = new Button();
				resizer.width = resizer.height = 14;
				resizer.setStyle(&quot;cornerRadius&quot;, 0);
				resizer.setStyle(&quot;icon&quot;, resizeIcon);

				rawChildren.addChild(resizer);
				resizer.addEventListener(MouseEvent.MOUSE_DOWN, resizeDown);
			}
		}

		override protected function updateDisplayList(w:Number, h:Number):void {
			super.updateDisplayList(w, h);
			resizer.x = w - resizer.width;
			resizer.y = h - resizer.height;
		}

		private function resizeDown(e:MouseEvent):void {
			stage.addEventListener(MouseEvent.MOUSE_MOVE, scalePanel);
			stage.addEventListener(MouseEvent.MOUSE_UP, stopScale);
		}

		private function scalePanel(e:MouseEvent):void {
			if ((stage.mouseX - x) &gt; minWidth
				&amp;&amp; (stage.mouseX - x)  minHeight
				&amp;&amp; (stage.mouseY - y) &lt; maxHeight) {
				height = (stage.mouseY - y);
			}
		}

		private function stopScale(e:MouseEvent):void {
			stage.removeEventListener(MouseEvent.MOUSE_MOVE, scalePanel);
			stage.removeEventListener(MouseEvent.MOUSE_UP, stopScale);
		}
	}
}</description>
		<content:encoded><![CDATA[<p>Shrikant,</p>
<p>   Great simple component &#8211; was almost exactly what I was looking for! However to achieve the functionality my project requires, I made a few minor tweaks.</p>
<p>   Firstly, I implemented Stephen Stulov&#8217;s suggestion about checking the existence of the resizer button in createChildren() so as to prevent duplicate creation of the resize button.</p>
<p>   Secondly, I changed the resize method to obey the minWidth/minHeight &amp; maxWidth/maxHeight properties. Nothin&#8217; fancy, just additional constraint checking.</p>
<p>   Thirdly, added a resize corner/handle icon (made a transparent PNG from the corner handle of Safari). You&#8217;ll need to create &amp; correctly embed your handle image you want one.</p>
<p>Code:</p>
<p>package flexscript {</p>
<p>	import flash.events.MouseEvent;</p>
<p>	import mx.containers.Panel;<br />
	import mx.controls.Button;<br />
	import mx.managers.CursorManager;</p>
<p>	public class ResizablePanel extends Panel {</p>
<p>		[Embed(source="../../../../../assets/imgs/resize_handle.png")] public var resizeIcon:Class;</p>
<p>		private var resizer:Button;</p>
<p>		public function ResizablePanel() {<br />
			super();<br />
		}</p>
<p>		override protected function createChildren():void {<br />
			super.createChildren();</p>
<p>			if (resizer == null) {<br />
				resizer = new Button();<br />
				resizer.width = resizer.height = 14;<br />
				resizer.setStyle(&#8220;cornerRadius&#8221;, 0);<br />
				resizer.setStyle(&#8220;icon&#8221;, resizeIcon);</p>
<p>				rawChildren.addChild(resizer);<br />
				resizer.addEventListener(MouseEvent.MOUSE_DOWN, resizeDown);<br />
			}<br />
		}</p>
<p>		override protected function updateDisplayList(w:Number, h:Number):void {<br />
			super.updateDisplayList(w, h);<br />
			resizer.x = w &#8211; resizer.width;<br />
			resizer.y = h &#8211; resizer.height;<br />
		}</p>
<p>		private function resizeDown(e:MouseEvent):void {<br />
			stage.addEventListener(MouseEvent.MOUSE_MOVE, scalePanel);<br />
			stage.addEventListener(MouseEvent.MOUSE_UP, stopScale);<br />
		}</p>
<p>		private function scalePanel(e:MouseEvent):void {<br />
			if ((stage.mouseX &#8211; x) &gt; minWidth<br />
				&amp;&amp; (stage.mouseX &#8211; x)  minHeight<br />
				&amp;&amp; (stage.mouseY &#8211; y) &lt; maxHeight) {<br />
				height = (stage.mouseY &#8211; y);<br />
			}<br />
		}</p>
<p>		private function stopScale(e:MouseEvent):void {<br />
			stage.removeEventListener(MouseEvent.MOUSE_MOVE, scalePanel);<br />
			stage.removeEventListener(MouseEvent.MOUSE_UP, stopScale);<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shrikant Patil</title>
		<link>http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/#comment-33</link>
		<dc:creator>Shrikant Patil</dc:creator>
		<pubDate>Fri, 26 Sep 2008 11:53:37 +0000</pubDate>
		<guid isPermaLink="false">http://flexscript.wordpress.com/?p=88#comment-33</guid>
		<description>Yes that is important thing. Thanks  for commenting on it. We become perfect if we share! Thanks again.</description>
		<content:encoded><![CDATA[<p>Yes that is important thing. Thanks  for commenting on it. We become perfect if we share! Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Stulov</title>
		<link>http://flexscript.wordpress.com/2008/08/28/flex-resizable-panel-component/#comment-32</link>
		<dc:creator>Stephen Stulov</dc:creator>
		<pubDate>Fri, 26 Sep 2008 06:54:16 +0000</pubDate>
		<guid isPermaLink="false">http://flexscript.wordpress.com/?p=88#comment-32</guid>
		<description>inside createChildren() method you should check whether the component is already created and added with addChild() call.

override protected function createChildren():void
{
             super.createChildren();
             if( resizer == null )
             {
                          resizer = new Button();
                          resizer.height=10;  
                          resizer.width = 10;    
                          rawChildren.addChild(resizer);
             }  
}

Since createChildren() method is called every time the panel is added. Your method is good. But if you will removeChild() your panel, and then addChild() it again - createChildren() method will be called again, and button is reattached.</description>
		<content:encoded><![CDATA[<p>inside createChildren() method you should check whether the component is already created and added with addChild() call.</p>
<p>override protected function createChildren():void<br />
{<br />
             super.createChildren();<br />
             if( resizer == null )<br />
             {<br />
                          resizer = new Button();<br />
                          resizer.height=10;<br />
                          resizer.width = 10;<br />
                          rawChildren.addChild(resizer);<br />
             }<br />
}</p>
<p>Since createChildren() method is called every time the panel is added. Your method is good. But if you will removeChild() your panel, and then addChild() it again &#8211; createChildren() method will be called again, and button is reattached.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
