<?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>aut0poietic</title>
	<atom:link href="http://aut0poietic.us/feed/" rel="self" type="application/rss+xml" />
	<link>http://aut0poietic.us</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Wed, 08 Sep 2010 02:20:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>TextArea Automatically Resize</title>
		<link>http://aut0poietic.us/2009/06/18/textarea-auto-resize/</link>
		<comments>http://aut0poietic.us/2009/06/18/textarea-auto-resize/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 20:35:06 +0000</pubDate>
		<dc:creator>aut0poietic</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[TextArea]]></category>

		<guid isPermaLink="false">http://aut0poietic.us/?p=1</guid>
		<description><![CDATA[Your Flex TextArea controls getting clipped?  This little piece of code fixes that. Sample code and a class after the jump.]]></description>
			<content:encoded><![CDATA[<p>Posting this just on the off-chance someone else ran into the issue and the solutions on the net weren&#8217;t up to their needs.</p>
<p>In a project, I&#8217;m using a TextArea control because it&#8217;s better at displaying images inline using the htmlText property &#8212; the Text control completely failed. But once I did this, I kept finding the text getting clipped.</p>
<p>TextArea controls expect that they&#8217;ll have a fixed or percentage width and height. Most of the suggestions I&#8217;ve seen require the use of getTextMetrics() for the mx_internal textField control of the TextArea. This fails miserably if there is any font sizing or inlined images in the html.</p>
<p>This (placed in creationComplete) works nearly perfectly:</p>
<pre class="brush: php;">

protected function onCreationComplete(event:Event):void
{
	//textAreaControl is the id of the control you want to resize to contain it's text.
	textAreaControl.validateNow() ;
	textAreaControl.mx_internal::getTextField().autoSize = TextFieldAutoSize.LEFT ;
	textAreaControl.mx_internal::getTextField().validateNow();
	textAreaControl.height = textAreaControl.mx_internal::getTextField().height ;
}
</pre>
<p>It would be just as easy to subclass the TextArea control and apply this on set htmlText().</p>
<p>One minor error with this is that before creationComplete is run, the text is briefly visible in it&#8217;s unsized state. If you&#8217;re using this in a subclassing situation, no worries, but if you&#8217;re applying this from a parent-&gt;child situation, you&#8217;re going to have to handle the appearance changes (but that&#8217;s fairly obvious &#8212; just felt it needed qualifying).</p>
<p>Hope that helps someone out.</p>
<p>Update:</p>
<p>Created the class in the comments below, figured I&#8217;d update the article:</p>
<pre class="brush: as3;">

package us.aut0poietic.controls.text
{
	import flash.text.TextFieldAutoSize;
	import mx.core.mx_internal;
	import mx.controls.TextArea;
;

	public class AutoSizeTextArea extends TextArea
	{
		public function AutoSizeTextArea()
		{
			super();
		}
		override public function set text(value:String):void
		{
			super.text = value ;
			updateSize() ;
		}
		override public function set htmlText(value:String):void
		{
			super.data = value ;
			updateSize() ;
		}
		override protected function commitProperties():void
		{
			super.commitProperties() ;
			updateSize() ;
		}
		protected function updateSize():void
		{
			if(mx_internal::getTextField() != null)
			{
				validateNow() ;
				mx_internal::getTextField().autoSize = TextFieldAutoSize.LEFT ;
				mx_internal::getTextField().validateNow();
				this.height = mx_internal::getTextField().height ;
			}
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://aut0poietic.us/2009/06/18/textarea-auto-resize/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AdvancedDataGrid Edit on DoubleClick</title>
		<link>http://aut0poietic.us/2009/03/17/advanceddatagrid-edit-on-doubleclick/</link>
		<comments>http://aut0poietic.us/2009/03/17/advanceddatagrid-edit-on-doubleclick/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 02:17:59 +0000</pubDate>
		<dc:creator>aut0poietic</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[AdvancedDataGrid]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://aut0poietic.us/?p=146</guid>
		<description><![CDATA[Want the cells in a Flex DataGrid to behave like they do in Microsoft Excel? Here's an easy fix.]]></description>
			<content:encoded><![CDATA[<p>This was too cool and too simple, so I had to share. I&#8217;m searching for a way to allow the user to select a row without editing a cell in an AdvancedDataGrid Component. The default behavior is when you click on a cell, you edit that cell. I don&#8217;t want to edit, I want to select.</p>
<p>I sub classed AdvancedDataGrid, but came up with all sorts of problems that made it unfeasible. Then on another post telling me how to sub class DataGrid (not even ADG), I saw a simple little bit of code that did nearly exactly what I wanted:</p>
<pre class="brush: as3;">

private var previousIndex:int = -1;
private function confirmEdit(event:AdvancedDataGridEvent):void
{
	if (previousIndex != event.rowIndex)
	{
    	previousIndex = event.rowIndex;
    	event.preventDefault();
	}
}
</pre>
<p>PAINFULLY easy. The poster didn&#8217;t link to their site, or I&#8217;d cite the source here, but wherever you are &#8220;pinto&#8221; I owe you one.</p>
]]></content:encoded>
			<wfw:commentRss>http://aut0poietic.us/2009/03/17/advanceddatagrid-edit-on-doubleclick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
