<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>From inspiration to realization &#187; Flex</title>
	<atom:link href="http://www.kensodev.com/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kensodev.com</link>
	<description>Professional web/RIA development blog</description>
	<lastBuildDate>Sun, 05 Sep 2010 05:44:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Maintain sort on a DataGrid when the dataProvider is&#160;changed</title>
		<link>http://www.kensodev.com/2010/09/05/maintain-sort-on-a-datagrid-when-the-dataprovider-is-changed/</link>
		<comments>http://www.kensodev.com/2010/09/05/maintain-sort-on-a-datagrid-when-the-dataprovider-is-changed/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 05:02:42 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[Sorting]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=575</guid>
		<description><![CDATA[Usually, in our flex application we do have a data-grid, this component is very useful for displaying data and have a sorting, ordering of columns and more, out of the box. I can speak for my applications and say that every enterprise application I have ever build had at least one or more data-Grid&#8217;s inside [...]]]></description>
			<content:encoded><![CDATA[<p>Usually, in our flex application we do have a data-grid, this component is very useful for displaying data and have a sorting, ordering of columns and more, out of the box.</p>
<p>I can speak for my applications and say that every enterprise application I have ever build had at least one or more data-Grid&#8217;s inside it.</p>
<p>So, what can we say about a grid that has not been said before in the past&#8230;?</p>
<p>I recently had a grid that I enabled sorting on it, it had a data-Provider (ArrayCollection) and I needed to preserver the sorting when the collection had changed.</p>
<p>the default behavior when you hookup a collection to the dataProvider property of the grid, is that when the collection changes, it will change the sorting back to default.</p>
<p>this is the code before the fix:</p>
<pre class="brush: as3;">
			&lt;mx:DataGrid  width=&quot;100%&quot;
							height=&quot;100%&quot;
							id=&quot;dataGrid&quot;
							dataProvider=&quot;{myHelper.widgetModel.data}&quot;
							itemClick=&quot;myHelper.updateCustomFieldsButtonBar()&quot;
							allowMultipleSelection=&quot;true&quot;
							updateComplete=&quot;myHelper.gridUpdateComplete(event)&quot;&gt;
				&lt;mx:columns&gt;
					&lt;mx:DataGridColumn dataField=&quot;id&quot; headerText=&quot;id&quot; visible=&quot;false&quot;/&gt;
					&lt;mx:DataGridColumn dataField=&quot;name&quot; headerText=&quot;Field Name&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;description&quot; headerText=&quot;Description&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;typeDisplayName&quot; headerText=&quot;Type&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;entityTypes&quot; headerText=&quot;Entity Type&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;listId&quot; headerText=&quot;Entity Type&quot; visible=&quot;false&quot;/&gt;
				&lt;/mx:columns&gt;

			&lt;/mx:DataGrid&gt;
</pre>
<p>this peace of code it the most important peace in the puzzle, wiring up (binding) between a model (collection) and the dataProvider</p>
<pre class="brush: as3;">
dataProvider=&quot;{myHelper.widgetModel.data}&quot;
</pre>
<p>So, we know that this way does not work.<br />
what do we need to do in order to save the sorting when the provider changes.</p>
<p>what we actually need to do is to create a view of our collection, provide it with data and wire it up to the grid</p>
<p>This is how we do it.</p>
<pre class="brush: as3;">
&lt;mx:ListCollectionView list=&quot;{helper.widgetModel.data}&quot; id=&quot;listCollectionView&quot; /&gt;

			&lt;mx:DataGrid  width=&quot;100%&quot;
							height=&quot;100%&quot;
							id=&quot;dataGrid&quot;
							dataProvider=&quot;{listCollectionView}&quot;
							itemClick=&quot;myHelper.updateCustomFieldsButtonBar()&quot;
							allowMultipleSelection=&quot;true&quot;
							updateComplete=&quot;myHelper.gridUpdateComplete(event)&quot;&gt;
				&lt;mx:columns&gt;
					&lt;mx:DataGridColumn dataField=&quot;id&quot; headerText=&quot;id&quot; visible=&quot;false&quot;/&gt;
					&lt;mx:DataGridColumn dataField=&quot;name&quot; headerText=&quot;Field Name&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;description&quot; headerText=&quot;Description&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;typeDisplayName&quot; headerText=&quot;Type&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;entityTypes&quot; headerText=&quot;Entity Type&quot; /&gt;
					&lt;mx:DataGridColumn dataField=&quot;listId&quot; headerText=&quot;Entity Type&quot; visible=&quot;false&quot;/&gt;
				&lt;/mx:columns&gt;

			&lt;/mx:DataGrid&gt;
</pre>
<p>notice that the grid&#8217;s data provider is not the collection view.</p>
<p>now, when the data will change, the sorting will not change.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/09/05/maintain-sort-on-a-datagrid-when-the-dataprovider-is-changed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Memory management in flex&#160;applications</title>
		<link>http://www.kensodev.com/2010/08/22/memory-management-in-flex-applications/</link>
		<comments>http://www.kensodev.com/2010/08/22/memory-management-in-flex-applications/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 05:24:33 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Concept]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Event Listener]]></category>
		<category><![CDATA[Flex memory]]></category>
		<category><![CDATA[Memory management]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=569</guid>
		<description><![CDATA[lately there is alot of buzz about flex application performance, keeping your memory low and just in general, keeping everything managed under your fingers and not just counting on the flex framework to manage your memory. flex has a garbage collector but it&#8217;s a bit special on the way it handles memory so I thought [...]]]></description>
			<content:encoded><![CDATA[<p><span>lately there is <span>alot</span> of buzz about flex application performance, keeping your memory low and just in general, keeping everything managed under your fingers and not just counting on the flex framework to manage your memory.</span></p>
<p>flex has a garbage collector but it&#8217;s a bit special on the way it handles memory so I thought I would layout some general rules on how to keep memory low.</p>
<p><span>first thing we need to understand is that any application we will build in our careers will be using some amount of memory, and because memory is not infinite we should keep our applications memory as low as possible.</span></p>
<p>I always say the best way to describe memory management is to &#8220;be smart&#8221; meaning, always have memory in mind, never let it go and by doing this your application will keep lean and thin all the time</p>
<p><span>by taking up too much memory you can get into allot of trouble, you can make your users hate the application because it is running slowly and making their computer run slowly. also, the application can simply crash.</span></p>
<p><span>I hear from programmers in my consulting that computers are getting more and more memory and you can see laptops coming with 4G of memory out of the box and so on, but actually we are also seeing a movement towards mobile devices such as mobile phones etc. these mobile devices do no allow us to use too much memory because it&#8217;s limited resource.</span></p>
<h2><span>Memory leaks</span></h2>
<p><span>memory leaks is a big issue in flex programming and it&#8217;s generally speaking divided into 2 parts, first when our application is using memory in parts we didn&#8217;t want it to use and the other part is when we didn&#8217;t handle the cleaning part efficiently enough.</span></p>
<p>Flash handles memory management through something called &#8220;references&#8221;, just to make things clear before we begin, the only way an object is cleaned by the garbage collector, is be not having any reference from that object to another object, that way you can make sure the object will be &#8220;picked up&#8221; by the garbage collector.</p>
<h3>Event Listeners</h3>
<p>Event listeners are by-far the most mis-usedÂ mis-understood part of flex applications, I have seen people/developers using those without even understanding what is actually happening behind the scenes and when (and if) those are cleaned up in memory.</p>
<p>I will try to explain<br />
let&#8217;s take this peace of code</p>
<pre class="brush: as3;">
//objectX
objectY.addEventListener(some_event, some_function)
</pre>
<p>We have two objects (ObjectX, ObjectY), Object Y has a reference to a function in objectX just by passing the function, now, if your application has a reference to objectY, object X will not get cleaned because it has a reference to a function.</p>
<p>There is actually something called weak event listeners, by default the event listeners are &#8220;strong&#8221; meaning every event listener is a function, if you specify the event listener is &#8220;weak&#8221; then the event listener does not count as a reference.</p>
<h3>Static Variables</h3>
<p>Static variables are never cleaned in the entire session of a flex application, meaning if you set the variable&#8217;s value with an object, this object will never get cleaned.</p>
<p>If you want to make sure the object is cleaned you should null out the variable.</p>
<pre class="brush: as3;">
// static variable
public static var _foo:Foo;
//setting the value
_foo = new Foo();
//clean
_foo = null;
</pre>
<h3>Dictionaries</h3>
<p>Dictionaries are another big problem and source of misunderstanding in flex applications.</p>
<p>Dictionaries are key-value collections, meaning you have a collection that is built in the form of a key and a value attached to it.</p>
<p>You can use objects as your key and your value, for example let&#8217;s say we have two objects (ObjectX, ObjectY), you add an entry to the dictionary where ObjectX is the key and ObjectY is the value.</p>
<p>By default the values in dictionaries are &#8220;strong&#8221; and you can specify a &#8220;weak&#8221; key, by doing this, you can actually make sure that if nothing else has a reference to ObjectX, it will get cleaned by the garbage collection, BUT, ObjectY will not get cleaned even though the key for it got cleaned from the dictionary.</p>
<p>There are many questions on this issue from flex experts to adobe, those questions generally start with a WHYYYYYY????</p>
<p>I would also like to understand why but this is the situation and we have to deal with it, in the Flex-Show podcast Aaron says that if you iterate through the values of the dictionary, then all values that don&#8217;t have a key (it was cleaned remember?) gets cleaned immediately.</p>
<p>I never encountered this behavior but Aaron knows what he is talking about, so I trust him <img src='http://www.kensodev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (Thanks Aaron).</p>
<h2>Conclusion</h2>
<p>I think those are the main three issues in flex applications, there are a few more but if you handle those three you should be fine and your application will actually be pretty lean (at least in memory management).</p>
<p>** this post was inspired by Aaron&#8217;s talk on the podcast, I enjoyed it so much I decided to make a post on the issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/08/22/memory-management-in-flex-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>keep your mxml files neat with View&#160;Helpers</title>
		<link>http://www.kensodev.com/2010/08/19/keep-your-mxml-files-neat-with-view-helpers/</link>
		<comments>http://www.kensodev.com/2010/08/19/keep-your-mxml-files-neat-with-view-helpers/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 16:00:53 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Concept]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[Consulting]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=558</guid>
		<description><![CDATA[I have been working with flex and consulting about flex development for quite some time now, I guess about 3 years of consulting and 4 years of hands-on development. I have seen flex applications written in many ways, mxml files, as files, namespaces and more. I guess there is no &#8220;right&#8221; way to do so, [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working with flex and consulting about flex development for quite some time now, I guess about 3 years of consulting and 4 years of hands-on development.</p>
<p>I have seen flex applications written in many ways, mxml files, as files, namespaces and more.</p>
<p>I guess there is no &#8220;right&#8221; way to do so, or at least not just one &#8220;right&#8221; way.</p>
<p>these past few months I have started working with mxml files in a way I think is very convenient, it keeps my mxml file very lean and clean, all of the view code is in a separate action-script file which inherits from a base class.</p>
<p style="text-align: center;">I want to show you this, first, this is the sample project, this is what it looks like in flash builder:<br />
<a title="Screen shot 2010-08-19 at 5.26.08 PM by KensoDev, on Flickr" href="http://www.flickr.com/photos/51960246@N07/4907663294/"><img class="aligncenter" src="http://farm5.static.flickr.com/4142/4907663294_69ebd7233a.jpg" alt="Screen shot 2010-08-19 at 5.26.08 PM" width="385" height="349" /></a></p>
<p>as you can see, there is the main application, an mxml component, the BaseViewHelper class and that is just about it.</p>
<p>now, let&#8217;s have a look at the BaseViewHelper class<br />
note: this is a stripped down version of the class, it has many additions in my project, like a way to add validations, clean and dirty modes for the model and more, this is just to see the way I work, you can add your own additions to it.</p>
<pre class="brush: as3;">
package com.kensodev.core
{
	import mx.core.UIComponent;

	public class BaseViewHelper
	{
		private var _view:UIComponent;

		public function BaseViewHelper()
		{

		}

		public function init():void
		{

		}

		public function set view(v:UIComponent):void
		{
			_view = v;
		}

		public function get view():UIComponent
		{
			return _view;
		}
	}
}
</pre>
<p>as you can see, I kept it very simple, it has a view getter and setter to set the view it handles, it has an init function (for creation complete events).</p>
<p>now, let&#8217;s see an mxml component and how does the helper fits, but first let&#8217;s see a view helper which inherits from the BaseViewHelper class.</p>
<pre class="brush: as3;">

package com.kensodev.views.helpers
{
	import com.kensodev.core.BaseViewHelper;
	import com.kensodev.views.MyViewComponent;

	public class MyViewComponentHelper extends BaseViewHelper
	{
		public function MyViewComponentHelper()
		{
			super();
		}

		public function get myView():MyViewComponent
		{
			return MyViewComponent(this.view);
		}

		public override function init():void
		{
			//TODO Auto-generated method stub
			super.init();
		}

		public function myButton_clickHandler(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
		}
	}
}
</pre>
<p>This is a helper file for the MyViewComponent, now, here&#8217;s the source code for implementing the helper inside each View component</p>
<pre class="brush: as3;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Canvas xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
		   width=&quot;400&quot;
		   height=&quot;300&quot;
		   creationComplete=&quot;helper.init()&quot;
		   xmlns:helper=&quot;com.kensodev.views.helpers.*&quot;&gt;

	&lt;mx:Script&gt;
		&lt;![CDATA[

		]]&gt;
	&lt;/mx:Script&gt;

	&lt;helper:MyViewComponentHelper view=&quot;{this}&quot; id=&quot;helper&quot; /&gt;

	&lt;mx:Button id=&quot;myButton&quot; click=&quot;helper.myButton_clickHandler(event)&quot;

&lt;/mx:Canvas&gt;
</pre>
<p>as you can see, the file is very clean, it has only data relevant to understand the structure of the component (which is all you need in mxml), all of the logic files &#8220;seats&#8221; behind the scenes.</p>
<p>there is a naming conventions for views and view helpers<br />
its<br />
view_name<br />
view_nameHelper<br />
this way, when you navigate your way through the code, you can always see what you are looking for with ease like so:</p>
<p style="text-align: center;"><a title="Screen shot 2010-08-19 at 5.36.53 PM by KensoDev, on Flickr" href="http://www.flickr.com/photos/51960246@N07/4907684584/"><img class="aligncenter" src="http://farm5.static.flickr.com/4137/4907684584_169980e5f0.jpg" alt="Screen shot 2010-08-19 at 5.36.53 PM" width="500" height="399" /></a></p>
<p>I hope you take inspiration with this way, I assure you I did, it&#8217;s a very useful way to manage large projects with many views and view helpers.</p>
<p>the source code of the example project is on git here.</p>
<p><a href="http://github.com/KensoDev/view-helper-example" target="_blank">http://github.com/KensoDev/view-helper-example</a></p>
<p>******</p>
<p>update:</p>
<p>after a discussion with <a href="http://www.twitter.com/douglasknudsen">@douglasknudsen</a> I want to make things clear, this is not the ViewHelper implementation of cairngorm Mvc framework, it&#8217;s something you should (or can) write on your own just to make things organized and clean.</p>
<p>I am using it regardless to the MVC framework I am using which is RobotLegs B.T.W</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/08/19/keep-your-mxml-files-neat-with-view-helpers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Should all developers be (active) members of the virtual&#160;community?</title>
		<link>http://www.kensodev.com/2010/08/03/should-all-developers-be-members-of-the-virtual-community/</link>
		<comments>http://www.kensodev.com/2010/08/03/should-all-developers-be-members-of-the-virtual-community/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 16:12:25 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Concept]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Product management]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=544</guid>
		<description><![CDATA[usually when I post in my blog, I make comments, raise decisions, write code or something like that, it&#8217;s never a question. This post, above anything else is a question and a try to spark a debate from my fellow developers and software craftsman out there. Earlier this week I started working on a very [...]]]></description>
			<content:encoded><![CDATA[<p>usually when I post in my blog, I make comments, raise decisions, write code or something like that, it&#8217;s never a question.</p>
<p>This post, above anything else is a question and a try to spark a debate from my fellow developers and software craftsman out there.</p>
<p>Earlier this week I started working on a very interesting project for an international company creating test suites for devices and applications, the suite is cross platform and can run on any machine both windows and Linux and test any device, from mobile phones to DVD&#8217;s to diving sensors.</p>
<p>the client side is written in flex and pure AS3, the server and services are written in Java and Perl scripts.</p>
<p>What is my point?</p>
<p>My point is that this company has some pretty strong developers, all know a thing or 2 on software developement, both in Java and Flex.</p>
<p>Another thing, usually when I get invited to consult and develop for a company saying &#8220;we have a flex application&#8221; I do see an application but it&#8217;s horrible, un-scalable, mxml+code in the same file, services calls in mxml and more.</p>
<p>in this company, that wasn&#8217;t the case, the application is actually pretty solid, stable and gone over more then a couple of QA steps inside the company and clients.</p>
<p>You can imagine that the developers over there can contribute a thing or two to the community.</p>
<p>OK, so far so good, what am I saying here?</p>
<p>From conversations I had with the developers I found out something amazing, none of them has a twitter account, none of them has a blog and none, absolutely none contributed to an open source project, not even a line of code, not even opened a case in the WIKI.</p>
<p>so, what do you think?<br />
Should all developers be active members of the community?<br />
Should every developer have a profile and answer questions on the amazing <a href="http://www.stackoverflow.com">StackOverflow</a><a href="http://www.stackoverflow.com">.com</a>?<br />
Should every developer write a blog?</p>
<p>Love to hear your thoughts on this&#8230;</p>
<p>another thing, when you interview programmers, do you care about these issues?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/08/03/should-all-developers-be-members-of-the-virtual-community/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>java.io.UnsupportedEncodingException problem &amp;&#160;solution</title>
		<link>http://www.kensodev.com/2010/08/02/java-io-unsupportedencodingexception-problem-solution/</link>
		<comments>http://www.kensodev.com/2010/08/02/java-io-unsupportedencodingexception-problem-solution/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 14:02:57 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[Jboss]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=540</guid>
		<description><![CDATA[While working today on a windows machine and trying to run an ANT task and then run JBoss to test my build I encountered this error java.io.UnsupportedEncodingException: cp1255 After quite some time of Googling and finding nothing I remembered I changed my regional settings on the machine to use Hebrew as the locale. This appeared [...]]]></description>
			<content:encoded><![CDATA[<p>While working today on a windows machine and trying to run an ANT task and then run JBoss to test my build I encountered this error</p>
<pre class="brush: bash;">
 java.io.UnsupportedEncodingException: cp1255
</pre>
<p>After quite some time of Googling and finding nothing I remembered I changed my regional settings on the machine to use Hebrew as the locale.</p>
<p>This appeared to be a mistake, once I changed the locale back to English (USA) everything got back to normal and worked absolutely fine (as always)</p>
<p>So, the conclusion is:<br />
when you get this error, verify that the machine you are using is set to English Locale and not other locales.</p>
<p>hope this saves you some time, I know I pulled more then a couple of hairs to find out what is causing this issue</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/08/02/java-io-unsupportedencodingexception-problem-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RobotLegs makes me smile every&#160;time</title>
		<link>http://www.kensodev.com/2010/07/31/robotlegs-makes-me-smile-every-time/</link>
		<comments>http://www.kensodev.com/2010/07/31/robotlegs-makes-me-smile-every-time/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 10:58:49 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[RobotLegs]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=535</guid>
		<description><![CDATA[Hi All, I have been using the RobotLegs MVC framework for flex for about a month and a half now, I have been using MATE before that and PureMVC before that, I have never got so much out of an MVC framework, it is so flexible, so customizable (the code is on git) and helps [...]]]></description>
			<content:encoded><![CDATA[<p>Hi All,</p>
<p>I have been using the <a href="http://www.robotlegs.org/" target="_blank">RobotLegs</a> MVC framework for flex for about a month and a half now, I have been using <a href="http://mate.asfusion.com/" target="_blank">MATE</a> before that and <a href="http://puremvc.org/" target="_blank">PureMVC</a> before that, I have never got so much out of an MVC framework, it is so flexible, so customizable (<a href="http://github.com/KensoDev/robotlegs-framework" target="_blank">the code is on git</a>) and helps me with my tasks all of the time.</p>
<p>so, why have I posted it on the blog and not just tweeted about it? well, I have tweeted about it for quite a bit, but the real reason for posting it on the blog is that I have made a new category on the blog called <a href="http://www.kensodev.com/category/robotlegs/">RobotLegs</a>.</p>
<p>I plan on posting some example code for it and being involved in the community.</p>
<p>you can keep yourself updated through my <a href="http://feeds.feedburner.com/KensoDev-en" target="_blank">RSS FEED</a>.</p>
<p>Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/07/31/robotlegs-makes-me-smile-every-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>set button width to text width in&#160;flex</title>
		<link>http://www.kensodev.com/2010/07/14/set-button-width-to-text-width-in-flex/</link>
		<comments>http://www.kensodev.com/2010/07/14/set-button-width-to-text-width-in-flex/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 08:07:18 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=521</guid>
		<description><![CDATA[Well, I have been working on a very interesting project recently, really stretching flex to the limits I needed to set buttons, linkButtons, Labels and more component&#8217;s width to the width of the text inside them. Usually, flex does it for you but the width was hardcoded in compile time and I needed to change [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I have been working on a very interesting project recently, really stretching flex to the limits <img src='http://www.kensodev.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
I needed to set buttons, linkButtons, Labels and more component&#8217;s width to the width of the text inside them.<br />
Usually, flex does it for you but the width was hardcoded in compile time and I needed to change the text and the width in runtime and resize the component according to that.</p>
<p>I have written a nifty helper function for that.</p>
<p>here it is:</p>
<pre class="brush: as3;">
/**
* This function will accept the text and the UI component and set the width to the width of the text
* @param text the text or label of the component
* @param container the container casted to a UIComponent
*
*/
public static function measureTextWidthAndResizeComponent(text:String, container:UIComponent):void
{
	var _measuredWidth:Number = 0;
	var  _paddingLeft:uint = 0;
	var _paddingRight:uint = 0;
	var _horizontalGap:uint = 0;
	var _addedToWidth:int;

	if(text == null)
		return;

	if(text.length &lt;= 1)
		return;

	_paddingLeft = container.getStyle(&quot;paddingLeft&quot;);
	_paddingRight = container.getStyle(&quot;paddingRight&quot;);
	_horizontalGap = container.getStyle(&quot;horizontalGap&quot;);

	_addedToWidth = int(_horizontalGap + _paddingLeft + _paddingRight);

	var lineMetrics:TextLineMetrics = container.measureText(text);

	_measuredWidth = (lineMetrics.width + _addedToWidth);
	container.width = _measuredWidth;
}
</pre>
<p>That&#8217;s it, enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/07/14/set-button-width-to-text-width-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copy object properties to another object &#8211;&#160;Flex</title>
		<link>http://www.kensodev.com/2010/06/22/copy-object-properties-to-another-object-flex/</link>
		<comments>http://www.kensodev.com/2010/06/22/copy-object-properties-to-another-object-flex/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 09:23:42 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[actionscript]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=504</guid>
		<description><![CDATA[In a project I am working on with Flex and AS3 I needed to copy all of the object&#8217;s properties and accessors to another object. because I didn&#8217;t want to hard code the properties for various reasons I needed to write a function that will &#8220;crawl&#8221; the object properties and accessors and copy then to [...]]]></description>
			<content:encoded><![CDATA[<p>In a project I am working on with Flex and AS3 I needed to copy all of the object&#8217;s properties and accessors to another object.<br />
because I didn&#8217;t want to hard code the properties for various reasons I needed to write a function that will &#8220;crawl&#8221; the object properties and accessors and copy then to the new object.</p>
<p>I created a static function that does exactly that</p>
<pre class="brush: as3;">
		/**
		 * copies a source object to a destination object
		 * @param sourceObject the source object
		 * @param destinationObject the destination object
		 *
		 */
		public static function copyObject(sourceObject:Object, destinationObject:Object):void
		{
			// check if the objects are not null
			if((sourceObject) &amp;&amp; (destinationObject)) {
				try
				{
					//retrive information about the source object via XML
					var sourceInfo:XML = describeType(sourceObject);
					var objectProperty:XML;
					var propertyName:String;

					//Â loop through the properties
					for each(objectProperty in sourceInfo.variable)
					{
						propertyName = objectProperty.@name;
						if(sourceObject[objectProperty.@name] != null)
						{
							if(destinationObject.hasOwnProperty(objectProperty.@name)) {
								destinationObject[objectProperty.@name] = sourceObject[objectProperty.@name];
							}
						}
					}
					//loop through the accessors
					for each(objectProperty in sourceInfo.accessor) {
						if(objectProperty.@access == &quot;readwrite&quot;) {
							propertyName = objectProperty.@name;
							if(sourceObject[objectProperty.@name] != null)
							{
								if(destinationObject.hasOwnProperty(objectProperty.@name)) {
									destinationObject[objectProperty.@name] = sourceObject[objectProperty.@name];
								}
							}
						}
					}
				}
				catch (err:*) {
					;
				}
			}
</pre>
<p>This function will copy everything, you can simply add an &#8220;allowedProperties&#8221; definition and make the function only copy definitions and properites which exist in your allowed definition.</p>
<p>like so:</p>
<pre class="brush: as3;">
private static var allowedProperties:String = &quot;height,width,visible,styleName,x,y,alpha,visible,source,dataProvider,styleDecleration,text,label,horizontalScrollPolicy,labelField,&quot;;

		public static function copyDisplayObjectData(sourceObject:Object, destinationObject:Object):void
		{
			if((sourceObject) &amp;&amp; (destinationObject)) {
				try
				{
					var sourceInfo:XML = describeType(sourceObject);
					var objectProperty:XML;
					var propertyName:String;
					Â
					for each(objectProperty in sourceInfo.variable)
					{
						propertyName = objectProperty.@name;
						if(allowedProperties.indexOf(propertyName) &gt; -1)
						{
							if(sourceObject[objectProperty.@name] != null)
							{
								if(destinationObject.hasOwnProperty(objectProperty.@name)) {
									destinationObject[objectProperty.@name] = sourceObject[objectProperty.@name];
								}
							}

						}
					}
					Â
					for each(objectProperty in sourceInfo.accessor) {
						if(objectProperty.@access == &quot;readwrite&quot;) {
							propertyName = objectProperty.@name;
							if(allowedProperties.indexOf(propertyName) &gt; -1)
							{
								if(sourceObject[objectProperty.@name] != null)
								{
									if(destinationObject.hasOwnProperty(objectProperty.@name)) {
										destinationObject[objectProperty.@name] = sourceObject[objectProperty.@name];
									}
								}
							}
						}
					}
				}
				catch (err:*) {
					;
				}
			}
		}
</pre>
<p>That&#8217;s it, tricky but absolutely can be done <img src='http://www.kensodev.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/06/22/copy-object-properties-to-another-object-flex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Empty dialogs in flex builder 3 + Flash builder&#160;4</title>
		<link>http://www.kensodev.com/2010/06/10/empty-dialogs-in-flex-builder-3-flash-builder-4/</link>
		<comments>http://www.kensodev.com/2010/06/10/empty-dialogs-in-flex-builder-3-flash-builder-4/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 13:58:17 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Tips and tricks]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=472</guid>
		<description><![CDATA[This week I needed to work with My PC on a flex project, I usually stay away of the PC with flex projects, I&#8217;m used to working on the mac with these project but I needed to work on the PC. While trying to configure the project in flex builder 3 (and with 4 as [...]]]></description>
			<content:encoded><![CDATA[<p>This week I needed to work with My PC on a flex project, I usually stay away of the PC with flex projects, I&#8217;m used to working on the mac with these project but I needed to work on the PC.</p>
<p>While trying to configure the project in flex builder 3 (and with 4 as well) I stumbled upon a weird bug that made me scratch my head for a while.<br />
The bug was that all of the dialogs appeared empty, no configuration, almost no buttons.</p>
<p>Here&#8217;s a screenshot of the problem:</p>
<p style="text-align: center;"><a rel="facebox" href="http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-14.png"><img class="size-medium wp-image-473 aligncenter" title="Flex empty dialog" src="http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-14-300x249.png" alt="" width="300" height="249" /></a></p>
<p>Now, I remembered a teammate I had a while back had the same problem and it appeared to be a WACOM with a windows 7 driver that caused the problem so I started disabling devices one after the other.</p>
<p>The problem was a logitech mouse software I have installed on the pc, once I quited this application everything went back to normal.</p>
<p>Here&#8217;s the icon on the taskbar. (not hard to trace)</p>
<p><a rel="attachment wp-att-474 facebox" href="http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-43.png"><img class="aligncenter size-medium wp-image-474" title="Logitech Mouse Icon in taskbar" src="http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-43-300x26.png" alt="" width="300" height="26" /></a></p>
<p>Hope this post helps you and you won&#8217;t scratch your had for hours like I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/06/10/empty-dialogs-in-flex-builder-3-flash-builder-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Access flex application through the SWFLoader&#160;component</title>
		<link>http://www.kensodev.com/2010/05/30/access-flex-application-through-the-swfloader-component/</link>
		<comments>http://www.kensodev.com/2010/05/30/access-flex-application-through-the-swfloader-component/#comments</comments>
		<pubDate>Sun, 30 May 2010 16:18:32 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=460</guid>
		<description><![CDATA[Often you load flex applications through another flex application using the SWFLoader component. it&#8217;s not that common knowledge that you can actually access all of that application exactly the same way you are accessing your own application. What does that mean? It means you can access that application components, get the children and get a [...]]]></description>
			<content:encoded><![CDATA[<p>Often you load flex applications through another flex application using the SWFLoader component.<br />
it&#8217;s not that common knowledge that you can actually access all of that application exactly the same way you are accessing your own application.</p>
<p><strong>What does that mean?</strong></p>
<p>It means you can access that application components, get the children and get a good knowledge on how this application is build, you can also access it&#8217;s component and dispatch events.</p>
<p><strong>OK, how?</strong></p>
<p>Let&#8217;s start doing it. we will create a simple application, put an SWFLoader on stage and create a listener for the complete event.<br />
Lets&#8217;s also add 2 global variables, one for SystemManager, another for IUIComponent (I will explain later)</p>
<p>This is what the application code should look like:</p>
<pre class="brush: as3;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; minWidth=&quot;955&quot; minHeight=&quot;600&quot;&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
			import mx.core.IUIComponent;
			import mx.managers.SystemManager;

			private var _systemManager:SystemManager;
			private var _innerApplication:IUIComponent;

			protected function loader_completeHandler(event:Event):void
			{
				_systemManager = SystemManager(loader.content);
			}
		]]&gt;
	&lt;/mx:Script&gt;

	&lt;mx:SWFLoader id=&quot;loader&quot; source=&quot;VistaRemix.swf&quot; width=&quot;800&quot; height=&quot;600&quot; autoLoad=&quot;true&quot; complete=&quot;loader_completeHandler(event)&quot;/&gt;
&lt;/mx:Application&gt;
</pre>
<p>As you can probably see, we are assigning a value to _systemManager when the loader (SWFLoader) finished loading, this enables us to work with that application system Manager and access properties.</p>
<p>Continuing&#8230;</p>
<p>We will add 2 Event listeners inside that function</p>
<pre class="brush: as3;">
_systemManager.addEventListener(FlexEvent.APPLICATION_COMPLETE, sysManage_ApplicationComplete_Handler);
_systemManager.addEventListener(FlexEvent.UPDATE_COMPLETE, sysManage_UpdateComplete_Handler);
</pre>
<p>Now that we have those in place, let&#8217;s add the closure functions</p>
<pre class="brush: as3;">
			private function sysManage_UpdateComplete_Handler(event:FlexEvent):void
			{
				_innerApplication = _systemManager.application;
			}

			private function sysManage_ApplicationComplete_Handler(event:FlexEvent):void
			{
				_innerApplication = _systemManager.application;
			}
</pre>
<p>Great, now _innerApplication is actually an application, you can get it&#8217;s children, get properties, get components, dispatch events and more.</p>
<p>This comes in very handy when you want control over an application and you don&#8217;t have the source, you can create a clone of that application and create your own GUI for it, it&#8217;s an amazing feature.</p>
<p>This is a screenshot of debugging mode, check out the debugger watch section, these are all methods you can use on that variable, you can of course use much more&#8230;</p>
<p><a rel="attachment wp-att-464" href="http://www.kensodev.com/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-7.23.21-PM-e1275236766248.png"><img class="aligncenter size-medium wp-image-464" title="Debug view of the application in Flash builder 4" src="http://www.kensodev.com/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-7.23.21-PM-e1275236766248-300x179.png" alt="Debug view of the application in Flash builder 4" width="300" height="179" /></a></p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/05/30/access-flex-application-through-the-swfloader-component/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flash builder 4 &#8211; sharing a project with your team using SVN&#160;Screencast</title>
		<link>http://www.kensodev.com/2010/05/24/flash-builder-4-sharing-a-project-with-your-team-using-svn-screencast/</link>
		<comments>http://www.kensodev.com/2010/05/24/flash-builder-4-sharing-a-project-with-your-team-using-svn-screencast/#comments</comments>
		<pubDate>Mon, 24 May 2010 04:38:26 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Product management]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=449</guid>
		<description><![CDATA[In this post I will show you how you can share a project with your team using SVN and flash buider 4. This is my first screencast in English after quite a few in my nativeÂ tongue language so please excuse me is I stutterÂ or swallow some of my words, I promise to keep getting better [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-450" href="http://www.kensodev.com/wp-content/uploads/2010/05/Flash-Builder-4.png"><img class="alignleft size-thumbnail wp-image-450" title="Flash Builder 4" src="http://www.kensodev.com/wp-content/uploads/2010/05/Flash-Builder-4-150x150.png" alt="" width="150" height="150" /></a></p>
<p>In this post I will show you how you can share a project with your team using SVN and flash buider 4.</p>
<p>This is my first screencast in English after quite a few in my nativeÂ tongue language so please excuse me is I stutterÂ or swallow some of my words, I promise to keep getting better with time.</p>
<p><span id="more-449"></span></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="309" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11974122&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="550" height="309" src="http://vimeo.com/moogaloop.swf?clip_id=11974122&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/11974122">Flash builder 4 &#8211; share project with your team using SVN</a> from <a href="http://vimeo.com/kensodev">Avi Tzurel</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/05/24/flash-builder-4-sharing-a-project-with-your-team-using-svn-screencast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change WebOrb default port from 2037 to what you&#160;want</title>
		<link>http://www.kensodev.com/2010/05/09/change-weborb-default-port-from-2037-to-what-you-want/</link>
		<comments>http://www.kensodev.com/2010/05/09/change-weborb-default-port-from-2037-to-what-you-want/#comments</comments>
		<pubDate>Sun, 09 May 2010 15:36:06 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[WebOrb]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=433</guid>
		<description><![CDATA[I have been using WebOrb for almost a year now, sometimes it&#8217;s a great experience, sometimes less (like any other product I have ever used). I have been running production machines for a client, this client request to test the WebOrb service on another port other then 2037 (default). It&#8217;s actually quite simple to create, [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-434" href="http://www.kensodev.com/wp-content/uploads/2010/05/brown_net.jpg"><img class="alignleft size-thumbnail wp-image-434" title="Weborb" src="http://www.kensodev.com/wp-content/uploads/2010/05/brown_net-150x150.jpg" alt="" width="150" height="150" /></a>I have been using WebOrb for almost a year now, sometimes it&#8217;s a great experience, sometimes less (like any other product I have ever used).</p>
<p>I have been running production machines for a client, this client request to test the WebOrb service on another port other then 2037 (default).</p>
<p>It&#8217;s actually quite simple to create, but not intuitive.</p>
<p>if you are using WebOrb from the command line, you have a setting called &#8220;port&#8221;. all you have to do is run the command with the port param and everything will work great.</p>
<p>like so:</p>
<pre class="brush: bash;">
c:\inetpub\wwwroot\weborb30\weborbee.exe -port 1935
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/05/09/change-weborb-default-port-from-2037-to-what-you-want/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic streaming (Adaptive bitrate) using Flash media&#160;Server</title>
		<link>http://www.kensodev.com/2010/04/15/dynamic-streamin-adaptive-bitrate-using-flash-media-server/</link>
		<comments>http://www.kensodev.com/2010/04/15/dynamic-streamin-adaptive-bitrate-using-flash-media-server/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 18:56:09 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flash media server]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash player]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=417</guid>
		<description><![CDATA[Video and the web are long time friends already, you see lots of websites with some sot of player for video content, you also see media companies and television channels serving video over the wire to the end users. Video can be downloaded (progressive download) to the client like YouTube or can be streamed to [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-418" href="http://www.kensodev.com/wp-content/uploads/2010/04/fms.png"><img class="alignleft size-thumbnail wp-image-418" title="Flash Media Server" src="http://www.kensodev.com/wp-content/uploads/2010/04/fms-150x150.png" alt="" width="150" height="150" /></a>Video and the web are long time friends already, you see lots of websites with some sot of player for video content, you also see media companies and television channels serving video over the wire to the end users.</p>
<p>Video can be downloaded (progressive download) to the client like YouTube or can be streamed to him.</p>
<p>I won&#8217;t discuss the pro&#8217;s &amp; con&#8217;s of streaming and progressive, we will only be discussing streaming in this post.</p>
<p>So, What is the post worthy problem we have when streaming video to the client?</p>
<p>Continue reading and find out.<br />
<span id="more-417"></span>When streaming video, you usually encode your video in a certain bitrate, this bitrate will work well in certain computers and won&#8217;t work well in others.</p>
<p>Why is that?</p>
<p>That&#8217;s because each of your users has a different connection thus being capable to receive a limited amount of bytes streamed to him.</p>
<p>So, you always have to find the &#8220;sweet spot&#8221; where you deliver a video that looks good and also light enough to fit a wider range of network connection speeds.</p>
<p>That is of course a problem becuase sometimes you want to stream hiQuality video and audio (HD) and you can&#8217;t because some of your users won&#8217;t be able to watch it smoothly.</p>
<p>Well, this is a problem we will solve here in this post.</p>
<p>Flash media server introduced a new way of streaming video to the client, it is called dynamic streaming and it is very dynamic (name implies just that).</p>
<p>That way, you can create several encodes to the same source movie and supply a movie best fit to the user cosuming it.</p>
<p>Another obvious advantage of this approach is the way it skips on top of the movie, when you skip to a further point in the movie, you are actually being supplied a different movie from the lowest quality to the highest.</p>
<p>So, how is it done, first, let&#8217;s create a flash file (I&#8217;m using flash CS4).</p>
<p style="text-align: center;"><a rel="facebox" href="http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-15-at-9.37.06-PM.png"><img class="aligncenter size-medium wp-image-419" title="New flash file (Adaptive bitrate) dynamic streaming" src="http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-15-at-9.37.06-PM-300x171.png" alt="" width="300" height="171" /></a></p>
<p>Now, we will create (by dragging and dropping from the components panel) an FLVPlayback control.</p>
<p>We will give it the same dimensions as the movie itself so it will fill the entire surface.</p>
<p>Now, we will give the player an instance name of &#8220;flvPlayer&#8221;</p>
<p>so, we have a movie, we have an FLVPlayback control, we called it &#8220;flvPlayer&#8221;.</p>
<p>We will create another layer, called &#8220;action script&#8221; and we will create this code inside.</p>
<pre class="brush: as3;">
import fl.video.*;
VideoPlayer.iNCManagerClass = NCManagerDynamicStream;
flvPlayer.source = &quot;dynamicStream.smil&quot;;
</pre>
<p>OK, so as we can see we created a pointer to a file called &#8220;dynamicStream.smil&#8221;, this is a special file (XML format).</p>
<p>This file details the following</p>
<ul>
<li>FMS Url</li>
<li>files you have encoded and a network speed in correlation</li>
</ul>
<p>The file looks like this:</p>
<pre class="brush: xml;">
&lt;smil&gt;
    &lt;head&gt;
        &lt;meta base=&quot;rtmp://your_fms_location/vod/&quot; /&gt;
    &lt;/head&gt;
    &lt;body&gt;
	&lt;switch&gt;
		&lt;video src=&quot;mp4:erets7_03_vod1_300.mp4&quot; system-bitrate=&quot;300000&quot;/&gt;
		&lt;video src=&quot;mp4:erets7_03_vod1_500.mp4&quot; system-bitrate=&quot;500000&quot;/&gt;
		&lt;video src=&quot;mp4:erets7_03_vod1_800.mp4&quot; system-bitrate=&quot;800000&quot;/&gt;
        &lt;/switch&gt;
    &lt;/body&gt;
&lt;/smil&gt;
</pre>
<p>Now, when we put this file on our web-server, the user will get the file it can receive and play, not slower, not faster, just the perfect file for him.</p>
<p>NO buffering, NO waiting, NO frustration, smooth, cool and fast user experience.</p>
<p>Good luck.</p>
<p>You can download the complete solution from here:<br />
<a class="downloadlink" href="http://www.kensodev.com/wp-content/plugins/download-monitor/download.php?id=dynamic_streaming.zip" title=" downloaded 116 times" >Source - Dynamic streaming (flash media server) (116)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/04/15/dynamic-streamin-adaptive-bitrate-using-flash-media-server/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Enumeration on a property &#8211; Flex&#160;3</title>
		<link>http://www.kensodev.com/2010/04/07/enumeration-on-a-property-flex-3/</link>
		<comments>http://www.kensodev.com/2010/04/07/enumeration-on-a-property-flex-3/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 08:28:47 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[As3]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=383</guid>
		<description><![CDATA[Often when you create custom controls in flex application, you create custom properties and the apps consuming your components needs to set those properties for the component to work properly. lack of documentation often lead to situation when the developer consuming your component doesn&#8217;t know what are the values you expect of him to set. [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-409" href="http://www.kensodev.com/wp-content/uploads/2010/04/fx-icon.png"><img class="alignleft size-thumbnail wp-image-409" title="Flex 3" src="http://www.kensodev.com/wp-content/uploads/2010/04/fx-icon-150x150.png" alt="" width="150" height="150" /></a>Often when you create custom controls in flex application, you create custom properties and the apps consuming your components needs to set those properties for the component to work properly.</p>
<p><span id="more-383"></span></p>
<p>lack of documentation often lead to situation when the developer consuming your component doesn&#8217;t know what are the values you expect of him to set.</p>
<p>Well, there&#8217;s a solution for this, Flex introduced the &#8220;Inspectable&#8221; metadata tag, you can simply set this tag above your setter and the developer will get full intellisense and be able to know what you meant.</p>
<p>In this simple application, I create a custom mxml component based on Canvas, I create a property called myString and created an &#8220;Inspectable&#8221; metatag.</p>
<p>like so:</p>
<pre class="brush: as3;">
[Bindable]
private var _myString:String;

[Inspectable (enumeration=&quot;stringValue1,stringValue2,stringValue3&quot;)]
public function set myString(val:String):void
{
_myString = val;
}
</pre>
<p>So far, it&#8217;s as simple as it can get, now, check out a screenshot of my flex builder when setting this property from outside</p>
<p style="text-align: center;"><a rel="attachment wp-att-384 facebox" href="http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-07-at-11.20.01-AM.png"><img class="aligncenter size-medium wp-image-384" title="Flex enum on peoprty" src="http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-07-at-11.20.01-AM-300x137.png" alt="" width="300" height="137" /></a></p>
<p>And that&#8217;s it, that&#8217;s how simple it is to create enumeration and ease the life on your fellow developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/04/07/enumeration-on-a-property-flex-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RTMP being blocked by firewalls &#8211; Flash media&#160;server</title>
		<link>http://www.kensodev.com/2010/02/19/rtmp-being-blocked-by-firewalls-flash-media-server/</link>
		<comments>http://www.kensodev.com/2010/02/19/rtmp-being-blocked-by-firewalls-flash-media-server/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 17:34:27 +0000</pubDate>
		<dc:creator>Avi Tzurel</dc:creator>
				<category><![CDATA[Flash media server]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash player]]></category>

		<guid isPermaLink="false">http://www.kensodev.com/?p=359</guid>
		<description><![CDATA[If you ever worked with Flash media server or any other media server for that matter you probably know they are not working with the regular Internet protocol which is HTTP, all of the media servers (almost all at least) are working on top of a protocol called RTMP. Now, if you have users working [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-360" href="http://www.kensodev.com/wp-content/uploads/2010/02/FMS.logo_.jpg"><img class="alignleft size-thumbnail wp-image-360" title="Flash media server logo" src="http://www.kensodev.com/wp-content/uploads/2010/02/FMS.logo_-150x150.jpg" alt="" width="150" height="150" /></a>If you ever worked with <a href="http://www.adobe.com/products/flashmediaserver/" target="_blank">Flash media server</a> or any other media server for that matter you probably know they are not working with the regular Internet protocol which is HTTP, all of the media servers (almost all at least) are working on top of a protocol called <a href="http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol" target="_blank">RTMP</a>.</p>
<p>Now, if you have users working behind a firewall, they probably can&#8217;t get passed it&#8217;s restrictions and they will (in most cases) be blocked and unable to see your application / video.</p>
<p>If you are working on a server like WebOrb (I&#8217;m working with it) then the data will also be blocked, and that is a bug issue</p>
<p>Here&#8217;s a way to solve this<br />
<span id="more-359"></span></p>
<p>Well, let&#8217;s first talk a bit more about RTMP, before ditching it and moving on.</p>
<p>With flash media server you can use RTMP over a few ports (1935, 80), 1935 will probably always be blocked because it is not a known port and even simple routers often block it.</p>
<p>port 80 makes things a bit more complicated, you have to make FMS listen to a specific IP or your web-server (if on the same server) will not work.</p>
<p>So, first rule is always use port 80, this is one way to make more users be able to connect to your application, watch your videos and interact with your service.</p>
<p>The connection is being made like so:</p>
<p>rtmp://your_ip_address:80/app_name</p>
<p>DO NOT use any type of arrays of ports, simply use port 80, if the client can&#8217;t connect to RTMP on port 80, he will no be able to connect on RTMP no matter the port you are using.</p>
<p><strong>So, What am I actually saying over here&#8230;?</strong></p>
<p>I&#8217;m saying you should only make 1 connection attemp, this attempt is on port 80 using RTMP, this should be your first choice, if the connection is unsuccesful, you should move the connection to use RTMPT which is RTMP encapsulated over HTTP, firewalls will not block this connection becuase it makes RTMP &#8220;hide&#8221; behind HTTP traffic on port 80.</p>
<p>The connection is made practically the same way</p>
<p>rtmpt://your_ip_address:80/app_name</p>
<p><strong>Why not use RTMPT at all times?</strong></p>
<p>You should not use RTMPT at all times because there&#8217;s a performance issue, there is an overhead on top of each packet sent.</p>
<p><strong>Why not go through all the possible ports with RTMP first, Why only 80?</strong></p>
<p>In most cases, firewalls will block every port (but 80), the timeouts the user will have to go through will be very long before he will finally be redirected to RTMPT.</p>
<p>I will post some code on how to fallback more efficiently later on this week, this post was actually inspired from a client&#8217;s solution I did this week during a consulting session.</p>
<p>Good luck</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kensodev.com/2010/02/19/rtmp-being-blocked-by-firewalls-flash-media-server/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
