<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5179824274561187223</id><updated>2011-07-29T09:33:06.597+02:00</updated><category term='flex'/><category term='complexe arraycollection filtering'/><category term='calllater'/><title type='text'>Flex &amp; more...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://flex-and-more.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5179824274561187223/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://flex-and-more.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Benn</name><uri>http://www.blogger.com/profile/13475641309176982250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5179824274561187223.post-5250020123788930562</id><published>2009-12-11T16:21:00.001+01:00</published><updated>2009-12-14T12:12:21.739+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='calllater'/><category scheme='http://www.blogger.com/atom/ns#' term='complexe arraycollection filtering'/><title type='text'>Flex trick for callLater and complexe ArrayCollection filtering</title><content type='html'>I was looking today a way to use a setter in a callLater function in Flex.&lt;br /&gt;Thanks to Kyle Quevillon @ &lt;a href="http://blog.flexmonkeypatches.com/"&gt;Flex Monkey Patches&lt;/a&gt; I found the way to do this in &lt;a href="http://blog.flexmonkeypatches.com/2007/03/22/using-calllater-on-a-setteryou-cant-do-that-or-can-you/"&gt;this article&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Actually I was already using the inline function trick to do complexe filtering on ArrayCollection.&lt;br /&gt;If you already tried to filter an ArrayCollection from a variable, you already know that it's not possible using filterFunction since the signature of the filtering function does not accept extra parameters.&lt;br /&gt;&lt;br /&gt;Still, you can do it with an inline function the exact same way Kyle Quevillon used it to set a variable via callLater.&lt;br /&gt;Here is an exemple.&lt;br /&gt;&lt;div id='iframeDiv31bb77da-030c-4dc5-8553-dea9d69f1ddd' style='display:none;margin:0px;'&gt;&lt;iframe id='iframe31bb77da-030c-4dc5-8553-dea9d69f1ddd' src='http://www.blogtrog.com/code.aspx?id=31bb77da-030c-4dc5-8553-dea9d69f1ddd' style='width: 400px; height: 150px; border: 1px solid #e0e0e0;margin:0px;' frameborder='0'&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id='noIframeDiv31bb77da-030c-4dc5-8553-dea9d69f1ddd' style='display:block;margin:0px;'&gt;&lt;pre&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; var fooArray:ArrayCollection; &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; filled with some values.&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; function foo(some_value:String):&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt;{&lt;br /&gt;    fooArray.filterFunction &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; function fooFilter(value:Object):Boolean{&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; obj.some_property &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; some_value;&lt;br /&gt;    };&lt;br /&gt;    fooArray.refresh();&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language='javascript' src='http://www.blogtrog.com/scripts/bt_code.js' type='text/javascript'&gt;&lt;/script&gt;&lt;script language='javascript' type='text/javascript'&gt;bt_code_init('31bb77da-030c-4dc5-8553-dea9d69f1ddd');&lt;/script&gt;&lt;br /&gt;You can even do more complexe filtering that way:&lt;br /&gt;&lt;br /&gt;&lt;div id='iframeDivf93e89f0-d2aa-4a9e-ae9a-6c1c3a301b8f' style='display:none;margin:0px;'&gt;&lt;iframe id='iframef93e89f0-d2aa-4a9e-ae9a-6c1c3a301b8f' src='http://www.blogtrog.com/code.aspx?id=f93e89f0-d2aa-4a9e-ae9a-6c1c3a301b8f' style='width: 400px; height: 150px; border: 1px solid #e0e0e0;margin:0px;' frameborder='0'&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id='noIframeDivf93e89f0-d2aa-4a9e-ae9a-6c1c3a301b8f' style='display:block;margin:0px;'&gt;&lt;pre&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; var fooArray:ArrayCollection; &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; filled with some values.&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; function foo(some_value:String,some_field_to_filter_on:String):&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt;{&lt;br /&gt;    fooArray.filterFunction &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; function fooFilter(value:Object):Boolean{&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; obj[some_field_to_filter_on] &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; some_value;&lt;br /&gt;    };&lt;br /&gt;    fooArray.refresh();&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language='javascript' src='http://www.blogtrog.com/scripts/bt_code.js' type='text/javascript'&gt;&lt;/script&gt;&lt;script language='javascript' type='text/javascript'&gt;bt_code_init('f93e89f0-d2aa-4a9e-ae9a-6c1c3a301b8f');&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5179824274561187223-5250020123788930562?l=flex-and-more.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://flex-and-more.blogspot.com/feeds/5250020123788930562/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://flex-and-more.blogspot.com/2009/12/flex-trick-for-calllater-and-complexe.html#comment-form' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5179824274561187223/posts/default/5250020123788930562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5179824274561187223/posts/default/5250020123788930562'/><link rel='alternate' type='text/html' href='http://flex-and-more.blogspot.com/2009/12/flex-trick-for-calllater-and-complexe.html' title='Flex trick for callLater and complexe ArrayCollection filtering'/><author><name>Benn</name><uri>http://www.blogger.com/profile/13475641309176982250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
