<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2009://34.37212-</id>
  <updated>2009-11-16T14:52:00Z</updated>
  <title>Comments for Search Friends Component (http://www.insideria.com/2009/07/search-friends-component.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2009://34.37212</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=37212" title="Search Friends Component" />
    <published>2009-07-07T13:00:00Z</published>
    <updated>2009-07-06T12:09:02Z</updated>
    <title>Search Friends Component</title>
    <summary>Welcome back to the series. In the previous articles we discussed topics like publishing of news, sending notifications to specific friends etc. The articles covered topics that are not only bound to the user interface in the facebook application development. This time, we are going to play around with the already existing (but complex) MultiFriend component. The component from the article 11 was quite good, but it really had the potential to be a kick ass component for facebook. There were things I wanted to implement, but was not able to because the whole article covered the basic construction of the component.</summary>
    <author>
      <name>Mirza Hatipovic</name>
      
    </author>
    
    <category term="Adobe Feed" />
    
    <category term="Features" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;Welcome back to the series. In the previous articles we discussed topics like publishing of news, sending notifications to specific friends etc. The articles covered topics that are not only bound to the user interface in the facebook application development. This time, we are going to play around with the already existing (but complex) MultiFriend component. The component from the article 11 was quite good, but it really had the potential to be a kick ass component for facebook. There were things I wanted to implement, but was not able to because the whole article covered the basic construction of the component.</div>

<div style="text-align: left;">In this article we will take the MultiFriendComponent and add functionality that will go beyond the basic stuff. Look at the original facebook search box:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img1.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img1.html','popup','width=294,height=258,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img1-thumb-294x258.png" width="294" height="258" alt="article14_img1.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">As you can see beside the name of the friends, there are other fields that appear in the search box, like the network of which the friends is the member of. Also, in the case of the original facebook search box, when we type in the name, not only the names are searched, but also the surnames, this is a big key advantage in comparison to the component we made few weeks ago.</div>

<div style="text-align: left;">These are just one of the features we want to implement in the extended version of the component, however there is one thing to note. We will use inheritance, so this way we will not touch the code we already implemented, this is the power of inheritance! Readers who did not complete the article 11 will also be able to follow this article because of inheritance, they do not need to understand the code that was previously written, they will just rely on the power of it. How many benefits of OOP are there! :-) Enough theory, let's move on to the practical part.</div>

<div style="text-align: left;">The first step in this approach is to download the FLA that came provided with the 11th article. The download link is <a href="http://insideria.com/InsideRIA_SearchFriendComponent.zip">here</a>. Let's open it to see what is inside and what we need to start. Here is the screen shot:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img2.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img2.html','popup','width=604,height=377,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img2-thumb-400x249.png" width="400" height="249" alt="article14_img2.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">As we can see, there is the text field from the previous article that is ready and already working. We will not repeat ourselves here as we already know that the component works fine. The first goal will be to implement a finer search technique that will search the names and the surnames of friends. For that, we first need to look at the structure of the inheritance that will work in this case:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img3.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img3.html','popup','width=300,height=418,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img3-thumb-300x418.png" width="300" height="418" alt="article14_img3.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">In this image above it is clearly visible how the inheritance structure looks like. At the top, there is the UIComponent that does all the hard work of drawing and resizing the component. Below, there is our custom MultiFriendField Component that is explained in article 11. Then finally, at the end, there is our SearchFriendField that will be created right now. So, open your favorite text editor and place the following class definition into it:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


