<?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'><id>tag:blogger.com,1999:blog-1955739017412408985</id><updated>2010-03-04T09:40:32.463-08:00</updated><title type='text'>Code on my mind</title><subtitle type='html'>This is a collection of various things I've learned along the way. Mostly programming or tech. No one in interested in how much coffee you drink or how much you miss 80's cartoons.</subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default'/><link rel='alternate' type='text/html' href='http://blog.152.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default?start-index=26&amp;max-results=25'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.152.org/atom.xml'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-6607537698264680150</id><published>2010-03-04T09:40:00.001-08:00</published><updated>2010-03-04T09:40:32.516-08:00</updated><title type='text'>This blog has moved</title><content type='html'>&lt;br /&gt;       This blog is now located at __FTP_MIGRATION_NEW_URL__.&lt;br /&gt;       You will be automatically redirected in 30 seconds, or you may click &lt;a href='__FTP_MIGRATION_NEW_URL__'&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;       For feed subscribers, please update your feed subscriptions to&lt;br /&gt;       __FTP_MIGRATION_FEED_URL__.&lt;br /&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-6607537698264680150?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/6607537698264680150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2010/03/this-blog-has-moved.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/6607537698264680150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/6607537698264680150'/><link rel='alternate' type='text/html' href='http://blog.152.org/2010/03/this-blog-has-moved.html' title='This blog has moved'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-5562225195005024631</id><published>2010-03-01T15:11:00.000-08:00</published><updated>2010-03-01T15:58:02.549-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='asynctoken'/><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='asyncresponder'/><category scheme='http://www.blogger.com/atom/ns#' term='httpService'/><category scheme='http://www.blogger.com/atom/ns#' term='addEventListener'/><category scheme='http://www.blogger.com/atom/ns#' term='iresponder'/><category scheme='http://www.blogger.com/atom/ns#' term='as'/><title type='text'>Flash / Flex / ActionScript: Using IResponder instead of EventListeners</title><content type='html'>Using &lt;i&gt;addEventListener&lt;/i&gt; is a popular way of of waiting for a response from a server. I've run into issues using this when a server returns the same response for all methods. Many of the listener methods are tripped for the wrong response. The easy way to avoid this is to use an &lt;b&gt;IResponder&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Here is an example using the HTTPService object. You should be able to use the same steps on a method that returns an AsyncToken.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;var asyncToken:AsyncToken;&lt;br /&gt;var internalIResponder:IResponder;&lt;br /&gt;...&lt;br /&gt;asyncToken = _httpService.send();&lt;br /&gt;internalIResponder = new AsyncResponder(onHTTPServiceSuccess, onHTTPServiceFault, asyncToken);&lt;br /&gt;asyncToken.addResponder(internalIResponder);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When &lt;i&gt;send&lt;/i&gt; is called it will return an AsyncToken. We can attach an IResponder object to the AsyncToken that will handle the success and fail cases for the response.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-5562225195005024631?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/5562225195005024631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2010/03/flash-flex-actionscript-using.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/5562225195005024631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/5562225195005024631'/><link rel='alternate' type='text/html' href='http://blog.152.org/2010/03/flash-flex-actionscript-using.html' title='Flash / Flex / ActionScript: Using IResponder instead of EventListeners'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-1414875197354041059</id><published>2009-12-07T10:32:00.000-08:00</published><updated>2009-12-07T10:32:04.050-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='ifnull'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='1305'/><category scheme='http://www.blogger.com/atom/ns#' term='error'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>MySQL: Error 1305 - Function xxx does not exist</title><content type='html'>I ran into an odd issue on a project I updated awhile ago. I updated an existing sql statement to include &lt;b&gt;IFNULL&lt;/b&gt; for an exclusion check. It worked fine on my dev machine, but caused an issue on the production machine. &lt;br /&gt;&lt;br /&gt;The version of MySQL on my dev machine was a little bit newer than production so the issue never came up. Here is the error the sql server returned: &lt;br /&gt;&lt;b&gt;#1305 - FUNCTION [DATABASE_NAME].ifnull does not exist&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Here is a little bit of the sql that caused the error: &lt;br /&gt;&lt;b&gt;AND IFNULL (  `tbl_category_admin`.`admin_key_id` =5, true )&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The problem was caused by the space between &lt;b&gt;IFNULL&lt;/b&gt; and &lt;b&gt;(&lt;/b&gt;. Changing it to &lt;b&gt;IFNULL(&lt;/b&gt; solved the problem. If you run into an issue where MySQL returns an error saying a given function does not exist look for spaces between the function and the "(".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-1414875197354041059?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/1414875197354041059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/12/mysql-error-1305-function-xxx-does-not.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/1414875197354041059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/1414875197354041059'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/12/mysql-error-1305-function-xxx-does-not.html' title='MySQL: Error 1305 - Function xxx does not exist'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-440650544245936013</id><published>2009-11-30T13:22:00.000-08:00</published><updated>2009-11-30T13:30:55.704-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='class'/><category scheme='http://www.blogger.com/atom/ns#' term='lastResult'/><category scheme='http://www.blogger.com/atom/ns#' term='warning'/><category scheme='http://www.blogger.com/atom/ns#' term='datagrid'/><category scheme='http://www.blogger.com/atom/ns#' term='ieventdispatcher'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='learning'/><category scheme='http://www.blogger.com/atom/ns#' term='error'/><category scheme='http://www.blogger.com/atom/ns#' term='cast'/><category scheme='http://www.blogger.com/atom/ns#' term='casting'/><category scheme='http://www.blogger.com/atom/ns#' term='dataprovider'/><title type='text'>Flex (Learning Flex 3 Book) : Removing IEventDispatcher error from the DataGrid</title><content type='html'>When I decided to learn Flex I started with &lt;a target="_blank" href="http://amzn.com/0596517327"&gt;Learning Flex 3&lt;/a&gt;. It's a great book and does an excellent job of introducing the MXML framework and Flex Builder IDE. I would recommend it to anyone.&lt;br /&gt;&lt;br /&gt;One of the problems I have with the book is it doesn't teach you how to remove warnings from your code. A later code example produces the following error: &lt;b&gt;warning: unable to bind to property 'contact' on class 'XML' (class is not an IEventDispatcher)&lt;/b&gt;. It's not a big deal, but I like to write code that doesn't produce hidden errors. &lt;br /&gt;&lt;br /&gt;Here is the code from the book:&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;mx: Application&lt;br /&gt;    xmlns: mx="http: //www.adobe. com/2006/mxml"&lt;br /&gt;    xmlns: view="com.oreilly.view.*"&lt;br /&gt;    layout="absolute"&lt;br /&gt;    applicationComplete="contactsService.send()" &amp;gt;&lt;br /&gt;    &amp;lt;mx:HTTPService id="contactsService"&lt;br /&gt;        resultFormat="e4x"&lt;br /&gt;        url="contacts.xml" /&amp;gt;&lt;br /&gt;    &amp;lt;mx:DataGrid id="contactsDataGrid"&lt;br /&gt;        dataProvider="{contactsService.lastResult.contact}"&lt;br /&gt;        selectedIndex="0"&lt;br /&gt;        left="10"&lt;br /&gt;        top="10"&lt;br /&gt;        bottom="10"&lt;br /&gt;        width="300"&amp;gt;&lt;br /&gt;        &amp;lt;mx: columns&amp;gt;&lt;br /&gt;            &amp;lt;mx: DataGridColumn headerText="First"  &lt;br /&gt;            dataField="firstName"/&amp;gt;&lt;br /&gt;            &amp;lt;mx: DataGridColumn headerText="Last" dataField="lastName"/&amp;gt;&lt;br /&gt;        &amp;lt;/mx:columns&amp;gt;&lt;br /&gt;    &amp;lt;/mx:DataGrid&amp;gt;&lt;br /&gt;    &amp;lt;view: ContactViewer&lt;br /&gt;        contact="{contactsDataGrid. selectedItem}"&lt;br /&gt;        x="318" y="10"&amp;gt;&lt;br /&gt;    &amp;lt;/view: ContactViewer&amp;gt;&lt;br /&gt;&amp;lt;/mx: Application&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The problem is the &lt;b&gt;dataProvider&lt;/b&gt; property of DataGrid. It's unable to figure out how to parse the data, so it throws a warning. This can be resolved with casting. We can tell the dataProvider what it should be and it will remove the warning. Here is the code that will remove the warning.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;dataProvider="{XMLList(XML(contactsService.lastResult).contact)}"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;contactsService.lastResult is an XML object. There are multiple children in the object. We can then cast the XML object as an &lt;b&gt;XMLList&lt;/b&gt; to use contact child node.&lt;br /&gt;&lt;br /&gt;Feel free to leave a comment if you have any questions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-440650544245936013?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/440650544245936013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/11/flex-removing-ieventdispatcher-error.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/440650544245936013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/440650544245936013'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/11/flex-removing-ieventdispatcher-error.html' title='Flex (Learning Flex 3 Book) : Removing IEventDispatcher error from the DataGrid'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-2780059074798889710</id><published>2009-11-18T16:12:00.000-08:00</published><updated>2009-11-18T16:50:04.539-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data'/><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='redraw'/><category scheme='http://www.blogger.com/atom/ns#' term='duplicate'/><category scheme='http://www.blogger.com/atom/ns#' term='repeat'/><category scheme='http://www.blogger.com/atom/ns#' term='init'/><category scheme='http://www.blogger.com/atom/ns#' term='switch'/><category scheme='http://www.blogger.com/atom/ns#' term='dataprovider'/><category scheme='http://www.blogger.com/atom/ns#' term='itemrenderer'/><category scheme='http://www.blogger.com/atom/ns#' term='random'/><category scheme='http://www.blogger.com/atom/ns#' term='creationComplete'/><category scheme='http://www.blogger.com/atom/ns#' term='tilelist'/><category scheme='http://www.blogger.com/atom/ns#' term='override'/><category scheme='http://www.blogger.com/atom/ns#' term='refresh'/><title type='text'>Flex: TileList cell switching/redraw problem using an itemRenderer</title><content type='html'>While working with the &lt;b&gt;TileList &lt;/b&gt;component I ran into a very odd issue. Images would move around while scrolling up and down. Also when I updated the dataProvider the TileList didn't display the new information. &lt;a href="http://blog.152.org/flex_examples/tilelist_bad/" target="_blank"&gt;Here is an example&lt;/a&gt;&amp;nbsp;so you can see what is going on. You can view the source the source by right-clicking and selecting "View Source".&lt;br /&gt;&lt;br /&gt;After a lot of research, and a post on &lt;a href="http://stackoverflow.com/questions/1627396/flex-image-switching-place-in-tilelist" target="_blank"&gt;StackOverflow&lt;/a&gt;, I figured out what was going on. My broken example relies on a MXML completion method (init, creationComplete, etc..) &amp;nbsp;to set the source of the image in the itemRenderer.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;index.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;mx:Component&amp;gt;&lt;br /&gt;    &amp;lt;itemRenderers:ImageTile_bad /&amp;gt;&lt;br /&gt;&amp;lt;/mx:Component&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;ImageTile_bad.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Image xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;        &amp;lt;![CDATA[&lt;br /&gt;            /**&lt;br /&gt;            * This is an example of how not to use an item render in a TileList  &lt;br /&gt;            * */&lt;br /&gt;            private function init() : void {&lt;br /&gt;                this.source = data;&lt;br /&gt;                this.name = data.toString().split("/").pop().split(".").shift();&lt;br /&gt;            }&lt;br /&gt;        ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Image&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;TileList reuses cells inside the component. I'm not sure why, but can't keep track of where things should render and starts switching images around. I tried overridding the &lt;b&gt;data &lt;/b&gt;method and it works, but I wanted to find a solution that doesn't require overriding a private method.&lt;br /&gt;&lt;br /&gt;The answer is to use a setter inside the itemRenderer to assign the value to the component. Here is a snip-it of code to show you what I mean.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;index.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;mx:Component&amp;gt;&lt;br /&gt;    &amp;lt;itemRenderers:ImageTile img="{data}"/&amp;gt;&lt;br /&gt;&amp;lt;/mx:Component&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;ImageTile.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;        &amp;lt;![CDATA[&lt;br /&gt;            /**&lt;br /&gt;            * This is an example of how to use an itemRenderer in a TileList&lt;br /&gt;            * Create a setter that will always update the when the TileList redraws&lt;br /&gt;            * */&lt;br /&gt;            public function set img(value:String) : void {&lt;br /&gt;                //make sure there is something to work with. avoid error# 1010&lt;br /&gt;                if(!value) {&lt;br /&gt;                    return;&lt;br /&gt;                }&lt;br /&gt;                this.source = value;&lt;br /&gt;                this.name = value.toString().split("/").pop().split(".").shift();&lt;br /&gt;            }&lt;br /&gt;        ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Image&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When &lt;b&gt;TileList &lt;/b&gt;redraws the cell it will pass &lt;b&gt;data &lt;/b&gt;into the img setter. This will make sure that the cell receives the correct information when it redraws. Also switching the dataProvider on the TileList works properly now. &lt;a href="http://blog.152.org/flex_examples/tilelist_good/" target="_blank"&gt;Here is a link to the working example&lt;/a&gt; that has available source code. Feel free to contact me if you have any questions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-2780059074798889710?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/2780059074798889710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/11/flex-tilelist-cell-switching-problem.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/2780059074798889710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/2780059074798889710'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/11/flex-tilelist-cell-switching-problem.html' title='Flex: TileList cell switching/redraw problem using an itemRenderer'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-939315649941304408</id><published>2009-11-12T17:29:00.000-08:00</published><updated>2010-01-10T13:57:14.448-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='event'/><category scheme='http://www.blogger.com/atom/ns#' term='capture'/><category scheme='http://www.blogger.com/atom/ns#' term='targeting'/><category scheme='http://www.blogger.com/atom/ns#' term='display'/><category scheme='http://www.blogger.com/atom/ns#' term='events'/><category scheme='http://www.blogger.com/atom/ns#' term='bubbling'/><category scheme='http://www.blogger.com/atom/ns#' term='displayobjectcontainer'/><category scheme='http://www.blogger.com/atom/ns#' term='eventlistener'/><category scheme='http://www.blogger.com/atom/ns#' term='eventdispatcher'/><category scheme='http://www.blogger.com/atom/ns#' term='3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='eventbubbling'/><category scheme='http://www.blogger.com/atom/ns#' term='sprite'/><category scheme='http://www.blogger.com/atom/ns#' term='listener'/><category scheme='http://www.blogger.com/atom/ns#' term='flash'/><category scheme='http://www.blogger.com/atom/ns#' term='as'/><title type='text'>Flash / ActionScript 3: Event Bubbling Example</title><content type='html'>Previously I wrote an article that showed an example of &lt;a href="http://blog.152.org/2009/11/flex-event-bubbling-example.html"&gt;Event Bubbling with Flex&lt;/a&gt;. I wanted to write a similar example for ActionScript 3. The principle is the same, but it works just a little different.&lt;br /&gt;&lt;br /&gt;Any class involved in bubbling must extend &lt;b&gt;DisplayObjectContainer&lt;/b&gt;. &lt;b&gt;&lt;a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html" target="_blank"&gt;Sprite&lt;/a&gt;&lt;/b&gt;&lt;a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html"&gt;&amp;nbsp;&lt;/a&gt;is the most basic DisplayObjectContainer class and most examples I see use it, so that's what I will use. I gave a brief overview of how event bubbling works in the Flex example that I won't repeat here. &lt;br /&gt;&lt;br /&gt;I'm creating three classes that include each other. The primary class includes Level1. Level1 includes Level2. Level2 includes Level3. Level3 triggers an event when it's added to the stage. The event from Level3 will bubble through Level2 and Level1 to the primary class without re-dispatching it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;event_bubbling_as.as&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package {&lt;br /&gt;    import flash.display.Sprite;&lt;br /&gt;    import flash.events.Event;&lt;br /&gt;    &lt;br /&gt;    import obj.Level1;&lt;br /&gt;    import obj.Level3;&lt;br /&gt;&lt;br /&gt;    public class event_bubbling_as extends Sprite&lt;br /&gt;    {&lt;br /&gt;        private var _level1:Level1&lt;br /&gt;        &lt;br /&gt;        public function event_bubbling_as()&lt;br /&gt;        {&lt;br /&gt;            _level1 = new Level1;&lt;br /&gt;            _level1.addEventListener(Level3.EVENT, onEvent);&lt;br /&gt;            &lt;br /&gt;            addChild(_level1);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        private function onEvent(event:Event) : void {&lt;br /&gt;                trace('caught event from level 3');&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Level1.as&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package obj&lt;br /&gt;{&lt;br /&gt;    import flash.display.Sprite;&lt;br /&gt;    &lt;br /&gt;    public class Level1 extends Sprite&lt;br /&gt;    {&lt;br /&gt;        private var _level2:Level2;&lt;br /&gt;        &lt;br /&gt;        public function Level1()&lt;br /&gt;        {&lt;br /&gt;            trace("in level 1");&lt;br /&gt;            _level2 = new Level2;&lt;br /&gt;            &lt;br /&gt;            addChild(_level2);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Level2.as&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package obj&lt;br /&gt;{&lt;br /&gt;    import flash.display.Sprite;&lt;br /&gt;    &lt;br /&gt;    public class Level2 extends Sprite&lt;br /&gt;    {&lt;br /&gt;        private var _level3:Level3;&lt;br /&gt;        &lt;br /&gt;        public function Level2()&lt;br /&gt;        {&lt;br /&gt;            trace("in level 2");&lt;br /&gt;            _level3 = new Level3;&lt;br /&gt;            &lt;br /&gt;            addChild(_level3);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Level3.as&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package obj&lt;br /&gt;{&lt;br /&gt;    import flash.display.Sprite;&lt;br /&gt;    import flash.events.Event;&lt;br /&gt;    &lt;br /&gt;    public class Level3 extends Sprite&lt;br /&gt;    {&lt;br /&gt;        public static const EVENT:String = "level3";&lt;br /&gt;        public function Level3(){&lt;br /&gt;            trace("in level 3");&lt;br /&gt;            &lt;br /&gt;            //trigger event when the object is added to the stage&lt;br /&gt;            addEventListener(Event.ADDED_TO_STAGE, launchEvent);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public function launchEvent(event:Event) : void {&lt;br /&gt;         var newEvent:Event = new Event(EVENT, true, true);&lt;br /&gt;         dispatchEvent(newEvent);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;You can download the Flex Project Archive example &lt;a href="http://blog.152.org/flex_examples/event_bubbling_as.zip"&gt;here&lt;/a&gt;. This can be directly imported into Flex. Run it in debug mode to see how each level is triggered.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-939315649941304408?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/939315649941304408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/11/flash-actionscript-3-event-bubbling.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/939315649941304408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/939315649941304408'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/11/flash-actionscript-3-event-bubbling.html' title='Flash / ActionScript 3: Event Bubbling Example'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-3016364678072691065</id><published>2009-11-01T23:23:00.000-08:00</published><updated>2009-11-13T11:06:23.657-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='event'/><category scheme='http://www.blogger.com/atom/ns#' term='object'/><category scheme='http://www.blogger.com/atom/ns#' term='mxml'/><category scheme='http://www.blogger.com/atom/ns#' term='capture'/><category scheme='http://www.blogger.com/atom/ns#' term='targeting'/><category scheme='http://www.blogger.com/atom/ns#' term='display'/><category scheme='http://www.blogger.com/atom/ns#' term='eventbubbling'/><category scheme='http://www.blogger.com/atom/ns#' term='events'/><category scheme='http://www.blogger.com/atom/ns#' term='bubbling'/><category scheme='http://www.blogger.com/atom/ns#' term='listener'/><category scheme='http://www.blogger.com/atom/ns#' term='displayobject'/><title type='text'>Flex: Event Bubbling Example</title><content type='html'>A refactor it gave me a chance to update the way I handled events. &lt;a href="http://livedocs.adobe.com/flex/3/html/help.html?content=events%5F08.html" target="_blank"&gt;This page&lt;/a&gt; on Adobe's site explains the event bubbling model.&amp;nbsp;To give a brief overview there are three phases: &lt;b&gt;Capture&lt;/b&gt;, &lt;b&gt;Targeting&lt;/b&gt; and &lt;b&gt;Bubbling&lt;/b&gt;. The &lt;b&gt;Capture&lt;/b&gt; phase will pass through each branch of a &lt;b&gt;&lt;a href="http://draft.blogger.com/goog_1257180277021" target="_blank"&gt;DisplayObject&lt;/a&gt;&lt;/b&gt;&lt;a href="http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html"&gt; &lt;/a&gt;tree until it reaches the last node. The &lt;b&gt;Targeting&lt;/b&gt; phase will look for objects that have event listeners bound to them. The &lt;b&gt;Bubbling&lt;/b&gt; phase ascends the &lt;b&gt;DisplayObject&lt;/b&gt; tree from the last node to the first node and activates the event listeners. Only &lt;b&gt;DisplayObjects&lt;/b&gt; have a &lt;b&gt;Capture&lt;/b&gt; and &lt;b&gt;Bubbling&lt;/b&gt; phase.&lt;br /&gt;&lt;br /&gt;Here is some example code I made in MXML that shows how event bubbling works.&amp;nbsp;There are four files. The Application file includes Layer1. Layer1 includes Layer2. Layer2 includes Layer3. When Layer3 is created it will throw an event. The first property of the event is the string that will trigger event listeners, the second allows the event to bubble through the &lt;b&gt;DisplayObject&lt;/b&gt; tree. The third allows the event to be canceled at any of the DisplayObjects it passes through. &amp;nbsp;The event will bubble through each &lt;b&gt;DisplayObject&lt;/b&gt; and back to the Application without manually passing it forward.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UPDATE&lt;/b&gt;&lt;br /&gt;If you're looking for an example of event bubbling in ActionScript please &lt;a href="http://blog.152.org/2009/11/flash-actionscript-3-event-bubbling.html"&gt;view this article&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;index.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" styleName="plain"&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;        &amp;lt;![CDATA[&lt;br /&gt;            import obj.Level3;&lt;br /&gt;            import obj.Level1;&lt;br /&gt;            &lt;br /&gt;            private var _level1:Level1;&lt;br /&gt;            &lt;br /&gt;            private function init() : void {&lt;br /&gt;                trace("in the base");&lt;br /&gt;                _level1 = new Level1;&lt;br /&gt;                &lt;br /&gt;                //add eventListener&lt;br /&gt;                _level1.addEventListener(Level3.EVENT,onEvent);&lt;br /&gt;                &lt;br /&gt;                addChild(_level1);&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            private function onEvent(event:Event) : void {&lt;br /&gt;                trace("picked up event from Level3 ");&lt;br /&gt;            }&lt;br /&gt;        ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Application&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Layer1.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()"&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;        &amp;lt;![CDATA[&lt;br /&gt;            private var _level2:Level2;&lt;br /&gt;            private function init() : void {&lt;br /&gt;                trace("in level 1");&lt;br /&gt;                _level2 = new Level2;&lt;br /&gt;                addChild(_level2);&lt;br /&gt;            }&lt;br /&gt;        ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Canvas&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Layer2.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()"&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;        &amp;lt;![CDATA[&lt;br /&gt;            private var _level3:Level3;&lt;br /&gt;            private function init() : void {&lt;br /&gt;                trace("in level 2");&lt;br /&gt;                _level3 = new Level3;&lt;br /&gt;                addChild(_level3);&lt;br /&gt;            }&lt;br /&gt;        ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Canvas&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Layer3.mxml&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" initialize="init()"&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;        &amp;lt;![CDATA[&lt;br /&gt;            public static const EVENT:String = "level3";&lt;br /&gt;            private function init(): void {&lt;br /&gt;                trace("in level 3");&lt;br /&gt;                var event:Event = new Event(EVENT,true,true);&lt;br /&gt;                dispatchEvent(event);&lt;br /&gt;            }&lt;br /&gt;        ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Canvas&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can download the Flex Project Archive example &lt;a href="http://blog.152.org/flex_examples/event_bubbling_mxml.zip" target="_blank"&gt;here&lt;/a&gt;. This can be directly imported into Flex. Run it in debug mode to see how each level is triggered.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-3016364678072691065?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/3016364678072691065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/11/flex-event-bubbling-example.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/3016364678072691065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/3016364678072691065'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/11/flex-event-bubbling-example.html' title='Flex: Event Bubbling Example'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-8170627959031961477</id><published>2009-10-29T14:41:00.000-07:00</published><updated>2010-01-28T11:38:39.698-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='event'/><category scheme='http://www.blogger.com/atom/ns#' term='httpService'/><category scheme='http://www.blogger.com/atom/ns#' term='mxml'/><category scheme='http://www.blogger.com/atom/ns#' term='faultevent'/><category scheme='http://www.blogger.com/atom/ns#' term='addEventListener'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='listener'/><category scheme='http://www.blogger.com/atom/ns#' term='removeEventListener'/><category scheme='http://www.blogger.com/atom/ns#' term='eventlistener'/><title type='text'>Flex: Problems reusing the HTTPService class</title><content type='html'>&lt;b&gt;UPDATE&lt;/b&gt;: This problem occurred because of a bug in the &lt;b&gt;3.4&lt;/b&gt; SDK. This bug does not exist in &lt;b&gt;3.2&lt;/b&gt; or lower. I've opened a &lt;a target="_blank" href="https://bugs.adobe.com/jira/browse/SDK-24847"&gt;bug &lt;/a&gt;with adobe on the issue.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UPDATE 2&lt;/b&gt;: The issue has been resolved in a new nightly build of the SDK. It should be fixed when 3.6 is release.&lt;br /&gt;&lt;br /&gt;I ran into an issue using the &lt;b&gt;HTTPService&lt;/b&gt; object that involved removing event listeners that were added inside MXML.&lt;br /&gt;&lt;br /&gt;Here is a snippet of code in the project.&amp;nbsp;This will open an xml file and load some data into a&amp;nbsp;&lt;b&gt;List&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;//this will fetch all our content.&lt;br /&gt;private var _httpService:HTTPService = new HTTPService; &lt;br /&gt;&lt;br /&gt;private function init() : void {&lt;br /&gt;    _httpService.url = "stub/data/albums.xml";&lt;br /&gt;    _httpService.resultFormat = "e4x";&lt;br /&gt;    &lt;br /&gt;    //set up http call&lt;br /&gt;    _httpService.addEventListener(ResultEvent.RESULT, populateList);&lt;br /&gt;    _httpService.send();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private function populateList(event:ResultEvent) : void {&lt;br /&gt;    //set the data provider&lt;br /&gt;    albumsComboBox.dataProvider = event.result.album;&lt;br /&gt;    &lt;br /&gt;    //remove listener&lt;br /&gt;    _httpService.removeEventListener(ResultEvent.RESULT, populateList);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This will open another xml file and populate the &lt;b&gt;TileList &lt;/b&gt;with images.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;private function loadAlbum(event:ListEvent) : void {&lt;br /&gt;    _httpService.url = "stub/data/" + event.currentTarget.selectedItem.@images;&lt;br /&gt;    _httpService.resultFormat = "e4x";&lt;br /&gt;    &lt;br /&gt;    //set up http call&lt;br /&gt;    _httpService.addEventListener(ResultEvent.RESULT, populateTilelist);&lt;br /&gt;    _httpService.send();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private function populateTilelist(event:ResultEvent) : void {&lt;br /&gt;    //set the data provider&lt;br /&gt;    imageGrid.dataProvider = event.result.photo;&lt;br /&gt;    &lt;br /&gt;    //remove listener&lt;br /&gt;    _httpService.removeEventListener(ResultEvent.RESULT, populateTilelist);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When &lt;b&gt;loadAlbum &lt;/b&gt;calls &lt;b&gt;send()&lt;/b&gt; it will call &lt;b&gt;populateList &lt;/b&gt;first and then goto &lt;b&gt;populateTilelist&lt;/b&gt;. &lt;b&gt;removeEventListener&lt;/b&gt; didn't work. I posted a question to &lt;a href="http://stackoverflow.com/questions/1609562/problems-re-using-httpservice-object" target="_blank"&gt;StackOverflow&lt;/a&gt; with the problem and got some great answers. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To get around this problem I created a &lt;b&gt;HTTPService&lt;/b&gt; wrapper that can be reused with no issues because it's an ActionScript Class. It's very light weight, doesn't include everything under the sun, but it gets the job done in a pinch. This is the 3rd revision of the class. It's been cleaned up and there are fewer methods now.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package util&lt;br /&gt;{&lt;br /&gt;    import mx.controls.Alert;&lt;br /&gt;    import mx.rpc.AsyncResponder;&lt;br /&gt;    import mx.rpc.AsyncToken;&lt;br /&gt;    import mx.rpc.IResponder;&lt;br /&gt;    import mx.rpc.events.FaultEvent;&lt;br /&gt;    import mx.rpc.events.ResultEvent;&lt;br /&gt;    import mx.rpc.http.HTTPService;&lt;br /&gt;    &lt;br /&gt;    public class HTTPServiceWrapper {&lt;br /&gt;        //reference for connections&lt;br /&gt;        private var _httpService:HTTPService;&lt;br /&gt;        &lt;br /&gt;        private var _alertTitle:String = "HTTPService: An error occured";&lt;br /&gt;        &lt;br /&gt;        // Holds all the tokens and callbacks&lt;br /&gt;        private var _processingQueue : Object = {};&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * Create the HTTPService &lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        public function HTTPServiceWrapper() : void {&lt;br /&gt;            //create the service&lt;br /&gt;            _httpService = new HTTPService;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * Get content from URL &lt;br /&gt;         * @param url&lt;br /&gt;         * @param resultFormat&lt;br /&gt;         * @param callBack&lt;br /&gt;         * @param request&lt;br /&gt;         * @param returnErrorEvent&lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        public function getContent(url:String,&lt;br /&gt;                                    resultFormat:String,&lt;br /&gt;                                    callBack:Function,&lt;br /&gt;                                    request:Object = null, &lt;br /&gt;                                    returnErrorEvent:Boolean = false) : void {&lt;br /&gt;            var asyncToken:AsyncToken;&lt;br /&gt;            var internalIResponder:IResponder;&lt;br /&gt;            &lt;br /&gt;            //set the url and result format&lt;br /&gt;            _httpService.url = url;&lt;br /&gt;            _httpService.resultFormat = resultFormat;&lt;br /&gt;            &lt;br /&gt;            //check for key/value pairs to be sent in the url&lt;br /&gt;            if(request) {&lt;br /&gt;                _httpService.request = request;&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            //send the request&lt;br /&gt;            asyncToken = _httpService.send();&lt;br /&gt;            internalIResponder = new AsyncResponder(onGetContentHandler,onFault, asyncToken);&lt;br /&gt;            asyncToken.addResponder(internalIResponder);&lt;br /&gt;            &lt;br /&gt;            //give token unique ID&lt;br /&gt;            asyncToken = tokenID(asyncToken);&lt;br /&gt;            &lt;br /&gt;            _processingQueue[asyncToken.ID] = new QueueObject(callBack,returnErrorEvent);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * This is the handler event for getContent. The callBack should accept a ResultEvent&lt;br /&gt;         *  &lt;br /&gt;         * @param event&lt;br /&gt;         * @param token&lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        private function onGetContentHandler(event:ResultEvent, token:AsyncToken) : void {&lt;br /&gt;            var queueObject:QueueObject = _processingQueue[token.ID];&lt;br /&gt;            &lt;br /&gt;            queueObject.callBack(event);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * This is the fault event for the class. The callBack should accept a null ArrayCollection and a FaultEvent if&lt;br /&gt;         * you want to handle the error.&lt;br /&gt;         *  &lt;br /&gt;         * @param event&lt;br /&gt;         * @param token&lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        private function onFault(event:FaultEvent, token:AsyncToken) : void {&lt;br /&gt;            var queueObject:QueueObject = _processingQueue[token.ID];&lt;br /&gt;            &lt;br /&gt;            //handle the fault&lt;br /&gt;            if(queueObject.returnErrorEvent){&lt;br /&gt;                queueObject.callBack(null, event);&lt;br /&gt;            }&lt;br /&gt;            else {&lt;br /&gt;                var displayMessage:String = event.fault.faultString;&lt;br /&gt;                displayError(displayMessage);&lt;br /&gt;                queueObject.callBack(null);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * This will add a unique identifier to a token &lt;br /&gt;         * @param token&lt;br /&gt;         * @return &lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        private function tokenID(token : AsyncToken) : AsyncToken {&lt;br /&gt;            token.ID = Math.random();&lt;br /&gt;            return token;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * Displays the error on a fault event in the content service &lt;br /&gt;         * @param event&lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        private function displayError(displayMessage : String) : void {&lt;br /&gt;            Alert.show(displayMessage, _alertTitle, Alert.OK);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class QueueObject{&lt;br /&gt;    public var callBack:Function;&lt;br /&gt;    public var returnErrorEvent:Boolean;&lt;br /&gt;    &lt;br /&gt;    public function QueueObject(callBack:Function, returnErrorEvent:Boolean){&lt;br /&gt;        this.callBack = callBack;&lt;br /&gt;        this.returnErrorEvent = returnErrorEvent;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Using the class is really simple. Use &lt;b&gt;getContent &lt;/b&gt;and pass it the file you want to load, the format it should be loaded in and the call back you want it to call after the file is retrieved. There are two extra properties I'm not using right now, but they will be helpful in the future. The fourth parameter accepts an &lt;b&gt;Object &lt;/b&gt;of key/value pairs to be sent with the URL.The fifth parameter lets you capture the result of an error if one occurs. The call back should accept a &lt;b&gt;FaultEvent &lt;/b&gt;object if you want to capture the error. If you let HTTPServiceWrapper handle the error an &lt;b&gt;Alert&lt;/b&gt;&amp;nbsp;window will pop up showing the error.&lt;br /&gt;&lt;pre class="brush: as3"&gt;//http wrapper&lt;br /&gt;private var _httpServiceWrapper:HTTPServiceWrapper = new HTTPServiceWrapper;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Runs when the application loads&lt;br /&gt;* */&lt;br /&gt;private function init() : void {&lt;br /&gt;    //get the list of albums&lt;br /&gt;    _httpServiceWrapper.getContent("stub/data/albums.xml", "e4x", populateList);&lt;br /&gt;    &lt;br /&gt;    //set event listeners for app&lt;br /&gt;    albumsComboBox.addEventListener(ListEvent.CHANGE, loadAlbum);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* This will populate the album list&lt;br /&gt;* */&lt;br /&gt;private function populateList(event:ResultEvent) : void {&lt;br /&gt; //if the result is null don't set it&lt;br /&gt; if(!event) {&lt;br /&gt;  return;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //set the data provider&lt;br /&gt; albumsComboBox.dataProvider = event.result.album;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* This will fetch the selected album&lt;br /&gt;* */&lt;br /&gt;private function loadAlbum(event:ListEvent) : void {&lt;br /&gt;    _httpServiceWrapper.getContent("stub/data/" + event.currentTarget.selectedItem.@images, "e4x", populateTilelist);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This cut quite a bit of bloat out of my app and is also very reusable which saves time in the long run. The final version of this code is hosted &lt;a href="http://blog.152.org/flex_examples/tilelist_good/" target="_blank"&gt;here&lt;/a&gt;. You can view source on it by right-clicking in the app and selecting "View Source". Please let me know if you have any questions about it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-8170627959031961477?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/8170627959031961477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/flex-problems-reusing-httpservice.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8170627959031961477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8170627959031961477'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/flex-problems-reusing-httpservice.html' title='Flex: Problems reusing the HTTPService class'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-116068352085910690</id><published>2009-10-29T12:14:00.000-07:00</published><updated>2009-11-05T09:50:17.506-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='application'/><category scheme='http://www.blogger.com/atom/ns#' term='images'/><category scheme='http://www.blogger.com/atom/ns#' term='color'/><category scheme='http://www.blogger.com/atom/ns#' term='error'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='project'/><category scheme='http://www.blogger.com/atom/ns#' term='2140'/><category scheme='http://www.blogger.com/atom/ns#' term='httpService'/><category scheme='http://www.blogger.com/atom/ns#' term='command'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='preferences'/><category scheme='http://www.blogger.com/atom/ns#' term='1069'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><category scheme='http://www.blogger.com/atom/ns#' term='stylename'/><title type='text'>Flex: New Project Settings</title><content type='html'>When starting a new Flex project there are a few settings I like to use by default.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Changes to Flex Compiler&lt;/b&gt;&lt;br /&gt;Flex Compiler options for a project can be found by right-clicking the project and selecting &lt;b&gt;properties&lt;/b&gt;. Select &lt;b&gt;Flex Compiler&lt;/b&gt;&amp;nbsp;from the menu on the left. The following properties should be added to the&amp;nbsp;&lt;b&gt;Additional compiler arguments&lt;/b&gt;&amp;nbsp;field.&lt;br /&gt;&lt;br /&gt;When you're reading local xml files or image you might run into a sandbox security Error# 2140 or ReferenceError Error# 1069 using the HTTPService object. Use this switch to stop the error.&lt;br /&gt;&lt;i&gt;-use-network=false&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;The loading background color of a Flex app can be changed. Use this switch to change the property.&lt;br /&gt;&lt;i&gt;-default-background-color &lt;b&gt;[HTML COLOR VALUE]&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;I typically use #FFFFFF.&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;b&gt;Changes to the Application&lt;/b&gt;&lt;br /&gt;I like to use a simple background for Flex apps. Add this property to the mx:Application to make the background white.&lt;br /&gt;&lt;i&gt;styleName="plain"&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-116068352085910690?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/116068352085910690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/flex-new-project-settings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/116068352085910690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/116068352085910690'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/flex-new-project-settings.html' title='Flex: New Project Settings'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-323284073738828644</id><published>2009-10-23T10:10:00.000-07:00</published><updated>2009-10-23T10:12:03.249-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='motorloa'/><category scheme='http://www.blogger.com/atom/ns#' term='droid'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Android: Motorola Droid</title><content type='html'>This phone has caught my eye. I've had an iPhone since launch but have become a bit&amp;nbsp;frustrated&amp;nbsp;with it. It's a beautiful phone, but a bit of a walled garden. Android has always been interesting to me, but now it seems to be catching up with the iPhone.&lt;br /&gt;&lt;br /&gt;I've started a wish list of things I hope the Droid will do. I'm updating it with links to articles that verify the features as time goes along.&lt;br /&gt;&lt;br /&gt;&lt;a target="_blank" href="http://spreadsheets.google.com/pub?key=tlQ3UVqx9gnphVI6h1aKTig&amp;amp;output=html"&gt;http://spreadsheets.google.com/pub?key=tlQ3UVqx9gnphVI6h1aKTig&amp;amp;output=html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-323284073738828644?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/323284073738828644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/android-motorola-droid.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/323284073738828644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/323284073738828644'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/android-motorola-droid.html' title='Android: Motorola Droid'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-5302716504222438288</id><published>2009-10-13T15:18:00.000-07:00</published><updated>2009-12-17T13:46:11.920-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='loadvars'/><category scheme='http://www.blogger.com/atom/ns#' term='cookie'/><category scheme='http://www.blogger.com/atom/ns#' term='urlvariables'/><category scheme='http://www.blogger.com/atom/ns#' term='cookies'/><category scheme='http://www.blogger.com/atom/ns#' term='3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='as'/><category scheme='http://www.blogger.com/atom/ns#' term='externalinterface'/><category scheme='http://www.blogger.com/atom/ns#' term='browser'/><title type='text'>Flash / ActionScript 3 / Flex : Reading browser cookies</title><content type='html'>Part of an ActionScript 3 project I was working on required me to pull cookies from the users browser into Flash. I tried hunting around google to find a good method to&amp;nbsp;achieve this, but found a lot of articles that wanted you to alter the embed code for flash. I wanted to find a way inside Flash to read the users cookies.&lt;br /&gt;&lt;br /&gt;I wrote some code to do something similar in ActionScript 2 that used &lt;b&gt;LoadVars&lt;/b&gt;. This class has been removed in ActionScript 3.&lt;br /&gt;&lt;br /&gt;This is the ActionScript 3 code I came up with. It uses &lt;b&gt;ExternalInterface&lt;/b&gt; to execute a bit of javascript that will pull the cookies directly into flash. It alters the cookie string to make it look like a URL and runs it through &lt;b&gt;URLVariables&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package {&lt;br /&gt;    import flash.display.Sprite;&lt;br /&gt;    import flash.external.ExternalInterface;&lt;br /&gt;    import flash.net.URLVariables;&lt;br /&gt;    &lt;br /&gt;    public class BrowserCookies extends Sprite&lt;br /&gt;    {&lt;br /&gt;        //this will parse the cookie data&lt;br /&gt;        private var _urlVariables:URLVariables;&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * Return all the cookie values in one object&lt;br /&gt;         * @return URLVariables &lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        public function get urlVariables() : URLVariables {&lt;br /&gt;            return _urlVariables;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * Return one cookie value&lt;br /&gt;         * @param value String&lt;br /&gt;         * @return String&lt;br /&gt;         * &lt;br /&gt;         */&lt;br /&gt;        public function getCookieValue(value:String) : String {&lt;br /&gt;            var returnValue:String = "";&lt;br /&gt;            &lt;br /&gt;            if(_urlVariables &amp;&amp; _urlVariables[value]) {&lt;br /&gt;                returnValue = _urlVariables[value];&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            return returnValue;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        /**&lt;br /&gt;         * This will connect to the browser and pull cookies into flash &lt;br /&gt;         */&lt;br /&gt;        public function BrowserCookies() : void{&lt;br /&gt;            //this will hold the data returned from javascript&lt;br /&gt;            var browserCookieString:String;&lt;br /&gt;            &lt;br /&gt;            //pull the data from javascript&lt;br /&gt;            browserCookieString = ExternalInterface.call("function(){return document.cookie}");&lt;br /&gt;            &lt;br /&gt;            //replace ; with &amp; to make it look like a url&lt;br /&gt;            browserCookieString = browserCookieString.replace(/;\s/g, "&amp;");&lt;br /&gt;&lt;br /&gt;            //parse the cookie string into variables. you can now access cookie variables as properties of this object&lt;br /&gt;            if(browserCookieString) {&lt;br /&gt;                _urlVariables = new URLVariables(browserCookieString);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now you can access any cookie property inside flash. Here is a quick example of how to use the class. Assume BrowserCookies.as exists in the same folder as the example class.&lt;br /&gt;&lt;pre class="brush: as3"&gt;package&lt;br /&gt;{&lt;br /&gt;    import flash.display.Sprite;&lt;br /&gt;    import flash.text.TextField;&lt;br /&gt;    &lt;br /&gt;    public class Index extends Sprite{&lt;br /&gt;        public function Index(){&lt;br /&gt;            //this will pull all the cookies out of the browser&lt;br /&gt;            var urlVars:BrowserCookies = new BrowserCookies;&lt;br /&gt;            var textField:TextField = new TextField;&lt;br /&gt;            &lt;br /&gt;            textField.width = 200;&lt;br /&gt;            textField.height = 200;&lt;br /&gt;            textField.text = urlVars.getCookieValue("today");&lt;br /&gt;            &lt;br /&gt;            addChild(textField);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I've uploaded a Flex Projext Export version of this example available &lt;a href="http://blog.152.org/flex_examples/BrowserCookies.zip" target="_blank"&gt;here&lt;/a&gt;. Feel free to contact me if you have any questions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-5302716504222438288?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/5302716504222438288/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/flashactionscript-3-reading-browser.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/5302716504222438288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/5302716504222438288'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/flashactionscript-3-reading-browser.html' title='Flash / ActionScript 3 / Flex : Reading browser cookies'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-5091724304441712720</id><published>2009-10-13T13:28:00.000-07:00</published><updated>2009-11-20T16:02:59.643-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='typo'/><category scheme='http://www.blogger.com/atom/ns#' term='dataformat'/><category scheme='http://www.blogger.com/atom/ns#' term='cookbook'/><category scheme='http://www.blogger.com/atom/ns#' term='3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='urlloader'/><category scheme='http://www.blogger.com/atom/ns#' term='flash'/><category scheme='http://www.blogger.com/atom/ns#' term='as'/><title type='text'>Flash / Actionscript 3: DataFormat doesn't exist</title><content type='html'>I was looking through the &lt;a href="http://amzn.com/0596526954"&gt;ActionScript 3.0 Cookbook&lt;/a&gt; today and started experimenting with the &lt;b&gt;URLLoader&lt;/b&gt; class. The example on page 437 talks about setting the format for the incoming URL. When setting the &lt;i&gt;dataFormat&lt;/i&gt; property of &lt;b&gt;URLLoader&lt;/b&gt; it suggests using the constant called&amp;nbsp;&lt;b&gt;DataFormat&lt;/b&gt;. The only problem is this constant doesn't exist. It's a typo. &lt;br /&gt;&lt;br /&gt;The real value is called &lt;b&gt;URLLoaderDataFormat&lt;/b&gt;. You can read more about it &lt;a href="http://help.adobe.com/en_US/AIR/1.1/jslr/flash/net/URLLoader.html#dataFormat"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-5091724304441712720?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/5091724304441712720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/flashas3-dataformat-doesnt-exist.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/5091724304441712720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/5091724304441712720'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/flashas3-dataformat-doesnt-exist.html' title='Flash / Actionscript 3: DataFormat doesn&apos;t exist'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-8468593832787324889</id><published>2009-10-11T15:05:00.000-07:00</published><updated>2009-11-10T14:07:53.659-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='custom'/><category scheme='http://www.blogger.com/atom/ns#' term='mvc'/><category scheme='http://www.blogger.com/atom/ns#' term='ini'/><category scheme='http://www.blogger.com/atom/ns#' term='parse_ini_file'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='php.ini'/><category scheme='http://www.blogger.com/atom/ns#' term='htaccess'/><category scheme='http://www.blogger.com/atom/ns#' term='eval'/><title type='text'>PHP: Creating your own custom ini config file</title><content type='html'>In a continuing effort to make my life more difficult I've decided to write my own MVC. I could have easily used one of many frameworks(&lt;a href="http://framework.zend.com/" target="_blank"&gt;Zend Framework&lt;/a&gt;, &lt;a href="http://cakephp.org/" target="_blank"&gt;Cake&lt;/a&gt;, &lt;a href="http://www.symfony-project.org/" target="_blank"&gt;Symfony&lt;/a&gt;, etc ...) but I was really interested in what it takes to write one. So far it's been a great experience and I've learned a lot about PHP5. &lt;br /&gt;&lt;br /&gt;One of the things I noticed about a lot of the MVCs is they store settings in an external ini file. I had no idea how they pulled the information out of them until I ran across &lt;a href="http://www.ibm.com/developerworks/web/library/os-php-cloud1/" target="_blank"&gt;this article on IBM's website&lt;/a&gt;. They mentioned a function called &lt;a href="http://php.net/parse_ini_file" target="_blank"&gt;&lt;b&gt;parse_ini_file&lt;/b&gt;&lt;/a&gt;. This function has been around since PHP4, but I never knew about it. You could fill the grand canyon with the things I don't know, but let's focus on this for now.&lt;br /&gt;&lt;br /&gt;This function allows you to read a external ini file and it returns an array of properties. You can also configure it to return an associative array of values grouped by category.&lt;br /&gt;&lt;br /&gt;This allowed me to move a lot of settings into an external file and clean up a huge chunk of code. The problem is many of the variables I defined were dynamic. parse_ini_file doesn't evaluate external PHP code. The trick to that is to run &lt;a href="http://php.net/eval" target="_blank"&gt;&lt;b&gt;eval&lt;/b&gt;&lt;/a&gt; on things you want it to parse.&lt;br /&gt;&lt;br /&gt;Here is an example of some code I have stored in an external file.&lt;br /&gt;&lt;pre class="brush: php"&gt;[define]&lt;br /&gt;PATH_HTTP = "http://{$_SERVER['HTTP_HOST']}/test_site/"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I created a function that will parse the ini file and will run eval on anything in the define group.&lt;br /&gt;&lt;pre class="brush: php"&gt;//configure define. this will parse php code&lt;br /&gt;if(isset($ini['define']))&lt;br /&gt;{&lt;br /&gt;  foreach($ini['define'] as $key=&amp;gt;$item)&lt;br /&gt;  {&lt;br /&gt;    define($key, eval("return \"{$item}\";"));&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The important part to note when using &lt;b&gt;eval&lt;/b&gt; is that it doesn't return a value. If you want to capture the evaluated variable prefix the variable with "return" and make sure to end the line with a &lt;b&gt;;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update&lt;/b&gt;&lt;br /&gt;An important thing to note is that ini files can be read very easily in a web browser. You'll want to set up a .htaccess file that blocks viewing of ini files. You can copy-paste this into a .htaccess file at the root of your site.&lt;br /&gt;&lt;pre&gt;&amp;lt;files *.ini&amp;gt;&lt;br /&gt;order allow,deny&lt;br /&gt;deny from all&lt;br /&gt;&amp;lt;/files&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-8468593832787324889?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/8468593832787324889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/php-creating-your-own-ini-config-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8468593832787324889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8468593832787324889'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/php-creating-your-own-ini-config-file.html' title='PHP: Creating your own custom ini config file'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-1255633723496635262</id><published>2009-10-08T11:41:00.000-07:00</published><updated>2009-10-08T14:02:09.539-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='catch'/><category scheme='http://www.blogger.com/atom/ns#' term='setAttribute'/><category scheme='http://www.blogger.com/atom/ns#' term='ie'/><category scheme='http://www.blogger.com/atom/ns#' term='option'/><category scheme='http://www.blogger.com/atom/ns#' term='explorer'/><category scheme='http://www.blogger.com/atom/ns#' term='createTextNode'/><category scheme='http://www.blogger.com/atom/ns#' term='internet'/><category scheme='http://www.blogger.com/atom/ns#' term='select'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='createElement'/><category scheme='http://www.blogger.com/atom/ns#' term='try'/><title type='text'>Javascript: Adding options to a select element</title><content type='html'>I've started working with javascript more and more now. I'm leaning away from using innerHTML and started creating the objects instead. As with anything javascript related Internet Explorer will cause more problems than solutions. &lt;br /&gt;&lt;br /&gt;When you're creating a new option element that will be added to a select element IE wants to do it one way while everyone else can handle it another way. I'll show the first way I tried to tackle it, and then show the cross browser way to handle it.&lt;br /&gt;&lt;br /&gt;I set up a try, catch block that would try IE first. If an error occurred it would fall back to the second method that works in most browsers.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js"&gt;&lt;br /&gt;//IE code&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;  obj_option = document.createElement('&amp;lt;option value="test value"/&amp;gt;');&lt;br /&gt;  obj_text = document.createTextNode("option text value");&lt;br /&gt;  obj_option.appendChild(obj_text);&lt;br /&gt;}&lt;br /&gt;//everyone else&lt;br /&gt;catch(e)&lt;br /&gt;{&lt;br /&gt;  var obj_option = document.createElement('option');&lt;br /&gt;  &lt;br /&gt;  obj_option.text = "option text value";&lt;br /&gt;  obj_option.value = "test value";&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Internet Explorer wants to place the value inside of the createElement method while other browsers can handle the assignment on the object property. Also IE wants the text added with createTextNode. It's a pain to have two methods for something so simple. After a bit of experimentation and research I have a method that works for all browsers.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js"&gt;&lt;br /&gt;var obj_option;&lt;br /&gt;var obj_text;&lt;br /&gt;&lt;br /&gt;obj_option = document.createElement('option');&lt;br /&gt;obj_text = document.createTextNode("option text value");&lt;br /&gt;obj_option.appendChild(obj_text);&lt;br /&gt;obj_option.setAttribute("value", "test value");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is much cleaner and easier to maintain. setAttribute is also a handy method for assigning non standard properties to an object. Some client-side form validation scripts want to add proprietary properties to a tag. Using setAttribute is the easiest way to create them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-1255633723496635262?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/1255633723496635262/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/javascript-adding-options-to-select.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/1255633723496635262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/1255633723496635262'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/javascript-adding-options-to-select.html' title='Javascript: Adding options to a select element'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-3256138947866485830</id><published>2009-10-04T21:59:00.001-07:00</published><updated>2009-11-19T10:32:08.157-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='10.6'/><category scheme='http://www.blogger.com/atom/ns#' term='svnkit'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='studio'/><category scheme='http://www.blogger.com/atom/ns#' term='zend'/><category scheme='http://www.blogger.com/atom/ns#' term='leopard'/><category scheme='http://www.blogger.com/atom/ns#' term='snow'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='osx'/><category scheme='http://www.blogger.com/atom/ns#' term='svn'/><category scheme='http://www.blogger.com/atom/ns#' term='6.1'/><title type='text'>Zend Studio 6.1: SVN update on Snow Leopard</title><content type='html'>I ran into an issue with a svn project today so I decided to create a new repository. The thing I didn't realize is that SVN has been upgraded to version 1.6.2 in Snow Leopard. This caused a major conflict with Zend Studio 6.1. When I tried to browse the repository with a project import it couldn't read the SVN tree.&lt;br /&gt;&lt;br /&gt;After a lot of searching I figured out how to update the SVN plug-in.&lt;br /&gt;&lt;br /&gt;Goto &lt;b&gt;Help&lt;/b&gt; =&amp;gt; &lt;b&gt;Software Updates&lt;/b&gt; =&amp;gt; &lt;b&gt;Find and Install&lt;/b&gt;.&lt;br /&gt;Select &lt;b&gt;Search for updates of the currently installed features&lt;/b&gt; and click Finish.&lt;br /&gt;&lt;br /&gt;When the search finishes check "Subversive update site 2.0.x".&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.152.org/uploaded_images/svn-761339.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" src="http://blog.152.org/uploaded_images/svn-761336.jpg" style="cursor: hand; cursor: pointer; display: block; height: 308px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Click the "Search" button. There should be an option listed called "Subversive update site 2.0.x". If you check the box you will get an error on a JavaHL 1.4.5 Win32 Binaries (Optional). Click the arrow to the left of to expose more options. Click the arrow to the left of "Subversive SVN Connectors" and uncheck all the JavaHL Win32 Binaries. This should allow you to install the new update.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.152.org/uploaded_images/svn-exceptions-708229.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" src="http://blog.152.org/uploaded_images/svn-exceptions-708226.jpg" style="cursor: hand; cursor: pointer; display: block; height: 226px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When the update has finished Zend will prompt you to allow a restart. Once it closes you will have to restart it. You'll need to select the new SVN plugin. Goto &lt;b&gt;Zend Studio for Eclipse&lt;/b&gt; =&amp;gt; &lt;b&gt;Preferences&lt;/b&gt;. Goto &lt;b&gt;Team&lt;/b&gt; =&amp;gt; &lt;b&gt;SVN&lt;/b&gt;. Click the &lt;b&gt;SVN Connector&lt;/b&gt; tab and select "SVN Kit (SVN/1.6.2 SVNKit/1.3.0)" from the SVN Connector down down.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.152.org/uploaded_images/svn-prefs-760357.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" src="http://blog.152.org/uploaded_images/svn-prefs-760354.jpg" style="cursor: hand; cursor: pointer; display: block; height: 226px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You should be able to import a project from a new version of SVN without a problem.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update 10/05/2009&lt;/b&gt;&lt;br /&gt;I may have left out a key piece of resolving the SVN issue. I was trying many things at the time, and this might be one of the parts that made it work.&lt;br /&gt;&lt;br /&gt;There is a new version of the SVNKit plug-in for eclipse. I don't have the exact steps at this moment to install them in Zend Studio, but the site has the steps for Eclipse and they're pretty close. You can view them &lt;a href="http://svnkit.com/download.php#eclipse-update-site" target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-3256138947866485830?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/3256138947866485830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/zend-studio-61-svn-update-on-snow.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/3256138947866485830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/3256138947866485830'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/zend-studio-61-svn-update-on-snow.html' title='Zend Studio 6.1: SVN update on Snow Leopard'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-3055070592152911860</id><published>2009-10-01T13:41:00.000-07:00</published><updated>2009-10-01T13:56:16.037-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='Library'/><category scheme='http://www.blogger.com/atom/ns#' term='class'/><category scheme='http://www.blogger.com/atom/ns#' term='build'/><category scheme='http://www.blogger.com/atom/ns#' term='complete'/><category scheme='http://www.blogger.com/atom/ns#' term='classes'/><category scheme='http://www.blogger.com/atom/ns#' term='autocomplete'/><category scheme='http://www.blogger.com/atom/ns#' term='auto'/><category scheme='http://www.blogger.com/atom/ns#' term='path'/><title type='text'>Flex: New Classes won't import into a project from a library</title><content type='html'>I ran into an issue while working on a Flex project where a new class I created in a Library wouldn't import, or auto-complete in the working project. It was also throwing a few different errors.&lt;br /&gt;&lt;br /&gt;This was displayed at Runtime:&lt;br /&gt;Variable xxx is not defined.&lt;br /&gt;&lt;br /&gt;This was displayed in the Problems window:&lt;br /&gt;Access of undefined property xxx.&lt;br /&gt;&lt;br /&gt;Sometimes Flex doesn't update the Build Path to include new classes. If you run into this issue you can check to see if everything in your project is included in the Build Path.&lt;br /&gt;&lt;br /&gt;Right-click on your Library project and goto Properties. Select "Flex Library Build Path" on the left and look in the Classes tab on the right. Scroll through the list to make sure everything is selected. If you're getting the errors above there is more than likely something in the list that isn't checked.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align:center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://blog.152.org/uploaded_images/CropperCapture[19]-751957.Png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 328px;" src="http://blog.152.org/uploaded_images/CropperCapture[19]-751955.Png" border="0" alt="" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-3055070592152911860?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/3055070592152911860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/10/flex-new-classes-wont-import-into.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/3055070592152911860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/3055070592152911860'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/10/flex-new-classes-wont-import-into.html' title='Flex: New Classes won&apos;t import into a project from a library'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-2953770422891636189</id><published>2009-09-25T14:50:00.000-07:00</published><updated>2009-11-20T16:02:59.646-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='trace'/><category scheme='http://www.blogger.com/atom/ns#' term='debug'/><category scheme='http://www.blogger.com/atom/ns#' term='as2'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript3'/><category scheme='http://www.blogger.com/atom/ns#' term='3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript2'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='2'/><title type='text'>Flex / ActionScript: Debugging</title><content type='html'>I ran into an issue while working on a project in flex. I was trying to figure out why something wasn't working and had a large amount of trace calls in my code. It was a complete pain to remove them all. This lead me to develop a debug class that I can turn off at a page level or you can turn if off in the class. It's a first draft. I'd like to make it a Singlton so I can turn it off for the whole project at a page level, but that's for later.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;package &lt;br /&gt;{&lt;br /&gt;public class Debug&lt;br /&gt;{&lt;br /&gt;private var _displayDebug:Boolean = false;&lt;br /&gt;private var _incomingClass:String = "";&lt;br /&gt;private var _logArray:Array = [];&lt;br /&gt;&lt;br /&gt;//to stop all debugging set this to false&lt;br /&gt;private var _turnOffDebug:Boolean = false;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Create the debug object &lt;br /&gt;* @param display&lt;br /&gt;* @param fileName&lt;br /&gt;* &lt;br /&gt;*/&lt;br /&gt;public function Debug(display:Boolean, fileName:String): void {&lt;br /&gt;_displayDebug = display;&lt;br /&gt;_incomingClass = fileName;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Display a trace message &lt;br /&gt;* @param msg&lt;br /&gt;* &lt;br /&gt;*/&lt;br /&gt;public function log(msg:String) : void {&lt;br /&gt;//override anything a debug passes in&lt;br /&gt;if(_turnOffDebug) {&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if(!_displayDebug) {&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var logMessage:String = "["+ new Date() +"]" + _incomingClass + ": " + msg; &lt;br /&gt;&lt;br /&gt;trace(logMessage);&lt;br /&gt;_logArray.push(logMessage);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using the class is simple. First create an instance of the class and tell if wither you want it on and what the name of the script you're calling it from is named.&lt;br /&gt;&lt;pre class="brush: as3"&gt;var debugObj:Debug = new Debug(true, 'main.mxml');&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To turn off debugging for the script just set the first parameter to false. To turn it off for the whole project change the class variable _turnOffDebug to true;&lt;br /&gt;&lt;br /&gt;Use the log method to display your statement in the debug area of flash or flex.&lt;br /&gt;&lt;pre class="brush: as3"&gt;debugObj.log('debug statement');&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is a what the trace statement should look like.&lt;br /&gt;[Fri Sep 25 15:03:21 GMT-0700 2009]main.mxml: debug statement&lt;br /&gt;&lt;br /&gt;If you have any feedback please send me a message.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-2953770422891636189?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/2953770422891636189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/09/flexactionscript-debugging.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/2953770422891636189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/2953770422891636189'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/09/flexactionscript-debugging.html' title='Flex / ActionScript: Debugging'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-6868691377402880491</id><published>2009-09-22T21:02:00.000-07:00</published><updated>2009-10-30T09:23:50.525-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='10.6'/><category scheme='http://www.blogger.com/atom/ns#' term='menubar'/><category scheme='http://www.blogger.com/atom/ns#' term='clock'/><category scheme='http://www.blogger.com/atom/ns#' term='bar'/><category scheme='http://www.blogger.com/atom/ns#' term='time'/><category scheme='http://www.blogger.com/atom/ns#' term='preferences'/><category scheme='http://www.blogger.com/atom/ns#' term='leopard'/><category scheme='http://www.blogger.com/atom/ns#' term='snow'/><category scheme='http://www.blogger.com/atom/ns#' term='osx'/><category scheme='http://www.blogger.com/atom/ns#' term='system'/><category scheme='http://www.blogger.com/atom/ns#' term='date'/><category scheme='http://www.blogger.com/atom/ns#' term='menu'/><title type='text'>Snow Leopard (10.6): Show the month and day in the menu bar</title><content type='html'>Snow Leopard(10.6) has a new option for Date &amp;amp; Time in System Preferences. You can now have the day, month and day of the month show in the menu bar. You could do this before, but it required a bit of hacking in the International section.&lt;br /&gt;&lt;br /&gt;Goto &lt;strong&gt;System Preferences&lt;/strong&gt; and select &lt;strong&gt;Date &amp;amp; Time&lt;/strong&gt;. Click the &lt;strong&gt;Clock&lt;/strong&gt; tab and check "&lt;em&gt;Show the day of the week&lt;/em&gt;".&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://blog.152.org/uploaded_images/time-772627.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" src="http://blog.152.org/uploaded_images/time-772625.jpg" style="cursor: hand; cursor: pointer; height: 216px; width: 400px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Your menu bar should look something like this now.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;a href="http://blog.152.org/uploaded_images/bar-748250.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" src="http://blog.152.org/uploaded_images/bar-748249.jpg" style="cursor: hand; cursor: pointer; height: 66px; width: 208px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-6868691377402880491?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/6868691377402880491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/09/snow-leopard10.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/6868691377402880491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/6868691377402880491'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/09/snow-leopard10.html' title='Snow Leopard (10.6): Show the month and day in the menu bar'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-1919077886325054292</id><published>2009-09-19T12:54:00.000-07:00</published><updated>2009-10-30T14:34:16.120-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='register'/><category scheme='http://www.blogger.com/atom/ns#' term='globals'/><category scheme='http://www.blogger.com/atom/ns#' term='4'/><category scheme='http://www.blogger.com/atom/ns#' term='php4'/><category scheme='http://www.blogger.com/atom/ns#' term='register_globals'/><category scheme='http://www.blogger.com/atom/ns#' term='workaround'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='5'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>PHP: Simple register_globals workaround</title><content type='html'>Working with an old php4 project in php5 can expose some bad programming practices and create bugs. The first problem is relying on register_globals. I don't want to turn this on because it injects variables into the page scope. I also don't want to update the whole project to not rely on it.&lt;br /&gt;&lt;br /&gt;The simple way around this is to write something that injects the variables into the project scope. This function will read all the variables from the url and inject them into the project scope. You should never rely on register_globals, but if you don't want to update old code this is an easy workaround.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: php"&gt;function register_globals()&lt;br /&gt;{&lt;br /&gt;  //if register_globals is on then return&lt;br /&gt;  if(ini_get("register_globals")) return;&lt;br /&gt;&lt;br /&gt;  //inject URL vars into scope&lt;br /&gt;  foreach($_REQUEST as $key=&amp;gt;$item)&lt;br /&gt;  {&lt;br /&gt;    $GLOBALS[$key] = $item;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-1919077886325054292?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/1919077886325054292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/09/simple-registerglobals-workaround.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/1919077886325054292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/1919077886325054292'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/09/simple-registerglobals-workaround.html' title='PHP: Simple register_globals workaround'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-4766414223450325686</id><published>2009-09-19T12:46:00.002-07:00</published><updated>2009-10-15T14:16:10.594-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='x'/><category scheme='http://www.blogger.com/atom/ns#' term='register_globals'/><category scheme='http://www.blogger.com/atom/ns#' term='5'/><category scheme='http://www.blogger.com/atom/ns#' term='osx'/><category scheme='http://www.blogger.com/atom/ns#' term='apple'/><category scheme='http://www.blogger.com/atom/ns#' term='10.6'/><category scheme='http://www.blogger.com/atom/ns#' term='4'/><category scheme='http://www.blogger.com/atom/ns#' term='leopard'/><category scheme='http://www.blogger.com/atom/ns#' term='snow'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='10.5'/><category scheme='http://www.blogger.com/atom/ns#' term='mamp'/><category scheme='http://www.blogger.com/atom/ns#' term='php.ini'/><category scheme='http://www.blogger.com/atom/ns#' term='pro'/><title type='text'>MAMP (Pro): Making changes to php.ini</title><content type='html'>I'm using MAMP Pro and trying to get an old project built in PHP4 up and running. The project depends on register_globals to be turned on. I tried to update the php.ini file located in MAMP/conf/php4/php.ini, but nothing would change when I looked at the phpinfo() output.&lt;br /&gt;&lt;br /&gt;After banging my head against the wall for awhile I turned to the forums at &lt;a href="http://mamp.info"&gt;mamp.info&lt;/a&gt;. There is an importance difference between MAMP and MAMP PRO. If you want to update any of the ini file settings while using MAMP PRO goto File =&gt; Edit Template and select the ini you want to update.&lt;br /&gt;&lt;br /&gt;The full forum post can be found &lt;a href="http://forum.mamp.info/viewtopic.php?f=2&amp;t=4354&amp;p=10784&amp;hilit=register_globals#p10784"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-4766414223450325686?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/4766414223450325686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/09/mamp-pro-making-changes-to-phpini.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/4766414223450325686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/4766414223450325686'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/09/mamp-pro-making-changes-to-phpini.html' title='MAMP (Pro): Making changes to php.ini'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-2785202008119402435</id><published>2009-09-18T13:44:00.000-07:00</published><updated>2009-11-20T16:02:59.648-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='as2'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript2'/><category scheme='http://www.blogger.com/atom/ns#' term='pad'/><category scheme='http://www.blogger.com/atom/ns#' term='zero'/><category scheme='http://www.blogger.com/atom/ns#' term='0'/><category scheme='http://www.blogger.com/atom/ns#' term='leading'/><category scheme='http://www.blogger.com/atom/ns#' term='padding'/><category scheme='http://www.blogger.com/atom/ns#' term='3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript3'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='string'/><category scheme='http://www.blogger.com/atom/ns#' term='2'/><title type='text'>Flash / ActionScript: String padding (leading zero)</title><content type='html'>I was working on a date/time format in Flash and needed a way to pad values out so they always took up the same amount of space. For example making sure a month always has two digits. Making sure it displays a "05" instead of "5". I couldn't find anything built into AS2 or AS3 to do this so I wrote something that would. It allows you to pass in a value and pad either the left or right side up to a given amount of characters.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;/**&lt;br /&gt;* This function will pad the left or right side of any variable passed in&lt;br /&gt;* elem [AS object]&lt;br /&gt;* padChar: String&lt;br /&gt;* finalLength: Number&lt;br /&gt;* dir: String&lt;br /&gt;*&lt;br /&gt;* return String&lt;br /&gt;*/&lt;br /&gt;function padValue(elem, padChar, finalLength, dir)&lt;br /&gt;{&lt;br /&gt;  //make sure the direction is in lowercase&lt;br /&gt;  dir = dir.toLowerCase();&lt;br /&gt;&lt;br /&gt;  //store the elem length&lt;br /&gt;  var elemLen = elem.toString().length;&lt;br /&gt;&lt;br /&gt;  //check the length for escape clause&lt;br /&gt;  if(elemLen == finalLength)&lt;br /&gt;  {&lt;br /&gt;    return elem;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  //pad the value&lt;br /&gt;  switch(dir)&lt;br /&gt;  {&lt;br /&gt;    default:&lt;br /&gt;    case 'l':&lt;br /&gt;      return padValue(padChar + elem, padChar, finalLength, dir);&lt;br /&gt;      break;&lt;br /&gt;    case 'r':&lt;br /&gt;      return padValue(elem + padChar, padChar, finalLength, dir);&lt;br /&gt;      break;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This function accepts an object that can be converted to a string with the toString method, the character you want to use for padding, the final length of the string and wither you want it padded on the left or right side using the character "l" or "r".&lt;br /&gt;&lt;br /&gt;For example if you have a number you want padded with three 0 so the final outcome will look like "0005" you would call the function like this.&lt;br /&gt;&lt;pre class="brush: as3"&gt;var exampleNumber:Number = 5;&lt;br /&gt;padValue(exampleNumber, "0", 4, 'l');&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you want to use this in FLEX you might want to type the parameters on the function and give it a return value.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-2785202008119402435?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/2785202008119402435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/05/string-padding-in-flash.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/2785202008119402435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/2785202008119402435'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/05/string-padding-in-flash.html' title='Flash / ActionScript: String padding (leading zero)'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-8178922941456513604</id><published>2009-08-28T16:14:00.001-07:00</published><updated>2010-01-25T09:18:38.761-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='as3'/><category scheme='http://www.blogger.com/atom/ns#' term='leading'/><category scheme='http://www.blogger.com/atom/ns#' term='prefix'/><category scheme='http://www.blogger.com/atom/ns#' term='util'/><category scheme='http://www.blogger.com/atom/ns#' term='numberformatter'/><category scheme='http://www.blogger.com/atom/ns#' term='number'/><category scheme='http://www.blogger.com/atom/ns#' term='zero'/><title type='text'>Actionscript/Flex: Number Formatting (prefix a leading zero)</title><content type='html'>I was looking for a simple way to prefix a single digit number with a zero. I thought &lt;a href="http://livedocs.adobe.com/flex/3/langref/mx/formatters/NumberFormatter.html" target="_blank"&gt;NumberFormatter&lt;/a&gt; would be able to do it, but turns out it can't. There is a project hosted on google for a bunch of tools that aren't included in Flex or Actionscript 3.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://code.google.com/p/as3corelib/"&gt;http://code.google.com/p/as3corelib/&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One of these tools allows you to prefix a number with a zero. It's in com.adobe.utils.NumberFormatter. The method is addLeadingZero(). It's kind of confusing having two NumberFormatter classes, but I didn't write it so there you go.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There's a lot of good stuff in the project, so if you're looking for something Flex doesn't do it might be in there.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I also wrote my own string padding function that can be used in Flex, AS2 or 3. Please see &lt;a href="http://blog.152.org/2009/05/string-padding-in-flash.html"&gt;this post&lt;/a&gt; for more details.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-8178922941456513604?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/8178922941456513604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/08/number-formatting-prefix-leading-zero.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8178922941456513604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8178922941456513604'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/08/number-formatting-prefix-leading-zero.html' title='Actionscript/Flex: Number Formatting (prefix a leading zero)'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-8452320105363788688</id><published>2009-08-20T08:44:00.000-07:00</published><updated>2009-09-22T21:54:47.251-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='todo'/><category scheme='http://www.blogger.com/atom/ns#' term='fixme'/><category scheme='http://www.blogger.com/atom/ns#' term='tasks'/><category scheme='http://www.blogger.com/atom/ns#' term='task'/><title type='text'>Flex: Using the Tasks window</title><content type='html'>I've been using Zend Studio for awhile and became very used to the TODO area that lets you track notes you've placed in code. I've wanted something similar for FLEX but there wasn't anything built in.&lt;br /&gt;&lt;br /&gt;Turns out there is a plugin for this very thing! You can read more about it &lt;a href="http://www.richinternet.de/blog/index.cfm?entry=911D4B57-0F0D-5A73-AF6F4D4D04099757"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-8452320105363788688?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/8452320105363788688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/08/using-tasks-window.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8452320105363788688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/8452320105363788688'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/08/using-tasks-window.html' title='Flex: Using the Tasks window'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-6241086428408825657</id><published>2009-08-12T13:59:00.000-07:00</published><updated>2009-10-23T10:29:56.844-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='viewstate'/><category scheme='http://www.blogger.com/atom/ns#' term='LinkBar'/><category scheme='http://www.blogger.com/atom/ns#' term='state'/><category scheme='http://www.blogger.com/atom/ns#' term='viewstates'/><category scheme='http://www.blogger.com/atom/ns#' term='states'/><category scheme='http://www.blogger.com/atom/ns#' term='change'/><title type='text'>Flex: Working with LinkBar viewstates</title><content type='html'>I've started experimenting with the LinkBar component for some navigation elements. I didn't want to use ViewStates because I'm loading and unloading items in a main window. I wanted to use it to capture navigation changes.&lt;br /&gt;&lt;br /&gt;You can capture clicks on each part of a LinkBar and then do what you want from there. This is the code I used.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: as3"&gt;&lt;mx:Script&gt;&lt;br /&gt;&lt;&amp;#33;[CDATA[&lt;br /&gt;import mx.events.ItemClickEvent;&lt;br /&gt;import mx.collections.ArrayCollection;&lt;br /&gt;&lt;br /&gt;private var links:Array = [{label:'Browse', id:'browseLink'},{label:'Search', id:'searchLink'}];&lt;br /&gt;&lt;br /&gt;[Bindable]&lt;br /&gt;public var linkBarDataProvider:ArrayCollection = new ArrayCollection(links);&lt;br /&gt;&lt;br /&gt;private function init() : void {&lt;br /&gt;linkBar.addEventListener(ItemClickEvent.ITEM_CLICK, handleLinkBar);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private function handleLinkBar(event:ItemClickEvent) : void {&lt;br /&gt;trace('item clicked: ' + event.item.id);&lt;br /&gt;}&lt;br /&gt;]]&gt;&lt;br /&gt;&lt;/mx:Script&gt;&lt;br /&gt;&lt;mx:LinkBar id="linkBar" dataProvider="{linkBarDataProvider}"/&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I created an Array with each navigation item I wanted and gave it a identifier. An event listener was set on the LinkBar to watch when items inside are clicked. The triggered event is ItemClickEvent.ITEM_CLICK. The event is passed to a function that will then look at the property called &lt;em&gt;item&lt;/em&gt;. &lt;em&gt;item&lt;/em&gt; is a reference to the element from the Array it used to create the navigation element. After I know which link was clicked I can load or unload the next item in the display.&lt;br /&gt;&lt;br /&gt;The example was based on the post I found &lt;a href="http://blog.flexexamples.com/2008/01/16/determining-which-item-was-clicked-in-a-flex-linkbar-control/" target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-6241086428408825657?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/6241086428408825657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/08/working-with-linkbar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/6241086428408825657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/6241086428408825657'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/08/working-with-linkbar.html' title='Flex: Working with LinkBar viewstates'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1955739017412408985.post-965451646498771931</id><published>2009-08-10T11:35:00.000-07:00</published><updated>2009-09-22T21:54:47.252-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='class'/><category scheme='http://www.blogger.com/atom/ns#' term='mxml'/><category scheme='http://www.blogger.com/atom/ns#' term='import'/><title type='text'>Flex: using mxml files as classes</title><content type='html'>Another thing I learned while working with Flex is that each MXML file can be treated like a class. You can import them and call the functions defined within like a method. This can be very useful when loading element into the stage.&lt;br /&gt;&lt;br /&gt;It's also important to note that methods and properties are available once you've created the object. If you have defined something to run on creationComplete it won't run until the object is added to the stage with addChild.&lt;br /&gt;&lt;br /&gt;main.mxml&lt;br /&gt;&lt;pre class="brush: as3"&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;br /&gt;&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"&gt;&lt;br /&gt; &lt;mx:Script&gt;&lt;br /&gt;  &lt;![CDATA[&lt;br /&gt;      import util.Example;&lt;br /&gt;   private function init() : void {&lt;br /&gt;    var example:Example = new Example;&lt;br /&gt;    &lt;br /&gt;    //run function from external MXML file&lt;br /&gt;    example.example_function();&lt;br /&gt;    &lt;br /&gt;    //add the mxml file to the stage&lt;br /&gt;    addChild(example);&lt;br /&gt;   }&lt;br /&gt;  ]]&gt;&lt;br /&gt; &lt;/mx:Script&gt;&lt;br /&gt;&lt;/mx:Application&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;util/Example.mxml&lt;br /&gt;&lt;pre class="brush: as3"&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;br /&gt;&lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" creationComplete="init()"&gt;&lt;br /&gt; &lt;mx:Script&gt;&lt;br /&gt;  &lt;![CDATA[&lt;br /&gt;   public function example_function() : void {&lt;br /&gt;    trace('running function example');&lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt;   private function init() : void {&lt;br /&gt;    trace('now all the elements inside are available');&lt;br /&gt;   }&lt;br /&gt;  ]]&gt;&lt;br /&gt; &lt;/mx:Script&gt;&lt;br /&gt;&lt;/mx:Canvas&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1955739017412408985-965451646498771931?l=blog.152.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/965451646498771931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.152.org/2009/08/using-mxml-files-as-classes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/965451646498771931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1955739017412408985/posts/default/965451646498771931'/><link rel='alternate' type='text/html' href='http://blog.152.org/2009/08/using-mxml-files-as-classes.html' title='Flex: using mxml files as classes'/><author><name>metric152</name><uri>http://www.blogger.com/profile/11587192756320730861</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='13857911564508194834'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>