<?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>Iwo Banaś - Flex Blog &#187; Flex 3</title>
	<atom:link href="http://www.iwobanas.com/tag/flex-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iwobanas.com</link>
	<description>Adobe Flex and AIR thoughts, custom components, how-to’s...</description>
	<lastBuildDate>Tue, 02 Feb 2010 22:54:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Scrolling and zooming chart with CategoryAxis</title>
		<link>http://www.iwobanas.com/2009/08/scrolling-and-zooming-chart-with-categoryaxis/</link>
		<comments>http://www.iwobanas.com/2009/08/scrolling-and-zooming-chart-with-categoryaxis/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 20:12:44 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[charts]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=144</guid>
		<description><![CDATA[Title of this post is a little bit misleading because it is not possible to use ChartScroller directly with CategoryAxis. This is because ChartScroller relays on axis minimum/maximum properties which are not present in CategoryAxis. Luckily it is possible to simulate CategoryAxis behavior with LinearAxis which is supported by ChartScroller. I will describe how to [...]]]></description>
			<content:encoded><![CDATA[<p>Title of this post is a little bit misleading because it is not possible to use ChartScroller directly with CategoryAxis. This is because ChartScroller relays on axis minimum/maximum properties which are not present in CategoryAxis. Luckily it is possible to simulate CategoryAxis behavior with LinearAxis which is supported by ChartScroller. I will describe how to do it in this post.<br />
<span id="more-144"></span></p>
<h3>Simple scenario</h3>
<p>The simplest and quite common scenario is having one data provider containing objects with single property determining category and further properties determining values of the series. Such data provider may look something like this (code copied from Flex API examples):</p>
<pre>
[Bindable]
public var dp:ArrayCollection = new ArrayCollection( [
    { Month: "Jan", Profit: 2000, Expenses: 1500, Amount: 450 },
    { Month: "Feb", Profit: 1000, Expenses: 200, Amount: 600 },
    { Month: "Mar", Profit: 1500, Expenses: 500, Amount: 300 },
    { Month: "Apr", Profit: 1800, Expenses: 1200, Amount: 900 },
    { Month: "May", Profit: 2400, Expenses: 575, Amount: 500 } ]);
</pre>
<p>In such case we have to do three things to simulate CategoryAxis behavior with LinearAxis:</p>
<ul>
<li>Declare only yField property of series (not xField).</li>
<li>Create label function converting data provider index to category name.</li>
<li>Declare LinearAxis using created label function with interval property set to 1.</li>
</ul>
<p>Label function may look like this (If xField of series is not specified Flex passes item index as labelValue so all we have to do is find correct item and return category value):</p>
<pre>
public function categoryLabelFunction(labelValue:Object,
                        previousValue:Object, axis:IAxis):String
{
    var index:int = int(labelValue);

    if (index >= 0 &#038;&#038; index < dp.length)
        return dp[index].Month;
    return "";
}
</pre>
<p>As you can see chart MXML code is only slightly modified compared to code using standard CategoryAxis:</p>
<pre>
&lt;mx:ColumnChart id="columnChart" width="100%" height="100%"
    gutterLeft="50" gutterRight="40" dataProvider="{dp}"&gt;
    &lt;mx:series&gt;
        &lt;!-- Note that xField is not specified --&gt;
        &lt;mx:ColumnSeries yField="Profit" /&gt;
        &lt;mx:ColumnSeries yField="Expenses" /&gt;
        &lt;mx:ColumnSeries yField="Amount" /&gt;
    &lt;/mx:series&gt;
    &lt;mx:horizontalAxis&gt;
        &lt;!-- LinearAxis simulating CategoryAxis --&gt;
        &lt;mx:LinearAxis interval="1"
            labelFunction="categoryLabelFunction" /&gt;
    &lt;/mx:horizontalAxis&gt;
&lt;/mx:ColumnChart&gt;
</pre>
<p><a title="Sources" href="/wp-content/uploads/chart_scroller_category_axis_01/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="ChartScroller example sources" href="/wp-content/uploads/chart_scroller_category_axis_01/srcview/ChartScrollerCategoryAxis01.zip">here</a>.</p>
<p><iframe src="/wp-content/uploads/chart_scroller_category_axis_01/ChartScrollerCategoryAxis01.html" width="100%" height="350" frameborder="no"  onMouseWheel="return false;" ></iframe></p>
<h3>More complex scenario</h3>
<p>In some cases you may need to use xField series properties. For example you may be using separate data providers of different length for different series. In such case additional parse function have to be created to convert category name to numeric value which can be placed along LinearAxis. You can find full example of such scenario <a title="Sources" href="/wp-content/uploads/chart_scroller_category_axis_02/srcview/index.html" target="_blank">here</a>.</p>
<p><a title="Sources" href="/wp-content/uploads/chart_scroller_category_axis_02/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="ChartScroller example sources" href="/wp-content/uploads/chart_scroller_category_axis_02/srcview/ChartScrollerCategoryAxis02.zip">here</a>.</p>
<p><iframe src="/wp-content/uploads/chart_scroller_category_axis_02/ChartScrollerCategoryAxis02.html" width="100%" height="350" frameborder="no"  onMouseWheel="return false;" ></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/08/scrolling-and-zooming-chart-with-categoryaxis/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Scrolling and zooming chart with ChartScroller</title>
		<link>http://www.iwobanas.com/2009/07/scrolling-and-zooming-chart-with-chartscroller/</link>
		<comments>http://www.iwobanas.com/2009/07/scrolling-and-zooming-chart-with-chartscroller/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 14:00:54 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[charts]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=129</guid>
		<description><![CDATA[Some time ago I presented scrolling chart by using modified axis renderer (ScrollableAxisRenderer). I rethought this concept and come to the point that axis renderer should render axis not scroll the chart, so chart scrolling should be implemented as separate component. This is especially true in case of charts with many axes and renderers. My [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I presented scrolling chart by using modified axis renderer (ScrollableAxisRenderer). I rethought this concept and come to the point that axis renderer should render axis not scroll the chart, so chart scrolling should be implemented as separate component. This is especially true in case of charts with many axes and renderers. My new idea was to create nonvisual component which will take reference to a chart and add appropriate listeners modifying axes minimum/maximum to achieve scrolling /zooming.<br />
<span id="more-129"></span></p>
<p>It was the challenge to find the way to easily convert mouse position to data coordinates and vice versa. According to documentation DataTransform objects should be used for this purpose, but unfortunately this documentation is quite incomplete. I especially like this sentence <em>&#8220;In theory, a chart can contain multiple overlaid DataTransform objects.&#8221;</em> – what does it mean <em>&#8220;in theory&#8221;</em> ? Having two vertical or horizontal axes is quite common case and in such case different data transformation have to be done for each axis. If charting sources were open it would at least be possible to figure out how data transformation is working reading code…</p>
<p>Anyway, finally I have found that chart series (<a href="http://livedocs.adobe.com/flex/3/langref/mx/charts/chartClasses/Series.html" target="_blank">Series</a>) inherits two function (<code>localToData()</code> and <code>dataToLocal()</code>) to transform points to and from data coordinates. Using these functions I have implemented component named <a href="/wp-content/uploads/chart_scroller_01/srcview/source/com/iwobanas/charts/ChartScroller.as.html" target="_blank">ChartScrolle</a>r.</p>
<p>All you have to do to enable chart scrolling/zooming using ChartScroller is create instance of ChartScroller and pass reference to the chart to it. You can do it in MXML using the code similar to the one below:</p>
<pre>
&lt;charts:ChartScroller id="scroller" chart="{chart}" /&gt;

&lt;mx:ColumnChart id="chart" width="100%" height="100%"
    gutterLeft="40" gutterRight="10" dataProvider="{dp}"&gt;
    &lt;mx:series&gt;
        &lt;mx:ColumnSeries id="series1" xField="x" yField="y2" /&gt;
        &lt;mx:ColumnSeries id="series2" xField="x" yField="y1" /&gt;
    &lt;/mx:series&gt;
&lt;/mx:ColumnChart&gt;
</pre>
<p>ChartScroller is hosted on <a href="http://code.google.com/p/reusable-fx/" target="_blank">http://code.google.com/p/reusable-fx/</a>. Currently charts with LinearAxis or DateTimeAxis are supported.</p>
<h3>Basic Example</h3>
<p><a title="Sources" href="/wp-content/uploads/chart_scroller_01/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="ChartScroller example sources" href="/wp-content/uploads/chart_scroller_01/srcview/ChartScrollerExample01.zip">here</a>.</p>
<p><iframe src="/wp-content/uploads/chart_scroller_01/ChartScrollerExample01.html" width="100%" height="350" frameborder="no"  onMouseWheel="return false;" ></iframe></p>
<h3>Example &#8211; using ChartScroller with many axes</h3>
<p>You can use ChartScroller for chart with multiple axes, so that different axes can be scrolled separately. To scroll/zoom concrete axis grab series using this axis or axis renderer.</p>
<p><a title="Sources" href="/wp-content/uploads/chart_scroller_02/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="ChartScroller example sources" href="/wp-content/uploads/chart_scroller_02/srcview/ChartScrollerExample02.zip">here</a>.</p>
<p><iframe src="/wp-content/uploads/chart_scroller_02/ChartScrollerExample02.html" width="100%" height="350" frameborder="no"  onMouseWheel="return false;" ></iframe></p>
<h3>Example &#8211; ChartScroller properties</h3>
<p><a href="/wp-content/uploads/chart_scroller_03/ChartScrollerExample.html" target="_blank">This example</a> demonstrates  how you can adjust behavior of ChartScroller by setting some of it public properties.</p>
<p>ChartScroller dispatches change event every time axis minimum/maximum value is modified. It also dispatches valueCommit event after specified time from last modification. This event may be used to retrieve new data or update other controls based on new axes minimum/maximum values. I will present example retrieving data from remote service on valueCommit event in separate post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/07/scrolling-and-zooming-chart-with-chartscroller/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Creating MDataGrid date filter</title>
		<link>http://www.iwobanas.com/2009/07/creating-mdatagrid-date-filter/</link>
		<comments>http://www.iwobanas.com/2009/07/creating-mdatagrid-date-filter/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 12:33:50 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[MXML]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=107</guid>
		<description><![CDATA[In this post I will describe how to create custom filter for MDataGrid (my extension of Flex 3 DataGrid described in one of the previous posts and hosted on http://code.google.com/p/reusable-fx/). I will guide you through creation of date filter as an example.
I consider extensibility one of the most important feature of well designed reusable component [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I will describe how to create custom filter for MDataGrid (my extension of Flex 3 DataGrid described in one of the previous posts and hosted on <a href="http://code.google.com/p/reusable-fx/" target="_blank">http://code.google.com/p/reusable-fx/</a>). I will guide you through creation of date filter as an example.</p>
<p>I consider extensibility one of the most important feature of well designed reusable component and that’s why I am trying to make process of creating new MDataGrid filters as straightforward as possible.</p>
<p><span id="more-107"></span></p>
<p>Following <em>&#8220;Favor object composition over class inheritance.&#8221;</em> rule I decided to split filtering functionality among a number of classes rather than write another thousand lines of DataGrid code. At the first glance the solution may look complicated but after understanding responsibilities of &#8220;filters&#8221; and &#8220;filter editors&#8221; it is really straightforward.</p>
<p><strong>Filter editors</strong> are the components displayed below column header after clicking filter button. Filter editor know nothing about business logic of filtering, their only responsibility is to present current state of the filter to the user and modify filter according to users actions. Filter editor may be any component implementing <a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filterEditors/IColumnFilterEditor.as.html" target="_blank">IColumnFilterEditor</a> interface. The default implementation of this interface is <a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filterEditors/FilterEditorBase.as.html" target="_blank">FilterEditorBase</a> class extending Box which is used as a base class for all standard MDataGrid filter editors. In the presented example we will create filter editor in MXML extending <a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filterEditors/FilterEditorBase.as.html" target="_blank">FilterEditorBase</a> class.</p>
<p><strong>Filter</strong> classes are where actual filtering takes place, they implement <code>filterFunction</code> which is used to eliminate items from MDataGrid data provider. Filters are also responsible for examining MDataGrid and presenting information about MDataGrid content to filter editors. In our example filter will present minimum and maximum dates found in given column. All filters extends <a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filters/ColumnFilterBase.as.html" target="_blank">ColumnFilterBase</a> class.</p>
<p>To implement date filtering mechanism two classes have to be implemented: filter class (<a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filters/DateRangeFilter.as.html" target="_blank">DateRangeFilter</a>) and filter editor class (<a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filterEditors/DateChooserFilterEditor.mxml.html" target="_blank">DateChooserFilterEditor</a>).</p>
<h3>DateRangeFilter</h3>
<p>DateRangeFilter extends ColumnFilterBase class and defines four fields: <code>dataMinimum</code>, <code>dataMaximum</code>, <code>minimum</code> and <code>maximum</code>.</p>
<p><code>dataMinimum</code> and <code>dataMaximum</code> represents a earliest and latest dates found in MDataGrid. These fields are updated by <code>updateOriginalDateRange()</code> function.</p>
<p><code>minimum</code> and <code>maximum</code> defines the range of dates which will be displayed in MDataGrid. By default <code>minimum</code> is set to <code>dataMinimum</code> and <code>maximum</code> is set to <code>dataMaximum</code> which means that all data are displayed (filter is inactive). It is important to call <code>commitFilterChange()</code> function inside <code>minimum/maximum</code> setter to inform MDataGrid that filter value have changed.</p>
<p>DateRangeFilter also overrides two functions defined in ColumnFilterBase:</p>
<p><code>isActive</code> getter checks if filter is active i.e. if it may eliminate any items form MDataGrid. In our case isActive getter simply checks if <code>minimum</code> and <code>maximum</code> differs from <code>dataMinimum</code> and <code>dataMaximum</code>.</p>
<pre>
override public function get isActive():Boolean
{
    return (minimum != dataMinimum || maximum != dataMaximum);
}
</pre>
<p><code>filterFunction</code> checks if item passed as an argument should be eliminated. First date displayed in column associated with this filter is extracted from given item and then it is compared against <code>minimum</code> and <code>maximum</code>. If the value is within the range <code>true</code> is returned (item is not eliminated) other ways <code>false</code> is returned (item is filtered out). If no date is fond for the given item <code>true</code> is returned. <code>filterFunction</code> is called many times for every MDataGrid item so it should not be computationally expensive.</p>
<pre>
override public function filterFunction(obj:Object):Boolean
{
    var value:Date = itemToDate(obj);

    if (value)
    {
        if (minimum &#038;&#038; value < minimum)
        {
            return false;
        }
        if (maximum &#038;&#038; value > maximum)
        {
            return false;
        }
    }
    return true;
}
</pre>
<p>You can find two additional functions in <a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filters/DateRangeFilter.as.html" target="_blank">DateRangeFilter</a> code: <code>itemToDate()</code> is responsible for extracting date from data item and <code>originalCollectionChandeHandler()</code> refresh <code>dataMinimum</code> and <code>dataMaximum</code> when MDataGrid original collection (copy of data provider) changes.</p>
<h3>DateChooserFilterEditor</h3>
<p><strong>Good news:</strong> creating filter editors in MXML is much simpler than coding filter and the effect is instantly visible!</p>
<p>To make curly brackets binding simpler it is good idea to create strongly typed, bindable reference to filter instance edited by filter editor. The code below is the only code placed in <code>&lt;script&gt;</code> tag of our filter editor:</p>
<pre>
[Bindable]
protected var filter:DateRangeFilter;

override public function startEdit(column:MDataGridColumn):void
{
    super.startEdit(column);
    if (!column.filter || !column.filter is DateRangeFilter)
    {
        column.filter = new DateRangeFilter(column);
    }
    filter = column.filter as DateRangeFilter;
}
</pre>
<p>All you have to do now to create cool filter editor is placing MXML components with appropriate bindings and inline event handlers. Below you can see my proposals how date filter editor may look like.</p>
<p>The simple <a href="/wp-content/uploads/date_filter_01/srcview/source/com/iwobanas/controls/dataGridClasses/filterEditors/DateChooserFilterEditor.mxml.html" target="_blank">DateChooserFilterEditor</a> consists of two DateChoosers and reset button.<br />
<a title="Sources" href="/wp-content/uploads/date_filter_01/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="MDataGrid date filter sources" href="/wp-content/uploads/date_filter_01/srcview/DateFilterExample01.zip">here</a>.</p>
<p>For better experience <a href="/wp-content/uploads/date_filter_01/DateFilterExample.html" target="_blank">open example in separate window</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/date_filter_01/DateFilterExample.html" width="100%" height="560" frameborder="no"></iframe></p>
<p>To save some space I have replaced DataChoosers with DateField and created <a href="/wp-content/uploads/date_filter_02/srcview/source/com/iwobanas/controls/dataGridClasses/filterEditors/DateFieldFilterEditor.mxml.html" target="_blank">DateFieldFilterEditor</a>.<br />
<a title="Sources" href="/wp-content/uploads/date_filter_02/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="MDataGrid date filter sources" href="/wp-content/uploads/date_filter_02/srcview/DateFilterExample02.zip">here</a>.</p>
<p>For better experience <a href="/wp-content/uploads/date_filter_02/DateFilterExample.html" target="_blank">open example in separate window</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/date_filter_02/DateFilterExample.html" width="100%" height="350" frameborder="no"></iframe></p>
<p>Of course dates may be filtered in many different ways. For example date filter editor may consist of two NumericSteppers to select years. I hope now you can create such filter editor by yourself.</p>
<p>If you have any questions or suggestions don&#8217;t hesitate to add a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/07/creating-mdatagrid-date-filter/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>DataGrid with client-side filtering and searching</title>
		<link>http://www.iwobanas.com/2009/06/datagrid-with-client-side-filtering-and-searching/</link>
		<comments>http://www.iwobanas.com/2009/06/datagrid-with-client-side-filtering-and-searching/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 22:47:03 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=83</guid>
		<description><![CDATA[I am working on reusable Flex 3 DataGrid extension allowing client-side filtering and searching, and probably many other features in the future. Although it is not finished yet I decided to publish the result of my work to get some feedback from you:-)
The project source repository is located at http://code.google.com/p/reusable-fx/
You can also view source of [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on reusable Flex 3 DataGrid extension allowing client-side filtering and searching, and probably many other features in the future. Although it is not finished yet I decided to publish the result of my work to get some feedback from you:-)</p>
<p>The project source repository is located at <a href="http://code.google.com/p/reusable-fx/">http://code.google.com/p/reusable-fx/</a><br />
You can also <a href="http://www.iwobanas.com/wp-content/uploads/data_grid_02/srcview/index.html" target="_blank">view source</a> of the example below.</p>
<p><span id="more-83"></span></p>
<p>I consider few things extremely important when creating new components:</p>
<h3>Reusability</h3>
<p>New DataGrid component should work not only for one cool demo but could be reused and reconfigured in many different applications. Every newly added element should support styling and/or skinning.</p>
<h3>Extensibility</h3>
<p>New DataGrid should allow further extension without need to rewrite too much code. During implementation of new features standard, well documented interfaces and patterns should be created to make further development easier. For example current version support filtering of text and numerical data but creation of filter for date ranges or images should be straightforward.</p>
<h3>Compatibility</h3>
<p>Compatibility with standard Flex DataGrid should be regarded very important and every incompatibilities should be well documented. For example one should be able to use filtering on one column when leaving other columns unchanged. Newly created interfaces should be similar to those known from standard Flex components.</p>
<p>I am trying to follow the rules above but of course it is not always possible. Especially if you are working on something for a long time it is difficult to tell what is intuitive for “ordinary user”. So if you play with example below and found something which in your opinion should work differently don’t hesitate to add a comment or create new issue on <a href="http://code.google.com/p/reusable-fx/issues/list">http://code.google.com/p/reusable-fx/issues/list</a> !</p>
<h3>Summary</h3>
<p>MDataGrid can be used just like standard DataGrid: you define a <code>dataProvider</code> and <code>columns</code> either in MXML or in ActionScript. If you want a column to allow filtering replace DataGridColumn with MDataGridColumn which by default has a text wildcard filtering enabled. If you prefer to filter column in a different way change <code>filterEditor</code> property of the column to point to some filter editor from <code>com.iwobanas.controls.dataGridClasses.filterEditors</code> package. You can find more information in the ASDoc in the source code. </p>
<h3>Example</h3>
<p>This example demonstrates live searching and filtering MDataGrid with about 400 rows.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/data_grid_02/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="MDataGrid sources" href="http://www.iwobanas.com/wp-content/uploads/data_grid_02/srcview/DataGrid02.zip">here</a>. </p>
<p>For better experience <a href="http://www.iwobanas.com/wp-content/uploads/data_grid_02/DataGridExample.html" target="_blank">open example in separate window</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/data_grid_02/DataGridExample.html" width="100%" height="350" frameborder="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/06/datagrid-with-client-side-filtering-and-searching/feed/</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>Scrollable Chart Axis Renderer</title>
		<link>http://www.iwobanas.com/2009/06/scrollable-chart-axis-renderer/</link>
		<comments>http://www.iwobanas.com/2009/06/scrollable-chart-axis-renderer/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 22:51:03 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[charts]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=64</guid>
		<description><![CDATA[Some time ago I was asked to create column chart representing data in time with user friendly interface to change period of analysis. Current solution was consisted of two data fields to select date range and it was OK but it wasn’t really Flexy.
I decided to enable scrolling the chart by dragging the axis so [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I was asked to create column chart representing data in time with user friendly interface to change period of analysis. Current solution was consisted of two data fields to select date range and it was OK but it wasn’t really Flexy.</p>
<p>I decided to enable scrolling the chart by dragging the axis so that if one wants to see what’s beyond the left edge of chart (s)he can simply drag the charts horizontal axis and scroll it right. To enable zooming the data I chose to use mouse wheel. Generally these ideas was based on popular maps services interfaces.</p>
<p><strong>This example is deprecated, consider using <a href="http://www.iwobanas.com/2009/07/scrolling-and-zooming-chart-with-chartscroller/">ChartScroller</a> instead!!!</strong><br />
<span id="more-64"></span></p>
<h3>Prototype implementation</h3>
<p>Implementation of fully working prototype was really straightforward. In just a few hours I tangled standard column chart with a bunch of event listeners and scrolling/zooming was working. This is what I like in Flex. The next challenge was to create reusable component which could be applied to any chart.</p>
<h3>Reusable component implementation</h3>
<p>After some investigation I decided to create a subclass of AxisRenderer which will automatically register required listeners and modify corresponding axis minimum and maximum values. I have faced some problems with lack of (or undocumented) functions transforming mouse position along axis renderer to data values. It’s a pity that Flex charting sources are closed, if they were open surely I will find much useful code hidden as private or mx_internal. Anyway, after some playing with debugger I have created my own implementation based on axis minimum/maximum values and renderers gutters. You can see the result below.</p>
<h3>TODOs</h3>
<p>There are still few things to be done to improve this component.</p>
<ul>
<li>The most important is to add event dispatched certain time after user finished moving or zooming the chart. Such event would allow developer to update chart data provider basing on selected minimum and maximum values.</li>
<li>Cursor might be changed to indicate grabbing axis.</li>
<li>Area of axis containing labels might also be mouse sensitive.</li>
<li>If you have any other ideas add a comment!</li>
</ul>
<p>This example demonstrates scrolling and zooming chart using ScrollableAxisRenderer.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/scrollable_chart_01/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="ScrollabeleAxisRenderer sources" href="http://www.iwobanas.com/wp-content/uploads/scrollable_chart_01/srcview/ScrollableAxisRenderer02.zip">here</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/scrollable_chart_01/ScrollableAxisRendererExample.html" width="100%" height="350" frameborder="no" onMouseWheel="return false;" ></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/06/scrollable-chart-axis-renderer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Searchable DataGrid</title>
		<link>http://www.iwobanas.com/2009/06/searchable-datagrid/</link>
		<comments>http://www.iwobanas.com/2009/06/searchable-datagrid/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 14:49:24 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=51</guid>
		<description><![CDATA[Although standard Flex 3 DataGrid implements findString() function it is not really usable. Searching only the first column or the column with sorting enabled is definitely not intuitive and skipping to the next match on every keystroke is confusing. Furthermore calling to findString() changes selected index without highlighting matching text so in DataGrid with many [...]]]></description>
			<content:encoded><![CDATA[<p>Although standard Flex 3 DataGrid implements findString() function it is not really usable. Searching only the first column or the column with sorting enabled is definitely not intuitive and skipping to the next match on every keystroke is confusing. Furthermore calling to findString() changes selected index without highlighting matching text so in DataGrid with many columns it may be hard to figure out where the matching text is located.</p>
<p>Given above I decided to create new more flexible and reusable searching mechanism for DataGrid. As I was working on it I realized that other components (e.g. TextArea) may also support searching. That’s why I decided to create <a href="http://www.iwobanas.com/wp-content/uploads/data_grid_01/srcview/source/com/iwobanas/core/ISearchable.as.html">ISearchable</a> interface to be implemented by every component supporting searching.</p>
<p>I also decided that searching should support standard wildcards like “*” or “?” so I created <a href="http://www.iwobanas.com/wp-content/uploads/data_grid_01/srcview/source/com/iwobanas/utils/WildcardUtils.as.html">WlidcardUtils</a> class to convert wildcards to regular expressions which are internally used by my searching mechanism. I know that regular expressions aren’t very fast so maybe one day I will write my own mechanism for matching wildcards but for now RegExp’s are enough.</p>
<p><span id="more-51"></span></p>
<p>To support searched text to be highlighted I have implemented <a href="http://www.iwobanas.com/wp-content/uploads/data_grid_01/srcview/source/com/iwobanas/controls/dataGridClasses/BoldSearchItemRenderer.as.html">BoldSearchItemRenderer</a> which can be used instead of standard DataGridItemRenderer.</p>
<p>Finally I have extended <a href="http://www.iwobanas.com/wp-content/uploads/data_grid_01/srcview/source/com/iwobanas/controls/DataGrid.as.html">DataGrid</a> to implement ISearchable interface. I haven’t named it SearchableDataGrid since I am going to add many other features later and as AdvancedDataGrid name was in use too I decided to leave the name DataGrid changing only the package.</p>
<p>This example demonstrates live searching DataGrid with about 400 rows.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/data_grid_01/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="Searchable DataGrid sources" href="http://www.iwobanas.com/wp-content/uploads/data_grid_01/srcview/DataGrid01.zip">here</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/data_grid_01/DataGridExample.html" width="100%" height="350" frameborder="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/06/searchable-datagrid/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Implementing Slide effects &#8211; iteration 3</title>
		<link>http://www.iwobanas.com/2009/06/implementing-slide-effects-iteration-3/</link>
		<comments>http://www.iwobanas.com/2009/06/implementing-slide-effects-iteration-3/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 11:18:33 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[effects]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[how-to]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=38</guid>
		<description><![CDATA[This post is a continuation of iteration 2. From the end user point of view Slide effects presented  here are almost identical to these from previous post. The only difference is that target components shadow or other filter drawn beside components bounds (0,0 to width, height rectangle) are not cropped during slide animation.
A number [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a continuation of <a href="http://www.iwobanas.com/2009/05/implementing-slide-effects-iteration-2/">iteration 2</a>. From the end user point of view Slide effects presented  here are almost identical to these from previous post. The only difference is that target components shadow or other filter drawn beside components bounds (0,0 to width, height rectangle) are not cropped during slide animation.</p>
<p>A number of changes was required to implement this functionality:</p>
<p><span id="more-38"></span></p>
<h3>Determining components visible bounds</h3>
<p>First of all actual components visible bounds have to be determined. I have found code to do that in private function of MaskEffectInstance class from Flex 3 framework. As I believe that such code shouldn’t be rewritten every time someone need it I have created utility class named ComponentUtils and copied code from MaskEffectInstance  to a public static function.</p>
<p>Knowing what are the visible bounds of the component I have discovered that x and y coordinate of visible rectangle are often negative (when filter is drawn at the left or above component). According to DisplayObjec documentation when scrollRect property is set the visible area upper-left corner is defined by components (0,0) point. So to enable displaying of filtered component (e.g. shadow) at the left or above component I had to move component there and back as described in next two paragraphs.</p>
<h3>Moving component (up/left) so that its origin (0,0 point) equals to visible rectangle upper-left corner</h3>
<p>To move component origin to visible rectangle origin I have adjusted its x and y coordinates in effect instance play() function:</p>
<pre>
target.x += visibleRect.x;
target.y += visibleRect.y
</pre>
<p>I have also remembered to restore component to its original position at effect end (onTweenEnd() function):</p>
<pre>
target.x -= visibleRect.x;
target.y -= visibleRect.y
</pre>
<h3>Moving component content back (down/right) so that it is displayed at the original location</h3>
<p>To balance component movement I have adjusted scrollRect x and y coordinates in concrete effect instance onTweenUpdate functions. If these values are set to negative values (visible rectangle x,y) component is moved right-down. After applying this changes effect seems to work as before but shadows are visible.
<p/>
<p>The following example demonstrates all SlideRight, SlideLeft, SlideDown and SlideUp effects.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_03/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="Slide effects sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_03/srcview/SlideEffect03.zip">here</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/slide_effect_03/SlideEffectsExample.html" width="100%" height="350" frameborder="no"></iframe></p>
<p>The following example demonstrates SlideDown and SlideUp effects applied to a VBox with DropShadowFilter enabled.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_03ex2/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="Slide effects sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_03ex2/srcview/SlideEffect03.zip">here</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/slide_effect_03ex2/SlideWithShadowExample.html" width="100%" height="350" frameborder="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/06/implementing-slide-effects-iteration-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Implementing Slide effects &#8211; iteration 2</title>
		<link>http://www.iwobanas.com/2009/05/implementing-slide-effects-iteration-2/</link>
		<comments>http://www.iwobanas.com/2009/05/implementing-slide-effects-iteration-2/#comments</comments>
		<pubDate>Thu, 28 May 2009 15:36:57 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[effects]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[how-to]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=25</guid>
		<description><![CDATA[
This post is a continuation of Implementing SlideDown effect – iteration 1. It is quite short since extraction of Slide base class and implementation of SlideDown, SlideUp, SlideLeft and SlideRight classes was really straightforward. Most of the code from iteration 1 was used as base classes (Slide and SlideInstance). Concrete effect classes simply declares instanceClass [...]]]></description>
			<content:encoded><![CDATA[<p>
This post is a continuation of <a href="http://www.iwobanas.com/2009/05/implementing-slidedown-effect-%E2%80%93-iteration-1/">Implementing SlideDown effect – iteration 1</a>. It is quite short since extraction of Slide base class and implementation of SlideDown, SlideUp, SlideLeft and SlideRight classes was really straightforward. Most of the code from iteration 1 was used as base classes (Slide and SlideInstance). Concrete effect classes simply declares instanceClass in constructor while concrete effect instance classes overrides onTweenUpdate() method to tween animation in a specific direction.
</p>
<p><span id="more-25"></span></p>
<p>The following example demonstrates all SlideRight, SlideLeft, SlideDown and SlideUp effects.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_02/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="Slide effects sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_02/srcview/SlideEffect02.zip">here</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/slide_effect_02/SlideEffectsExample.html" width="100%" height="350" frameborder="no"></iframe></p>
<p>This implementation has one shortcoming, components are cropped to its width/height so if they have drop shadow or other filters enabled it may not be visible during animation. I will create Slide effect supporting filters in iteration 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/05/implementing-slide-effects-iteration-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing SlideDown effect – iteration 1</title>
		<link>http://www.iwobanas.com/2009/05/implementing-slidedown-effect-%e2%80%93-iteration-1/</link>
		<comments>http://www.iwobanas.com/2009/05/implementing-slidedown-effect-%e2%80%93-iteration-1/#comments</comments>
		<pubDate>Tue, 26 May 2009 17:12:58 +0000</pubDate>
		<dc:creator>Iwo Banas</dc:creator>
				<category><![CDATA[effects]]></category>
		<category><![CDATA[reusable components]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[how-to]]></category>

		<guid isPermaLink="false">http://www.iwobanas.com/?p=9</guid>
		<description><![CDATA[This tutorial describes how to create reusable effect which  can be applied both by calling play() function and by binding it to showEffect/hideEffect MXML attribute.
If you simply want to use slide effect in your application you don’t have to read whole this tutorial. Simply download sources, open included examples and you will surely understand [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial describes how to create reusable effect which  can be applied both by calling play() function and by binding it to showEffect/hideEffect MXML attribute.</p>
<p>If you simply want to use slide effect in your application you don’t have to read whole this tutorial. Simply <a title="SlideDown, SlideUp, SlideLeft, SlideRight sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_03/srcview/SlideEffect03.zip">download sources</a>, open included examples and you will surely understand how to use it.</p>
<p>I have divided this tutorial into three parts (posts):</p>
<ul>
<li> iteration 1 – Simple SlideDown effect (this article)</li>
<li> <a href="http://www.iwobanas.com/2009/05/implementing-slide-effects-iteration-2/">iteration 2 – Extracting Slide base class and implementing slide effect in 4 directions</a></li>
<li> <a href="http://www.iwobanas.com/2009/06/implementing-slide-effects-iteration-3/">iteration 3 &#8211; Adding filter support e.g. DropShadowFilter</a></li>
</ul>
<p><span id="more-9"></span></p>
<h3>Background</h3>
<p>Recently I needed to create a custom dropdown component, something like ComboBox but containing form instead of list inside dropdown. My first idea was to extend ComboBase, unfortunately it is more about handling list than about displaying dropdown so it was of no use in my case. Finally I decided to create my component from scratch. After some playing with PopUpManager I have my component almost ready, the only thing I needed was cool slide effect to animate showing and hiding of the dropdown.</p>
<p>I was pretty sure that there is such effect in Flex 3 framework since ComboBox and ColorPicker is using it. Disappointment again, both ComboBox and ColorPicker have their own implementations embedded into their code (personally I think that such code duplication is a reason of numerous bugs in Flex 3). So again I decided to create my own component from scratch &#8211; Slide effect this time.</p>
<p>I have divided this task into 3 iterations each covered by separate post.</p>
<h3>Iteration 1 – Simple SlideDown effect</h3>
<p>My first thought was to create SlideDown by combining Move effect(downward) with WipeUp but then I realized that WipeUp is not working as expected together with DropShadowFilter which I was using so I have to think about something else.</p>
<p>After some digging in reference documentation I have found DisplayObject.scrollRect property which does exactly what I needed. Although it is intended to support scrolling it is perfect for Slide effect implementation: scrollRect x and y properties can be used to animate the move while width/height can be used to crop component.</p>
<p>Implementation of new effect using TweenEffect as a base class was really straightforward. I will not describe it here in more details since there is nice doc about tween effect at <a title="Flex 3 reference" href="http://livedocs.adobe.com/flex/3/html/help.html?content=createeffects_3.html" target="_blank">http://livedocs.adobe.com/flex/3/html/help.html?content=createeffects_3.html</a></p>
<p>There are two flaws in this document, both refers to effect instance class play() function:</p>
<ul>
<li> Tween object created in this function should be assigned to TweenEffectInstance.tween public property not to local variable.</li>
<li> To avoid flickering at the beginning of effect call to mx_internal::applyTweenStartValues() is needed (I know that using mx_internal functions is not recommended but this function is not harmful at all and probably was marked mx_internal by accident).</li>
</ul>
<p>You can see complete code of my play() function below:</p>
<pre>
override public function play():void {
    super.play();

    // backup scrollRect value
    scrollRect = target.scrollRect;

    width = target.width;
    height = target.height;

    // We are tweenning two values: one from 0 to width, the other from 0 to height
    tween = createTween(this, [0, 0], [width, height], duration);

    // Call to this function is needed to prevent filckering at effect start
    // I have no idea why this function is mx_internal
    mx_internal::applyTweenStartValues();
}
</pre>
<p>I have also implemented additional initEffect() function to enable my effect to automatically detect correct showTarget value when used as “showEffect” “hideEffect”etc.  You can find code of this function below.</p>
<pre>
override public function initEffect(event:Event):void
{
	super.initEffect(event);

	// if showTarget is not explicitly set assign default value dependent on event type
	if (!_showExplicitlySet)
	{
		switch (event.type)
		{
			case FlexEvent.CREATION_COMPLETE:
			case FlexEvent.SHOW:
			case Event.ADDED:
			{
				showTarget = true;
				break;
			}

			case FlexEvent.HIDE:
			case Event.REMOVED:
			{
				showTarget = false;
				break;
			}
		}
	}
}
</pre>
<p>This example demonstrates SlideDown effect compared to WipeDown.<br />
<a title="Sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_01/srcview/index.html" target="_blank">View source</a> is enabled, you can download zipped sources from <a title="SlideDown sources" href="http://www.iwobanas.com/wp-content/uploads/slide_effect_01/srcview/SlideEffect01.zip">here</a>.</p>
<p><iframe src="http://www.iwobanas.com/wp-content/uploads/slide_effect_01/SlideEffectExample.html" width="100%" height="350" frameborder="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwobanas.com/2009/05/implementing-slidedown-effect-%e2%80%93-iteration-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