package facebookUI {
 
 	<span class="category1">public</span> <span class="category1">class</span> SearchFriendsField <span class="category1">extends</span> MultiFriendField{
  
  		<span class="category1">function</span> SearchFriendsField(){
   			<span class="category2">trace</span>(<span class="category1">this</span> + „ works...&amp;#8220;);
   		}
  
  	}
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Let's see how this works. In order for this to work, we need to make sure the the newly created class is linked to the MovieClip we want here. Let's change the linkage:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img4.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img4.html','popup','width=696,height=357,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img4-thumb-400x205.png" width="400" height="205" alt="article14_img4.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">So, now it's turn for the big test. We need to check if the whole inheritance idea works for us. Let's compile the swf and run it inside the facebook application canvas. Here is the result on my side:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/article14_img5.png"><img alt="article14_img5.png" src="http://www.insideria.com/assets_c/2009/06/article14_img5-thumb-400x164.png" width="400" height="164" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Cool, this is the sign that the inheritance in the class is working! We have all the hard work from article 11 in one class and we have all the place in the class SearchFriendsField to add new features.</div>

<div style="text-align: left;">Now we talked about that how to implement a new search functionality. We need a way to search for names and surnames. In order to update the search, we need to find the method that does the search, and that is: </div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


protected <span class="category1">function</span> textChanged(e:Event):<span class="category1">void</span> {
 
 	<span class="category1">var</span> <span class="category2">names</span>:<span class="category2">Array</span> = _inputField.<span class="category2">text</span>.<span class="category2">split</span>("<span class="quote">,</span>");
 	<span class="category1">var</span> lastName:<span class="category2">String</span> = <span class="category2">names</span>[<span class="category2">names</span>.<span class="category2">length</span> - 1];
 	_suggestClip.suggest(trim(lastName));
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Currently, this method only passes the names of the users, we need to do some magic to implement the search functionality for the names and the surnames. The line of code:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

<span class="category1">var</span> lastName:<span class="category2">String</span> = <span class="category2">names</span>[<span class="category2">names</span>.<span class="category2">length</span> - 1];</pre>
</code>

</div></div> 

<div style="text-align: left;">is a bit misleading (my fault :-) ). It passes whole name, like "Mirza Hatipovic" instead of "Hatipovic" or only "Mirza". The whole method need to look like this:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

override protected <span class="category1">function</span> textChanged(e:Event):<span class="category1">void</span> {
 
 			<span class="category1">var</span> <span class="category2">names</span>:<span class="category2">Array</span> = _inputField.<span class="category2">text</span>.<span class="category2">split</span>("<span class="quote">,</span>");
 			<span class="category1">var</span> <span class="category2">name</span>:<span class="category2">String</span> = <span class="category2">names</span>[<span class="category2">names</span>.<span class="category2">length</span> - 1];
 			<span class="category1">var</span> n:<span class="category2">Array</span> = <span class="category2">name</span>.<span class="category2">split</span>("<span class="quote"> </span>");
 			<span class="category1">var</span> firstName:<span class="category2">String</span> = n[0];
 			<span class="category1">var</span> lastName:<span class="category2">String</span> = n[1];
 
 			_suggestClip.suggest(trim(firstName));
 
 			<span class="category1">if</span>(lastName){
  				_suggestClip.suggest(trim(lastName));
  			}
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Unfortunately it is not enough, we need to open SuggestClip.as and modify the method getSimilarWords():</div>


<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


<span class="category1">private</span> <span class="category1">function</span> getSimilarWords(typed:<span class="category2">String</span>){
 
 	<span class="category1">this</span>.<span class="category2">visible</span> = <span class="category1">true</span>;
 	_wordSugg.clearAll();
 	<span class="category1">var</span> w = _words;
 	<span class="category1">var</span> i = 0;
 	<span class="category1">var</span> len = w.<span class="category2">length</span>;
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  
  		<span class="category1">var</span> currword:<span class="category2">String</span> = w[i];
  
  		<span class="category1">var</span> n:<span class="category2">Array</span> = currword.<span class="category2">split</span>("<span class="quote"> </span>");
  		<span class="category1">var</span> firstName:<span class="category2">String</span> = n[0];
  		<span class="category1">var</span> lastName:<span class="category2">String</span> = n[1];
  
  		<span class="category1">if</span>(typed.<span class="category2">toLowerCase</span>() == (firstName.<span class="category2">substr</span>(0, typed.<span class="category2">length</span>).<span class="category2">toLowerCase</span>())){
   			_wordSugg.addWord(currword, typed.<span class="category2">length</span>);
   		}
  
  		<span class="category1">if</span>(typed.<span class="category2">toLowerCase</span>() == (lastName.<span class="category2">substr</span>(0, typed.<span class="category2">length</span>).<span class="category2">toLowerCase</span>())){
   			_wordSugg.addWord(currword, typed.<span class="category2">length</span>);
   		}
  
  	}
 
 	<span class="category1">if</span>(i &gt; 0){
  		_wordSugg.focusFirst();
  	}
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">And finally we see in the image that the component is seaching both for names and surnames </div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img6.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img6.html','popup','width=391,height=207,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img6-thumb-391x207.png" width="391" height="207" alt="article14_img6.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Cool, we finally have the right algorithm for friends search. The search is more complex and a lot more precise then the previous one. </div>

<div style="text-align: left;">The next thing we need to do is to display the country / network the friend belongs to. Here is the image to remind how this looks like in reality:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img11.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img11.html','popup','width=294,height=258,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img1-thumb-294x258.png" width="294" height="258" alt="article14_img1.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">As we can see, it does not show up below every friend, but it does show up below friends that entered such information. In order to achieve this, we need to tweak not just the code, but also the MovieClip that holds the information. So, let's search for this MovieClip inside the library. On my side the clip is named WordButton.</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img7.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img7.html','popup','width=374,height=353,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img7-thumb-374x353.png" width="374" height="353" alt="article14_img7.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">So, let's open it to see how it looks like inside before we make any tweaks to the clip:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img8.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img8.html','popup','width=288,height=107,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img8-thumb-288x107.png" width="288" height="107" alt="article14_img8.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Hey, inside the clip there is only a text field to display the name properly. We need to create a new one below it, font size 7 and font color light gray.</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img9.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img9.html','popup','width=524,height=238,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img9-thumb-400x181.png" width="400" height="181" alt="article14_img9.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Now the clip is ready and it can be used in the script. It would be nice to start the application in the current state to see how the new text field looks like:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img10.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img10.html','popup','width=406,height=218,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img10-thumb-400x214.png" width="400" height="214" alt="article14_img10.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Ok, we see that the new text field appears right below the name and that was the desired result. The next thing we need to do is to populate the newly created text field with the network name. Hmm, let's examine how to do that. The method Users.getInfo() had fields that gives us the geographical location:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

user -&gt; current_location -&gt; country</pre>
</code>

</div></div> 

<div style="text-align: left;">That's cool, now we need to check where we update the information to make the necessary modifications. Open MultiFriendField.as and find the following method:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


protected <span class="category1">function</span> onDataRecieve(e:FacebookEvent){
  	
 			<span class="category1">var</span> userData = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
 			
 			<span class="category1">var</span> i;
 			<span class="category1">var</span> len = userData.<span class="category2">length</span>;
 		 
 			<span class="category1">for</span>(i = 0; i &lt; len; i++){
  				<span class="category1">var</span> user = userData.<span class="category2">getItemAt</span>(i);
  				<span class="category2">trace</span>(user.first_name + "<span class="quote"> </span>" + user.last_name);
  				_suggestClip.addWord(user.first_name + "<span class="quote"> </span>" + user.last_name);
  			}
  	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">The same method will be overridden in the SearchFriendField method. It looks like this:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>
 
override protected <span class="category1">function</span> onDataRecieve(e:FacebookEvent){
  	
 			<span class="category1">var</span> userData = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
 			
 			<span class="category1">var</span> i;
 			<span class="category1">var</span> len = userData.<span class="category2">length</span>;
 		 
 			<span class="category1">for</span>(i = 0; i &lt; len; i++){
  				<span class="category1">var</span> user = userData.<span class="category2">getItemAt</span>(i);
  				_suggestClip.addWord(user.first_name + "<span class="quote"> </span>" + user.last_name + "<span class="quote"> </span>" + user.current_location.country);
  			}
  	
 		}</pre>
</code>

</div></div>

<div style="text-align: left;">
As a result we see the country in the output window but still we did not display it. Here is how we can do it. We need to add the country to the getSimilarWords method, provided by SuggestClip.as:</div>

<div style="text-align: left;">SuggestClip.as:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


<span class="category1">private</span> <span class="category1">function</span> getSimilarWords(typed:<span class="category2">String</span>){
 			<span class="category1">this</span>.<span class="category2">visible</span> = <span class="category1">true</span>;
 			_wordSugg.clearAll();
 			<span class="category1">var</span> w = _words;
 			<span class="category1">var</span> i = 0;
 			<span class="category1">var</span> len = w.<span class="category2">length</span>;
 			<span class="category1">for</span>(i = 0; i &lt; len; i++){
  
  				<span class="category1">var</span> currword:<span class="category2">String</span> = w[i];
  
  				<span class="category1">var</span> n:<span class="category2">Array</span> = currword.<span class="category2">split</span>("<span class="quote"> </span>");
  				<span class="category1">var</span> firstName:<span class="category2">String</span> = n[0];
  				<span class="category1">var</span> lastName:<span class="category2">String</span> = n[1];
  				<span class="category1">var</span> country:<span class="category2">String</span> = n[2];
  
  				<span class="category1">if</span>(typed.<span class="category2">toLowerCase</span>() == (firstName.<span class="category2">substr</span>(0, typed.<span class="category2">length</span>).<span class="category2">toLowerCase</span>())){
   					_wordSugg.addWord(currword, typed.<span class="category2">length</span>, country);
   				}
  
  				<span class="category1">if</span>(typed.<span class="category2">toLowerCase</span>() == (lastName.<span class="category2">substr</span>(0, typed.<span class="category2">length</span>).<span class="category2">toLowerCase</span>())){
   					_wordSugg.addWord(currword, typed.<span class="category2">length</span>, country);
   				}
  
  
  			}
 			<span class="category1">if</span>(i &gt; 0){
  				_wordSugg.focusFirst();
  			}
 		}


In SuggWord.as:

<span class="category1">public</span> <span class="category1">function</span> addWord(t:<span class="category2">String</span>, len:<span class="category2">Number</span>, country:<span class="category2">String</span>):<span class="category1">void</span>{
 			
 			_clipCounter++;
 			
 			<span class="category1">var</span> word_mc:<span class="category2">MovieClip</span> = <span class="category1">new</span> WordButton();
 			word_mc.<span class="category2">name</span> = "<span class="quote">field</span>" + _clipCounter;
 
 			_clips["<span class="quote">field</span>" + _clipCounter] = word_mc;
 
 			<span class="category1">this</span>.addChild(word_mc);
 			word_mc.setWord(t, len, country);
 
 			<span class="category1">var</span> clip = _clips["<span class="quote">field</span>" + (_clipCounter - 1)];
 			<span class="category1">var</span> prevClipExists = <span class="category2">Boolean</span>(clip);
 
 			<span class="category1">if</span>(prevClipExists){
  				word_mc.<span class="category2">y</span> = clip.<span class="category2">y</span> + clip.<span class="category2">height</span>;
  			} <span class="category1">else</span> {
  				word_mc.<span class="category2">y</span> = 1;	
  			}
 
 
 			word_mc.addEventListener(MouseEvent.CLICK, wordClicked);
 			
 		}

&lt;div style="<span class="quote">text-align: left;</span>"&gt;In WordButton.as:&lt;/div&gt;

<span class="category1">public</span> <span class="category1">function</span> setWord(w:<span class="category2">String</span>, len:<span class="category2">Number</span>, c:<span class="category2">String</span>):<span class="category1">void</span>{
 			main_txt.<span class="category2">visible</span> = <span class="category1">false</span>;
 			main_txt.<span class="category2">htmlText</span> = "<span class="quote">&lt;b&gt;</span>" + w.<span class="category2">substr</span>(0, len) + "<span class="quote">&lt;/b&gt;</span>";
 			<span class="category1">var</span> wid:<span class="category2">Number</span> = main_txt.<span class="category2">textWidth</span>;
 			main_txt.<span class="category2">htmlText</span> = "<span class="quote">&lt;b&gt;</span>" + w.<span class="category2">substr</span>(0, len) + "<span class="quote">&lt;/b&gt;</span>" + w.<span class="category2">substr</span>(len, w.<span class="category2">length</span>);
 			main_txt.<span class="category2">visible</span> = <span class="category1">true</span>;
 			textBG_mc.<span class="category2">width</span> = wid;
 			network_txt.<span class="category2">text</span> = c;
 			_word = w;
 		}</pre>
</code>

</div></div> 

<div style="text-align: left;">After those modifications are done (it might be a pain, sorry), we can see in the image below that the country was set:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img111.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img111.html','popup','width=268,height=81,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img11-thumb-268x81.png" width="268" height="81" alt="article14_img11.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Now I agree that this was a bit complicated and hard to follow. We have added two cool features that make the component much much more useful. Especially the new search feature looks more like the original facebook friend search. </div>

<div style="text-align: left;">We already worked on fonts. It would be neat if we could implement a feature where the user can use different fonts that fit into the environment of the application. For that we can apply a special fontFace property at the end of the SearchFriendField class. It looks like this:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

<span class="category1">public</span> <span class="category1">function</span> fontFace(e:<span class="category2">String</span>){
 	_fontFace = e;
 	invalidate();
}</pre>
</code>

</div></div> 

<div style="text-align: left;">
We simply set the font and after that we cann the invalidate method that will redraw the component. The draw() method is located in the MultiFriendField class and looks like this:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

override protected <span class="category1">function</span> draw():<span class="category1">void</span> {
 
 	<span class="linecomment">// always call super.draw() at the end</span>
 	<span class="category1">super</span>.draw();
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">This is how it looks like inside the MultiFriendField.as component. We will write the same inside the SearchFriendField.as class:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


override protected <span class="category1">function</span> draw():<span class="category1">void</span> {
 
 	<span class="linecomment">// always call super.draw() at the end</span>
 	<span class="category1">super</span>.draw();
 
 	<span class="linecomment">//do additional stuff here...</span>
 
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now, as soon as invalidate() is called, the following flow occurs:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img12.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img12.html','popup','width=300,height=418,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img12-thumb-300x418.png" width="300" height="418" alt="article14_img12.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">So, let's concentrate on the draw() function inside the SearchFriendsField() class. Here is the flow of how the methods get called inside the component:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img13.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img13.html','popup','width=477,height=285,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img13-thumb-400x238.png" width="400" height="238" alt="article14_img13.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Looks a bit complicated but actually it's not. In the draw function, the following happens:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

override protected <span class="category1">function</span> draw():<span class="category1">void</span> {
 
 	<span class="linecomment">// always call super.draw() at the end</span>
 	<span class="category1">super</span>.draw();
 
 	<span class="linecomment">//set new font face</span>
 	suggestClip.fontFace = _fontFace;
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Looking at the image above, we see that the next clip that needs to be called is SuggWord. And here is how this looks like inside SuggestClip:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


<span class="category1">public</span> <span class="category1">function</span> fontFace(e:<span class="category2">String</span>){
 	_fontFace = e;
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Please dont get confused, hold on! One thing we must consider here. We need to assign the fontFace to every WordButton and this will be done in the loop that creates the array of WordButtons:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


<span class="category1">public</span> <span class="category1">function</span> addWord(t:<span class="category2">String</span>, len:<span class="category2">Number</span>, country:<span class="category2">String</span>):<span class="category1">void</span>{
 			
 	_clipCounter++;
 			
 	<span class="category1">var</span> word_mc:<span class="category2">MovieClip</span> = <span class="category1">new</span> WordButton();
 	word_mc.<span class="category2">name</span> = "<span class="quote">field</span>" + _clipCounter;
 
 	word_mc.fontFace = _fontFace;
 	...</pre>
</code>

</div></div> 

<div style="text-align: left;">So, as we can see it in the image, every time the new WordButton is added the the display list, the new fontFace is assigned. Looking at the item here, we need to open WordButton as and add the same faceFont setter:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


<span class="category1">public</span> <span class="category1">function</span> fontFace(e:<span class="category2">String</span>){
 	_fontFace = e;
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now let's see it this actually works:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/06/article14_img14.html" onclick="window.open('http://www.insideria.com/assets_c/2009/06/article14_img14.html','popup','width=364,height=277,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://www.insideria.com/assets_c/2009/06/article14_img14-thumb-364x277.png" width="364" height="277" alt="article14_img14.png" class="mt-image-none" style="" /></a></span>
<br/>
<div style="text-align: left;">
Finally we got it. As we can see the complete architecture of the component is pretty complex it's not very easy to tweak things that live inside it.</div>

<div style="text-align: left;">In order not to confuse you, here are the codes of all the classes used:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


package facebookUI {
 
 	<span class="category1">import</span> flash.events.*;
 	<span class="category1">import</span> com.facebook.events.FacebookEvent;
 	<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoData;
 	<span class="category1">import</span> com.facebook.<span class="category2">data</span>.FacebookNetwork;
 
 	<span class="category1">public</span> <span class="category1">class</span> SearchFriendsField <span class="category1">extends</span> MultiFriendField{
  
  		protected <span class="category1">var</span> _fontFace:<span class="category2">String</span> = "<span class="quote">Arial</span>";
  
  		<span class="category1">function</span> SearchFriendsField(){
   			<span class="category2">trace</span>(<span class="category1">this</span> + "<span class="quote"> works...</span>");
   		}
  
  		override protected <span class="category1">function</span> draw():<span class="category1">void</span> {
   
   			<span class="linecomment">// always call super.draw() at the end</span>
   			<span class="category1">super</span>.draw();
   
   			_suggestClip.fontFace = _fontFace;
   
   		}
  
  		
  		override protected <span class="category1">function</span> textChanged(e:Event):<span class="category1">void</span> {
   
   			<span class="category1">var</span> <span class="category2">names</span>:<span class="category2">Array</span> = _inputField.<span class="category2">text</span>.<span class="category2">split</span>("<span class="quote">,</span>");
   			<span class="category1">var</span> <span class="category2">name</span>:<span class="category2">String</span> = <span class="category2">names</span>[<span class="category2">names</span>.<span class="category2">length</span> - 1];
   			<span class="category1">var</span> n:<span class="category2">Array</span> = <span class="category2">name</span>.<span class="category2">split</span>("<span class="quote"> </span>");
   			<span class="category1">var</span> firstName:<span class="category2">String</span> = n[0];
   			<span class="category1">var</span> lastName:<span class="category2">String</span> = n[1];
   
   			_suggestClip.suggest(trim(firstName));
   
   			<span class="category1">if</span>(lastName){
    				_suggestClip.suggest(trim(lastName));
    			}
   
   		}
  
  		
  		override protected <span class="category1">function</span> onDataRecieve(e:FacebookEvent){
    	
   			<span class="category1">var</span> userData = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
   			
   			<span class="category1">var</span> i;
   			<span class="category1">var</span> len = userData.<span class="category2">length</span>;
   		 
   			<span class="category1">for</span>(i = 0; i &lt; len; i++){
    				<span class="category1">var</span> user = userData.<span class="category2">getItemAt</span>(i);
    				_suggestClip.addWord(user.first_name + "<span class="quote"> </span>" + user.last_name + "<span class="quote"> </span>" + user.current_location.country);
    			}
    	
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> <span class="category1">set</span> fontFace(e:<span class="category2">String</span>):<span class="category1">void</span> {
   			_fontFace = e;
   			invalidate();
   		}
  
  	}
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">SuggestClip.as:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


package facebookUI{
 
 	<span class="category1">import</span> flash.display.*;
 	<span class="category1">import</span> flash.<span class="category2">text</span>.*;
 	<span class="category1">import</span> flash.events.*;
 
 	<span class="category1">public</span> <span class="category1">class</span> SuggestClip <span class="category1">extends</span> SnapClip{
  
  		<span class="category1">private</span> <span class="category1">var</span> _words:<span class="category2">Array</span> = <span class="category1">null</span>;
  		<span class="category1">private</span> <span class="category1">var</span> _wordSugg:<span class="category2">MovieClip</span> = <span class="category1">new</span> SuggWord();
  
  		protected <span class="category1">var</span> _fontFace:<span class="category2">String</span> = "<span class="quote">Arial</span>";
  		
  		<span class="category1">function</span> SuggestClip(){
   			<span class="category1">super</span>();
   			<span class="category1">this</span>.<span class="category2">visible</span> = <span class="category1">false</span>;
   			_words = <span class="category1">new</span> <span class="category2">Array</span>();
   			<span class="category1">this</span>.addChild(_wordSugg);
   		}
  
  
  
  		<span class="category1">private</span> <span class="category1">function</span> keyPressed(e:KeyboardEvent):<span class="category1">void</span> {
   
   			<span class="category1">if</span>(e.keyCode == 40){
    				_wordSugg.focusNext();
    			}
   
   			<span class="category1">if</span>(e.keyCode == 38){
    				_wordSugg.focusPrev();
    			}
   
   			<span class="category1">if</span>(e.keyCode == 13){
    				<span class="category1">var</span> word:<span class="category2">String</span> = _wordSugg.getWord();
    				<span class="category1">var</span> ex:SuperEvent = <span class="category1">new</span> SuperEvent("<span class="quote">wordClicked</span>", <span class="category1">true</span>, <span class="category1">true</span>);
    				ex.<span class="category1">add</span>("<span class="quote">word</span>", word);
    				dispatchEvent(ex);
    				<span class="category1">this</span>.<span class="category2">visible</span> = <span class="category1">false</span>;
    			}
   
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> activate():<span class="category1">void</span>{
   			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> deactivate():<span class="category1">void</span>{
   			<span class="category1">this</span>.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
   		}
  
  		<span class="category1">private</span> <span class="category1">function</span> getSimilarWords(typed:<span class="category2">String</span>){
   			
   			<span class="category1">this</span>.<span class="category2">visible</span> = <span class="category1">true</span>;
   			
   			_wordSugg.clearAll();
   			<span class="category1">var</span> w = _words;
   			<span class="category1">var</span> i = 0;
   			<span class="category1">var</span> len = w.<span class="category2">length</span>;
   
   			<span class="category1">for</span>(i = 0; i &lt; len; i++){
    
    				<span class="category1">var</span> currword:<span class="category2">String</span> = w[i];
    
    				<span class="category1">var</span> n:<span class="category2">Array</span> = currword.<span class="category2">split</span>("<span class="quote"> </span>");
    				<span class="category1">var</span> firstName:<span class="category2">String</span> = n[0];
    				<span class="category1">var</span> lastName:<span class="category2">String</span> = n[1];
    				<span class="category1">var</span> country:<span class="category2">String</span> = n[2];
    
    				<span class="category1">if</span>(typed.<span class="category2">toLowerCase</span>() == (firstName.<span class="category2">substr</span>(0, typed.<span class="category2">length</span>).<span class="category2">toLowerCase</span>())){
     					_wordSugg.addWord(n[0] + n[1], typed.<span class="category2">length</span>, country);
     				}
    
    				<span class="category1">if</span>(typed.<span class="category2">toLowerCase</span>() == (lastName.<span class="category2">substr</span>(0, typed.<span class="category2">length</span>).<span class="category2">toLowerCase</span>())){
     					_wordSugg.addWord(n[0] + n[1], typed.<span class="category2">length</span>, country);
     				}
    
    
    			}
   			<span class="category1">if</span>(i &gt; 0){
    				_wordSugg.focusFirst();
    			}
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> addWord(w:<span class="category2">String</span>):<span class="category1">void</span>{
   			_words.<span class="category2">push</span>(w);
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> suggest(typed:<span class="category2">String</span>):<span class="category1">void</span>{
   			
   			<span class="category1">if</span>(typed == "<span class="quote"></span>"){
    				_wordSugg.clearAll();
    				<span class="category1">return</span>;
    			}
   		
   			<span class="category1">var</span> similarWords = getSimilarWords(typed);
   
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> <span class="category1">set</span> fontFace(e:<span class="category2">String</span>):<span class="category1">void</span> {
   			_fontFace = e;
   			_wordSugg.fontFace = e;
   		}
  		
  	}
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">SuggWord.as:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>

package facebookUI{
 
 	<span class="category1">import</span> flash.display.*;
 	<span class="category1">import</span> flash.events.*;
 
 	<span class="category1">public</span> <span class="category1">class</span> SuggWord <span class="category1">extends</span> <span class="category2">MovieClip</span>{
  		
  		<span class="category1">private</span> <span class="category1">var</span> _focusIndex:<span class="category2">Number</span> = 0;
  		<span class="category1">private</span> <span class="category1">var</span> _currentWord:<span class="category2">String</span> = "<span class="quote"></span>";
  		<span class="category1">private</span> <span class="category1">var</span> _clipCounter:<span class="category2">Number</span> = 0;
  		<span class="category1">private</span> <span class="category1">var</span> _clips:<span class="category2">Object</span> = <span class="category1">new</span> <span class="category2">Object</span>();
  
  		protected <span class="category1">var</span> _fontFace:<span class="category2">String</span> = "<span class="quote">Arial</span>";
  		
  		<span class="category1">function</span> SuggWord(){
   			<span class="category1">super</span>();
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> clearAll():<span class="category1">void</span> {
   			<span class="category1">while</span> (<span class="category1">this</span>.numChildren){
    				<span class="category1">this</span>.removeChildAt(0);
    			}
   
   
   
   			_clips = <span class="category1">new</span> <span class="category2">Object</span>();
   			_clipCounter = 0;
   			_focusIndex = 0;
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> wordClicked(e:MouseEvent){
   
   			<span class="category1">var</span> clip = e.currentTarget;
   			dispatchWord(clip.getWord());
   			_focusIndex = 0;
   
   		}
  		
  		<span class="category1">private</span> <span class="category1">function</span> dispatchWord(word:<span class="category2">String</span>){
   			<span class="category1">var</span> e:SuperEvent = <span class="category1">new</span> SuperEvent("<span class="quote">wordClicked</span>", <span class="category1">true</span>, <span class="category1">true</span>);
   			e.<span class="category1">add</span>("<span class="quote">word</span>", word);
   			dispatchEvent(e);
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> addWord(t:<span class="category2">String</span>, len:<span class="category2">Number</span>, country:<span class="category2">String</span>):<span class="category1">void</span>{
   			
   			_clipCounter++;
   			
   			<span class="category1">var</span> word_mc:<span class="category2">MovieClip</span> = <span class="category1">new</span> WordButton();
   			word_mc.<span class="category2">name</span> = "<span class="quote">field</span>" + _clipCounter;
   
   			word_mc.fontFace = _fontFace;
   
   			_clips["<span class="quote">field</span>" + _clipCounter] = word_mc;
   
   			<span class="category1">this</span>.addChild(word_mc);
   			word_mc.setWord(t, len, country);
   
   			<span class="category1">var</span> clip = _clips["<span class="quote">field</span>" + (_clipCounter - 1)];
   			<span class="category1">var</span> prevClipExists = <span class="category2">Boolean</span>(clip);
   
   			<span class="category1">if</span>(prevClipExists){
    				word_mc.<span class="category2">y</span> = clip.<span class="category2">y</span> + clip.<span class="category2">height</span>;
    			} <span class="category1">else</span> {
    				word_mc.<span class="category2">y</span> = 1;	
    			}
   
   			word_mc.addEventListener(MouseEvent.CLICK, wordClicked);
   			
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> focusPrev():<span class="category1">void</span>{
   
   			<span class="category1">if</span>(_focusIndex == 0){
    				<span class="category1">return</span>;
    			}
   
   			_focusIndex--;
   	
   			<span class="category1">var</span> clip = _clips["<span class="quote">field</span>" + _focusIndex];
   			<span class="category1">var</span> clipExists = <span class="category2">Boolean</span>(clip);
   
   			<span class="category1">if</span>(clipExists){
    
    				clip.rolledOver(<span class="category1">new</span> MouseEvent(MouseEvent.ROLL_OVER));
    				_currentWord = clip.getWord();
    
    				<span class="category1">var</span> prevClip = _clips["<span class="quote">field</span>" + (_focusIndex + 1)];
    				<span class="category1">var</span> prevClipExists = <span class="category2">Boolean</span>(prevClip);
    
    				<span class="category1">if</span>(prevClipExists){
     					prevClip.rolledOut(<span class="category1">new</span> MouseEvent(MouseEvent.ROLL_OUT));
     				}
    
    
    
    				
    
    			}
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> focusNext():<span class="category1">void</span>{
   			
   			<span class="category1">if</span>(_focusIndex == (_clipCounter + 1)){
    				<span class="category1">return</span>;
    			}
   
   			<span class="category1">if</span>(_focusIndex == 0){
    				focusFirst();
    			}
   				
   			<span class="category1">var</span> clip = _clips["<span class="quote">field</span>" + _focusIndex];
   			<span class="category1">var</span> clipExists = <span class="category2">Boolean</span>(clip);
   
   			<span class="category1">if</span>(clipExists){
    
    
    
    				clip.rolledOver(<span class="category1">new</span> MouseEvent(MouseEvent.ROLL_OVER));
    				_currentWord = clip.getWord();
    
    				<span class="category1">var</span> prevClip = _clips["<span class="quote">field</span>" + (_focusIndex - 1)];
    				<span class="category1">var</span> prevClipExists = <span class="category2">Boolean</span>(prevClip);
    
    				<span class="category1">if</span>(prevClipExists){
     					prevClip.rolledOut(<span class="category1">new</span> MouseEvent(MouseEvent.ROLL_OUT));
     				}
    
    				_focusIndex++;
    
    			}
   
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> focusFirst():<span class="category1">void</span>{
   
   			_focusIndex = 1;
   			<span class="category1">var</span> clip = _clips["<span class="quote">field</span>" + _focusIndex];
   
   			<span class="category1">var</span> clipExists = <span class="category2">Boolean</span>(clip);
   			<span class="category1">if</span>(clipExists){
    				clip.rolledOver(<span class="category1">new</span> MouseEvent(MouseEvent.ROLL_OVER));
    				_currentWord = clip.getWord();
    			}
   
   
   
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> getWord():<span class="category2">String</span>{
   			<span class="category1">return</span> _currentWord;
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> <span class="category1">set</span> fontFace(e:<span class="category2">String</span>):<span class="category1">void</span> {
   			_fontFace = e;
   		}
  
  	}
 
}</pre>
</code>

</div></div> 

<div style="text-align: left;">WordButton.as:</div>

<div class="acode" style="overflow:auto;padding:10px;" ><div style="overflow-x: visible;">
<code language="perl">
<pre>


package facebookUI{
 
 	<span class="category1">import</span> flash.display.*;
 	<span class="category1">import</span> flash.events.*;
 	<span class="category1">import</span> flash.<span class="category2">text</span>.*;
 
 	<span class="category1">public</span> <span class="category1">class</span> WordButton <span class="category1">extends</span> <span class="category2">MovieClip</span>{
  		
  		<span class="category1">private</span> <span class="category1">var</span> _word:<span class="category2">String</span> = <span class="category1">null</span>;
  
  		<span class="category1">private</span> <span class="category1">var</span> _tf = <span class="category1">new</span> <span class="category2">TextFormat</span>();
  		
  		<span class="category1">function</span> WordButton(){
   			<span class="category1">super</span>();
   			<span class="category2">stop</span>();
   			<span class="category2">init</span>();
   		}
  		
  		<span class="category1">private</span> <span class="category1">function</span> <span class="category2">init</span>():<span class="category1">void</span>{
   			<span class="category1">this</span>.buttonMode = <span class="category1">false</span>;
   			textBG_mc.<span class="category2">width</span> = 0;
   			<span class="category1">this</span>.addEventListener(MouseEvent.ROLL_OVER, rolledOver);
   			<span class="category1">this</span>.addEventListener(MouseEvent.ROLL_OUT, rolledOut);
   			main_txt.defaultTextFormat = _tf;
   			network_txt.defaultTextFormat = _tf;
   			main_txt.<span class="category2">setTextFormat</span>(_tf);
   			network_txt.<span class="category2">setTextFormat</span>(_tf);
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> rolledOver(e:MouseEvent):<span class="category1">void</span> {
   			_tf.<span class="category2">color</span> = 0xffffff;
   			main_txt.defaultTextFormat = _tf;
   			network_txt.defaultTextFormat = _tf;
   			main_txt.<span class="category2">setTextFormat</span>(_tf);
   			network_txt.<span class="category2">setTextFormat</span>(_tf);
   			<span class="category1">this</span>.<span class="category2">gotoAndStop</span>(2);
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> rolledOut(e:MouseEvent):<span class="category1">void</span> {
   			_tf.<span class="category2">color</span> = 0x000000;
   			main_txt.defaultTextFormat = _tf;
   			network_txt.defaultTextFormat = _tf;
   			main_txt.<span class="category2">setTextFormat</span>(_tf);
   			network_txt.<span class="category2">setTextFormat</span>(_tf);
   			<span class="category1">this</span>.<span class="category2">gotoAndStop</span>(1);
   		}
  		
  		<span class="category1">public</span> <span class="category1">function</span> getWord():<span class="category2">String</span>{
   			<span class="category1">return</span> _word;
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> setWord(w:<span class="category2">String</span>, len:<span class="category2">Number</span>, c:<span class="category2">String</span>):<span class="category1">void</span>{
   			main_txt.<span class="category2">visible</span> = <span class="category1">false</span>;
   			main_txt.<span class="category2">htmlText</span> = "<span class="quote">&lt;b&gt;</span>" + w.<span class="category2">substr</span>(0, len) + "<span class="quote">&lt;/b&gt;</span>";
   			<span class="category1">var</span> wid:<span class="category2">Number</span> = main_txt.<span class="category2">textWidth</span>;
   			main_txt.<span class="category2">htmlText</span> = "<span class="quote">&lt;b&gt;</span>" + w.<span class="category2">substr</span>(0, len) + "<span class="quote">&lt;/b&gt;</span>" + w.<span class="category2">substr</span>(len, w.<span class="category2">length</span>);
   			main_txt.<span class="category2">visible</span> = <span class="category1">true</span>;
   			textBG_mc.<span class="category2">width</span> = wid;
   			network_txt.<span class="category2">text</span> = c;
   			_word = w;
   		}
  
  		<span class="category1">public</span> <span class="category1">function</span> <span class="category1">set</span> fontFace(e:<span class="category2">String</span>):<span class="category1">void</span> {
   			_tf.<span class="category2">font</span> = e;
   		}
  
  
  
  	}
 
}</pre>
</code>

</div></div> 

<p><br/>To view the entire series please visit <a href="http://www.insideria.com/series-facebook-dev.html">http://www.insideria.com/series-facebook-dev.html</a></p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37212-comment:2067925</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37212" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html#comment-2067925" />
    <title>Comment from RIA Mad on 2009-07-08</title>
    <author>
        <name>RIA Mad</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Really Great one.. </p>]]>
    </content>
    <published>2009-07-08T09:19:13Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37212-comment:2138683</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37212" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html#comment-2138683" />
    <title>Comment from Fun on 2009-10-13</title>
    <author>
        <name>Fun</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Great! reaaly very helpful</p>

<p>could you post the SuperEvent.as code.</p>

<p>Without that we can't run the sample :(</p>]]>
    </content>
    <published>2009-10-13T19:33:07Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37212-comment:2174294</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37212" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/07/search-friends-component.html#comment-2174294" />
    <title>Comment from brew norman on 2009-11-05</title>
    <author>
        <name>brew norman</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>another tutorial that DOESN'T WORK!!! wtf?</p>

<p>"The first step in this approach is to download the FLA that came provided with the 11th article."<br />
please let me know how to get this file to work. i downloaded it, opened it in  cs4 and i get these errors.  pretty lazy if you cant even get your own files provided to run!</p>

<p>google Emanuele Feronato , her tutorials work!!!</p>

<p>1017: The definition of base class UIComponent was not found.<br />
1020: Method marked override must override another method.<br />
5000: The class 'facebookUI.SearchFriendsField' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.<br />
5000: The class 'FacebookShim' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.<br />
5000: The class 'facebookUI.WordButton' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.<br />
5000: The class 'facebookUI.SuggestClip' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.</p>]]>
    </content>
    <published>2009-11-06T05:59:28Z</published>
  </entry>

</feed
