<?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/05/extended-profilepic-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.35908-</id>
  <updated>2009-11-16T14:59:19Z</updated>
  <title>Comments for Extended ProfilePic Component with Effects (http://www.insideria.com/2009/05/extended-profilepic-component.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2009://34.35908</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/05/extended-profilepic-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=35908" title="Extended ProfilePic Component with Effects" />
    <published>2009-05-26T13:00:00Z</published>
    <updated>2009-06-02T13:59:40Z</updated>
    <title>Extended ProfilePic Component with Effects</title>
    <summary>In this article we will extend the ProfilePic component from the last article and show example of how we can use it in real world scenarios. We will create a facebook application that asks the user a question about the displayed friend. Yes, it is in fact a copy of an existing application (I don&#8217;t remember the name and I don&#8217;t want to make advertising). The application simply switches from one question to another and associates the displayed friend with the question. Like, for ex., the question appears &#8220;Would you ever like to date Monica?&quot; and the application user can simply select between &#8220;Yes&#8221; of &#8220;No&#8221;. On the other side, you can choose if you want that the answer is send to the user as a notification. Personally I enjoyed the application and will use it as reference to make a flash version out of it. On the other side, we will use the component and add features to it so the sample will demonstrate how useful the component can be in the development process. We will have the freedom to create our own questions. They can be stored either in the database or XML, but in our case it will be stored in a flat XML file.</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;">In this article we will extend the ProfilePic component from the <a href="http://www.insideria.com/2009/05/profilepic-component.html" target="_blank">last article</a> and show example of how we can use it in real world scenarios. We will create a Facebook application that asks the user a question about the displayed friend. Yes, it is in fact a copy of an existing application (I don&#8217;t remember the name and I don&#8217;t want to make advertising). The application simply switches from one question to another and associates the displayed friend with the question. Like, for example, the question appears &#8220;Would you ever like to date Monica?" and the application user can simply select between &#8220;Yes&#8221; or &#8220;No&#8221;. On the other side, you can choose if you want the answer to be sent to the user as a notification. Personally I enjoyed the application and will use it as a reference to make a Flash version out of it. On the other side, we will use the component and add features to it so the sample will demonstrate how useful the component can be in the development process. We will have the freedom to create our own questions. They can be stored either in the database or XML, but in our case it will be stored in a flat XML file. </div>

<div class="ap_r"><a href="http://www.insideria.com/series-facebook-dev.html"><img src="http://www.insideria.com/upload/2009/04/fb_app_8.jpg" alt="series badge" style="width: 148px;" /></a><div class="apcaption">Find the rest of this series on the <a href="http://www.insideria.com/series-facebook-dev.html">series page</a>.</div></div>

<div style="text-align: left;">OK, now let&#8217;s move on and start with the development. First of all, we need to remember that we will use the same application like in the previous sample. We have the .fla ready, we have api key and we have the secret key and we have the ProfilePic component ready. We also have the DisplayStatus component, but in this sample, it does not have that much value so we will leave it out this time. Here is the final picture of the application:</div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img131.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img131.html','popup','width=467,height=264,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/04/article8_img13-thumb-400x226.png" width="400" height="226" alt="article8_img13.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">The task of creating such an app may seem a bit overwhelming, but it's not that difficult. Not easy, but also not too difficult. Once we define our question, we will store it in an XML file. Then, our Facebook swf will load the XML. The questions will be shuffled and the array of friends will be loaded. One question will be associated with one randomly selected friend and the application user will answer with yes or no.</div>

<div style="text-align: left;">Open the .fla we previously worked on and remove all instances of the components from the stage. </div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img11.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img11.html','popup','width=599,height=482,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/04/article8_img1-thumb-400x321.jpg" width="400" height="321" alt="article8_img1.jpg" class="mt-image-none" style="" /></a></span>
<br/>
<div style="text-align: left;">Also, remove all the ActionScript we worked on. OK, for now leave the Flash IDE we need to make sure the XML file is created. Because the application will be some sort of a quiz, the XML will consist only of questions. So here is the XML structure:</div>

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

&lt;?xml <span class="category2">version</span>='<span class="quote">1.0</span>'?&gt;
&lt;questions&gt;
	&lt;question&gt;Would you like to kiss (friend)?&lt;/question&gt;
	&lt;question&gt;Would you like to live <span class="category1">with</span> (friend) <span class="category1">on</span> a lone island?&lt;/question&gt;
	&lt;question&gt;Would you like to marry (friend)?&lt;/question&gt;
&lt;/questions&gt;</pre>
</code>

</div></div> 

<div style="text-align: left;">Open you favorite XML / plain text editor and paste it. You can add as many questions as you want. Just make sure they are inside the <question> nodes. Notice the (friend) placeholder inside every question? We will use it later in the application to replace it with actual names of friends. So the question will not appear like: </div>

<div style="text-align: left;">Would you like to marry (friend)?</div>

<div style="text-align: left;">Instead it will appear like:</div>

<div style="text-align: left;">Would you like to marry Monica?</div>
<div style="text-align: left;">Beside that, the ProfilePic component will appear and display the image of the user. Yeah! </div>

<div style="text-align: left;">OK, save the XML file we just created in the root folder of our standard Facebook app. </div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img2.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img2.html','popup','width=563,height=144,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/04/article8_img2-thumb-400x102.png" width="400" height="102" alt="article8_img2.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Save it as &#8220;questions.xml&#8221;. Since the XML is ready to go, we can go back to the Flash IDE and handle to loading of the XML content in our swf file. </div>

<div style="text-align: left;">Go to the first frame and paste the following code:</div>

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

<span class="category1">import</span> flash.net.URLLoader;
<span class="category1">import</span> flash.net.URLRequest;
<span class="category1">import</span> flash.xml.*;
<span class="category1">import</span> flash.events.*;
<span class="category1">import</span> flash.errors.*;

<span class="category1">var</span> mainXML:<span class="category2">XML</span>;
<span class="category1">var</span> loader:URLLoader = <span class="category1">new</span> URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.<span class="category2">load</span>(<span class="category1">new</span> URLRequest("<span class="quote">questions.xml</span>"));

<span class="category1">function</span> onComplete(evt:Event){
 	
     mainXML = <span class="category1">new</span> <span class="category2">XML</span>(loader.<span class="category2">data</span>)
     <span class="category2">trace</span>("<span class="quote">xml loaded, start working with data&amp;#133;</span>");
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">There is really no need to explain those few lines of code a lot. First we import the classes needed for connecting to URL destinations and for working with XML. </div>

<div style="text-align: left;">Hold on (you might say)! Yes, there is an error here: </div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img3.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img3.html','popup','width=458,height=243,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/04/article8_img3-thumb-400x212.png" width="400" height="212" alt="article8_img3.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">and it says something about security. Hmm, the XML file that is located in the same folder like the swf cannot be loaded? It&#8217;s strange, but because of the various restrictions Facebook placed on the applications, there must be a workaround to load the XML data. And the workaround is AMFPHP from the previous articles! Now we can see how cool it is when we are proficient in many areas, not only ActionScript. In order for the XML to load, we need to create a small PHP class file with a method to load XML. This method will simply be called from the swf and we will bypass the security restriction. </div>

<div style="text-align: left;">Let&#8217;s see how it is done.  Since we know that we need to work with AMFPHP, we need to make sure that the libraries are there. Remember the articles where we worked with AMFPHP? Because we work on the same application, the AMFPHP library is still there and we do not need to set it up again. Cool, in the folder amfphp/services we should have the class &#8220;FBServices&#8221;. Remove all the methods from it and just leave the constructor. We only need to method for loading the xml and passing it to flash, so paste this method below the constructor:</div>

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

<span class="category1">function</span> loadXML($file){
 	$myFile = "<span class="quote">../../</span>".$file;
 	$fh = fopen($myFile, '<span class="quote">r</span>');
 	$theData = fread($fh, filesize($myFile));
 	fclose($fh);
 	<span class="category1">return</span> $theData;
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now upload the class file to the services folder (amfphp/services). Now load the class browser via http://www.myserver.com/yourAppName/amfphp/browser/.</div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img4.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img4.html','popup','width=241,height=185,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/04/article8_img4-thumb-241x185.png" width="241" height="185" alt="article8_img4.png" class="mt-image-none" style="" /></a></span>
<br/>
<div style="text-align: left;">Now click on the FBServices class and click on the loadXML method. We can see there is a text field where we can enter the parameter for the questions. So in that field we will enter &#8220;questions.xml&#8221;:</div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img5.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img5.html','popup','width=308,height=105,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/04/article8_img5-thumb-308x105.png" width="308" height="105" alt="article8_img5.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">When you press questions.xml we finally see the result in the browser window:</div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img6.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img6.html','popup','width=474,height=158,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/04/article8_img6-thumb-400x133.png" width="400" height="133" alt="article8_img6.png" class="mt-image-none" style="" /></a></span>
<br/>
<div style="text-align: left;">We need to keep in mind that this is just plain text. Now our goal is to load it directly from flash. Here is how the code looks like using ActionScript:</div>

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

<span class="category1">var</span> gateway:<span class="category2">NetConnection</span> = <span class="category1">new</span> <span class="category2">NetConnection</span>();
<span class="category1">var</span> responder:Responder = <span class="category1">new</span> Responder(onResult, onFault);

gateway.<span class="category2">connect</span>("<span class="quote">http://www.yourserver.com/yourApp/amfphp/gateway.php</span>");
gateway.<span class="category2">call</span>("<span class="quote">FBServices.loadXML</span>", responder, "<span class="quote">questions.xml</span>");
 
<span class="category1">function</span> onResult(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">trace</span> ("<span class="quote">onResult: </span>" + responds)
}
 
<span class="category1">function</span> onFault(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">trace</span>("<span class="quote">fault </span>" + responds.description);
}</pre>
</code>

</div></div> 

<div style="text-align: left;">When the swf is uploaded, we can see the xml in the ouput window:</div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img7.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img7.html','popup','width=459,height=309,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/04/article8_img7-thumb-400x269.png" width="400" height="269" alt="article8_img7.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">
Cool! We are now ready to parse the XML since we skipped the security check here. There are plenty of ways to handle XML in ActionScript but in order to do that we first need to create a separate function:</div>

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

<span class="category1">function</span> <span class="category2">parseXML</span>(xmlStr:<span class="category2">String</span>):<span class="category1">void</span>{
 	
 	mainXML = <span class="category1">new</span> XMLDocument();
 	mainXML.<span class="category2">ignoreWhite</span> = <span class="category1">true</span>;
 	mainXML.<span class="category2">parseXML</span>(xmlStr);
 	
 	<span class="category1">var</span> xmlQ:<span class="category2">Array</span> = mainXML.<span class="category2">firstChild</span>.<span class="category2">childNodes</span>;
 	<span class="category1">var</span> i = 0;
 	<span class="category1">var</span> len = xmlQ.<span class="category2">length</span>;
 	
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  		
  		questions.<span class="category2">push</span>(xmlQ[i].<span class="category2">firstChild</span>.<span class="category2">toString</span>());
  		
  	}
 	
 	<span class="category2">trace</span>("<span class="quote">questions: </span>" + questions);
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Bur first, in order for the function to work, we need to define the mainXML variable and the question array. So, in order not to get confused, here is the complete code from the first frame:</div>

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

<span class="category1">import</span> flash.net.URLLoader;
<span class="category1">import</span> flash.net.URLRequest;
<span class="category1">import</span> flash.xml.*;
<span class="category1">import</span> flash.events.*;
<span class="category1">import</span> flash.errors.*;

<span class="category1">var</span> mainXML:XMLDocument = <span class="category1">new</span> XMLDocument();

<span class="category1">var</span> questions:<span class="category2">Array</span> = <span class="category1">new</span> <span class="category2">Array</span>();

<span class="category1">var</span> gateway:<span class="category2">NetConnection</span> = <span class="category1">new</span> <span class="category2">NetConnection</span>();
<span class="category1">var</span> responder:Responder = <span class="category1">new</span> Responder(onResult, onFault);

gateway.<span class="category2">connect</span>("<span class="quote">http://www.yourserver.com/yourApp/amfphp/gateway.php</span>");
gateway.<span class="category2">call</span>("<span class="quote">FBServices.loadXML</span>", responder, "<span class="quote">questions.xml</span>");
 
<span class="category1">function</span> onResult(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">parseXML</span>(responds.<span class="category2">toString</span>());
}
 
<span class="category1">function</span> onFault(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">trace</span>("<span class="quote">fault </span>" + responds.description);
}

<span class="category1">function</span> <span class="category2">parseXML</span>(xmlStr:<span class="category2">String</span>):<span class="category1">void</span>{
 	
 	mainXML = <span class="category1">new</span> XMLDocument();
 	mainXML.<span class="category2">ignoreWhite</span> = <span class="category1">true</span>;
 	mainXML.<span class="category2">parseXML</span>(xmlStr);
 	
 	<span class="category1">var</span> xmlQ:<span class="category2">Array</span> = mainXML.<span class="category2">firstChild</span>.<span class="category2">childNodes</span>;
 	<span class="category1">var</span> i = 0;
 	<span class="category1">var</span> len = xmlQ.<span class="category2">length</span>;
 	
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  		
  		questions.<span class="category2">push</span>(xmlQ[i].<span class="category2">firstChild</span>.<span class="category2">toString</span>());
  		
  	}
 	
 	<span class="category2">trace</span>("<span class="quote">questions: </span>" + questions);
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now, when the swf is compiled and the uploaded, we can see that the array is of questions is loaded:</div>

questions: Would you like to kiss (friend)?,Would you like to live with (friend) on a lone island?,Would you like to marry (friend)?

<div style="text-align: left;">Cool! Until now we did a great job. We loaded the xml and parsed the xml. We stripped the unnecessary xml nodes from the strings and the result of the hard work is an array of pure questions. Now, since we have our questions ready, we have to take care of other things. Now we need to load the list of friends we have. For that, we will have the look at the <a href="http://www.insideria.com/2009/05/using-the-brand-new-facebook-a.html" target="_blank">5th article</a>. The goal here is to load the collection of friends with all the data (uid, first name, last name, etc.) and to associate it with one random question. So here is the code to load the friends. First import the fancy Facebook classes:</div>

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

<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoData;
<span class="category1">import</span> com.facebook.utils.FacebookSessionUtil;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.FacebookUser;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoFieldValues;
<span class="category1">import</span> com.facebook.commands.users.GetInfo;
<span class="category1">import</span> com.facebook.commands.friends.*;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.friends.*;
<span class="category1">import</span> com.facebook.net.FacebookCall;
<span class="category1">import</span> com.facebook.events.FacebookEvent;
<span class="category1">import</span> com.facebook.Facebook;

&lt;div style="<span class="quote">text-align: left;</span>"&gt;Then, we define the variables somewhere at the top of the code:&lt;/div&gt;

<span class="category1">var</span> fbook:Facebook;
<span class="category1">var</span> session:FacebookSessionUtil;
<span class="category1">var</span> user:FacebookUser;</pre>
</code>

</div></div> 

And then we can start the Facebook session:

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

session = <span class="category1">new</span> FacebookSessionUtil("<span class="quote">YOUR_API_KEY</span>", "<span class="quote">YOUR_SECRET</span>", loaderInfo);
fbook = session.facebook;</pre>
</code>

</div></div> 

<div style="text-align: left;">Now we call the friends right after the xml is loeded, so in the parseXML question, after the xml parsing, place the following code:</div>

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

<span class="category1">var</span> <span class="category2">call</span>:GetFriends = <span class="category1">new</span> GetFriends();
<span class="category2">call</span>.addEventListener(FacebookEvent.COMPLETE, onFriends);
fbook.post(<span class="category2">call</span>);</pre>
</code>

</div></div> 

<div style="text-align: left;">We receive the user ids in the onFriends function:</div>

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

<span class="category1">function</span> onFriends(e:FacebookEvent):<span class="category1">void</span>{
 	
 	<span class="category1">var</span> friendsData = (e.<span class="category2">data</span> as GetFriendsData);
 	<span class="category1">var</span> friends = friendsData.friends;
 	
 	<span class="category1">var</span> i;
 	<span class="category1">var</span> len = friends.<span class="category2">length</span>;
 	<span class="category1">var</span> uids:<span class="category2">Array</span> = <span class="category1">new</span> <span class="category2">Array</span>();
 		
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  			
  		<span class="category1">var</span> user = friends.<span class="category2">getItemAt</span>(i) as FacebookUser;
  		uids.<span class="category2">push</span>(user.uid);
  			
  	}
 		
 	<span class="category1">var</span> <span class="category2">call</span>:FacebookCall = fbook.post(<span class="category1">new</span> GetInfo(uids, [GetInfoFieldValues.ALL_VALUES]));
 	<span class="category2">call</span>.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
     fbook.post(<span class="category2">call</span>);
 
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Just like in the <a href="http://www.insideria.com/2009/05/using-the-brand-new-facebook-a.html" target="_blank">5th article</a>, after the user ids are loaded, we call the getInfo function to retrieve the info of all friends and receive the data in the following function:</div>

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

<span class="category1">function</span> onDataRecieve(e:FacebookEvent){
 	
 	users = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
 
 	<span class="category2">trace</span>(&amp;#8220;users: &amp;#8221; + users);
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">This is a very important step, so in order not the get confused, here is the complete code from the first frame:</div>

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

<span class="category1">import</span> flash.net.URLLoader;
<span class="category1">import</span> flash.net.URLRequest;
<span class="category1">import</span> flash.xml.*;
<span class="category1">import</span> flash.events.*;
<span class="category1">import</span> flash.errors.*;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoData;
<span class="category1">import</span> com.facebook.utils.FacebookSessionUtil;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.FacebookUser;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoFieldValues;
<span class="category1">import</span> com.facebook.commands.users.GetInfo;
<span class="category1">import</span> com.facebook.commands.friends.*;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.friends.*;
<span class="category1">import</span> com.facebook.net.FacebookCall;
<span class="category1">import</span> com.facebook.events.FacebookEvent;
<span class="category1">import</span> com.facebook.Facebook;

<span class="category1">var</span> fbook:Facebook;
<span class="category1">var</span> session:FacebookSessionUtil;
<span class="category1">var</span> user:FacebookUser;

session = <span class="category1">new</span> FacebookSessionUtil("<span class="quote">YOUR_API_KEY</span>", "<span class="quote">YOUR_SECRET</span>",loaderInfo);
fbook = session.facebook;

<span class="category1">var</span> mainXML:XMLDocument = <span class="category1">new</span> XMLDocument();

<span class="category1">var</span> questions:<span class="category2">Array</span> = <span class="category1">new</span> <span class="category2">Array</span>();
<span class="category1">var</span> users;

<span class="category1">var</span> gateway:<span class="category2">NetConnection</span> = <span class="category1">new</span> <span class="category2">NetConnection</span>();
<span class="category1">var</span> responder:Responder = <span class="category1">new</span> Responder(onResult, onFault);

gateway.<span class="category2">connect</span>("<span class="quote">http://www.yourserver.com/yourApp/amfphp/gateway.php</span>");
gateway.<span class="category2">call</span>("<span class="quote">FBServices.loadXML</span>", responder, "<span class="quote">questions.xml</span>");
 
<span class="category1">function</span> onResult(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">parseXML</span>(responds.<span class="category2">toString</span>());
}
 
<span class="category1">function</span> onFault(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">trace</span>("<span class="quote">fault </span>" + responds.description);
}

<span class="category1">function</span> <span class="category2">parseXML</span>(xmlStr:<span class="category2">String</span>):<span class="category1">void</span>{
 	
 	mainXML = <span class="category1">new</span> XMLDocument();
 	mainXML.<span class="category2">ignoreWhite</span> = <span class="category1">true</span>;
 	mainXML.<span class="category2">parseXML</span>(xmlStr);
 	
 	<span class="category1">var</span> xmlQ:<span class="category2">Array</span> = mainXML.<span class="category2">firstChild</span>.<span class="category2">childNodes</span>;
 	<span class="category1">var</span> i = 0;
 	<span class="category1">var</span> len = xmlQ.<span class="category2">length</span>;
 	
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  		
  		questions.<span class="category2">push</span>(xmlQ[i].<span class="category2">firstChild</span>.<span class="category2">toString</span>());
  		
  	}
 	
 	<span class="category1">var</span> <span class="category2">call</span>:GetFriends = <span class="category1">new</span> GetFriends();
 	<span class="category2">call</span>.addEventListener(FacebookEvent.COMPLETE, onFriends);
 	fbook.post(<span class="category2">call</span>);
 	
}

<span class="category1">function</span> onFriends(e:FacebookEvent):<span class="category1">void</span>{
 	
 	<span class="category1">var</span> friendsData = (e.<span class="category2">data</span> as GetFriendsData);
 	<span class="category1">var</span> friends = friendsData.friends;
 	
 	<span class="category1">var</span> i;
 	<span class="category1">var</span> len = friends.<span class="category2">length</span>;
 	<span class="category1">var</span> uids:<span class="category2">Array</span> = <span class="category1">new</span> <span class="category2">Array</span>();
 		
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  			
  		<span class="category1">var</span> user = friends.<span class="category2">getItemAt</span>(i) as FacebookUser;
  		uids.<span class="category2">push</span>(user.uid);
  			
  	}
 		
 	<span class="category1">var</span> <span class="category2">call</span>:FacebookCall = fbook.post(<span class="category1">new</span> GetInfo(uids, [GetInfoFieldValues.ALL_VALUES]));
 	<span class="category2">call</span>.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
     fbook.post(<span class="category2">call</span>);
 
 	
}

<span class="category1">function</span> onDataRecieve(e:FacebookEvent){
 	
 	users = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
 
 	<span class="category2">trace</span>("<span class="quote">users: </span>" + users);
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">So now the next step here is somehow to associate the question with the user. Pick one user, pick one question and display it on the screen, as simple as that. But for this to happen, we will need to create a movieclip containing the profile pic, the question and the buttons. This is pretty straightforward. Go back to the Flash IDE and create a new movieclip via Insert -> New Symbol. Create the new movieclip called QuestionHolder:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img8.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img8.html','popup','width=442,height=170,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/04/article8_img8-thumb-400x153.png" width="400" height="153" alt="article8_img8.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Now, the Flash IDE will take you automatically to the timeline of the movieclip. Create two layers. The above one Actions the lower one Components:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img9.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img9.html','popup','width=342,height=172,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/04/article8_img9-thumb-342x172.png" width="342" height="172" alt="article8_img9.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Place the ProfilePicDisplay component to the stage. </div>
<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img10.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img10.html','popup','width=503,height=435,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/04/article8_img10-thumb-400x345.png" width="400" height="345" alt="article8_img10.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">
Name it profilePic_mc in the property inspector. Next to that component, place a dynamic text field right beside the profile pic component and name it  q_txt. Place two buttons below the text field. Label it Yes and No respectively and name them yes_btn and no_btn in the property inspector respectively. </div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img111.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img111.html','popup','width=446,height=267,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/04/article8_img11-thumb-400x239.png" width="400" height="239" alt="article8_img11.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Place the following code to the first frame of this movieclip:</div>

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

<span class="category1">import</span> com.facebook.Facebook;

<span class="category1">function</span> setQuestion(uid:<span class="category2">Number</span>, question:<span class="category2">String</span>, fBook:Facebook){
 	profilePic_mc.<span class="category2">load</span>(fBook, uid);
 	q_txt.<span class="category2">text</span> = question;
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now go back to the main timeline and paste the following function below all code:</div>

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

<span class="category1">function</span> setQuestion(){
 	
 	<span class="category1">var</span> randUserNum = <span class="category2">Math</span>.<span class="category2">round</span>(<span class="category2">Math</span>.<span class="category2">random</span>() * users.<span class="category2">length</span>);
 	<span class="category1">var</span> uid = (users.<span class="category2">getItemAt</span>(randUserNum)).uid;
 	<span class="category1">var</span> randQNum = <span class="category2">Math</span>.<span class="category2">round</span>(<span class="category2">Math</span>.<span class="category2">random</span>() * questions.<span class="category2">length</span>);
 	<span class="category1">var</span> question = questions[randQNum];
 	qHolder_mc.setQuestion(uid, question, fbook);
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">This function needs to be called as soon as the friends and questions are loaded: </div>

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

<span class="category1">function</span> onDataRecieve(e:FacebookEvent){
 	users = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
 	setQuestion();
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now compile the swf and upload it to the server. When we call the app in Facebook, we see something similar to this:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img12.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img12.html','popup','width=474,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/04/article8_img12-thumb-400x233.png" width="400" height="233" alt="article8_img12.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">Cool, still there is something missing, the (friend) placeholder is still there and needs to be replaced. Add the function below in the main timeline:</div>

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

<span class="category1">function</span> replacePlaceHolder(str:<span class="category2">String</span>, <span class="category2">name</span>:<span class="category2">String</span>){
 	<span class="category1">var</span> <span class="category2">index</span>:<span class="category2">Number</span> = str.<span class="category2">indexOf</span>("<span class="quote">(friend)</span>");
 	<span class="category1">var</span> firstChunk = str.<span class="category2">substr</span>(0, <span class="category2">index</span> - 1);
 	<span class="category1">var</span> secondChunk = str.<span class="category2">substr</span>(<span class="category2">index</span> + 9, str.<span class="category2">length</span>);
 	<span class="category1">var</span> sentence = firstChunk + "<span class="quote"> </span>" + <span class="category2">name</span> + "<span class="quote"> </span>" + secondChunk;
 	<span class="category1">return</span> sentence;
}</pre>
</code>

</div></div>

<div style="text-align: left;">And the setQuestion function needs a slight modification:</div>

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

<span class="category1">function</span> setQuestion(){
 	
 	<span class="category1">var</span> randUserNum = <span class="category2">Math</span>.<span class="category2">round</span>(<span class="category2">Math</span>.<span class="category2">random</span>() * users.<span class="category2">length</span>);
 	<span class="category1">var</span> uid = (users.<span class="category2">getItemAt</span>(randUserNum)).uid;
 	<span class="category1">var</span> firstName = (users.<span class="category2">getItemAt</span>(randUserNum)).first_name;
 	<span class="category1">var</span> randQNum = <span class="category2">Math</span>.<span class="category2">round</span>(<span class="category2">Math</span>.<span class="category2">random</span>() * questions.<span class="category2">length</span>);
 	<span class="category1">var</span> question = replacePlaceHolder(questions[randQNum], firstName);
 	qHolder_mc.setQuestion(uid, question, fbook);
 	
}</pre>
</code>

</div></div> 

<div style="text-align: left;">This is cool! Now when we run this sample in the Facebook canvas, we see the actual name of the friend in the question:</div>

<br/>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.insideria.com/assets_c/2009/04/article8_img13.html" onclick="window.open('http://www.insideria.com/assets_c/2009/04/article8_img13.html','popup','width=467,height=264,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/04/article8_img13-thumb-400x226.png" width="400" height="226" alt="article8_img13.png" class="mt-image-none" style="" /></a></span>
<br/>

<div style="text-align: left;">The only thing that is left here to do is to modify to make the buttons work. Here how it is done. Go to the QuestionHolder movieclip and place the following actions in the timeline:</div>

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

yes_btn.addEventListener(MouseEvent.CLICK, yesClicked);
no_btn.addEventListener(MouseEvent.CLICK, noClicked);

<span class="category1">function</span> yesClicked(e:MouseEvent):<span class="category1">void</span>{
 	dispatchEvent(<span class="category1">new</span> Event("<span class="quote">yesClicked</span>"));
}

<span class="category1">function</span> noClicked(e:MouseEvent):<span class="category1">void</span>{
 	dispatchEvent(<span class="category1">new</span> Event("<span class="quote">noClicked</span>"));
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Go back to the main timeline and place this script at the bottom:</div>

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

qHolder_mc.addEventListener("<span class="quote">yesClicked</span>", yesClicked);
qHolder_mc.addEventListener("<span class="quote">noClicked</span>", noClicked);

<span class="category1">function</span> yesClicked(e:Event):<span class="category1">void</span>{
 	<span class="linecomment">//do something before moving on...</span>
 	setQuestion();
}

<span class="category1">function</span> noClicked(e:Event):<span class="category1">void</span>{
 	<span class="linecomment">//do something before moving on...</span>
 	setQuestion();
}</pre>
</code>

</div></div>

<div style="text-align: left;">Now when the swf is compiled and uploaded a new friend / question pair appears. </div>

<div style="text-align: left;">Here is the complete code from the main timeline:</div>

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

<span class="category1">import</span> flash.net.URLLoader;
<span class="category1">import</span> flash.net.URLRequest;
<span class="category1">import</span> flash.xml.*;
<span class="category1">import</span> flash.events.*;
<span class="category1">import</span> flash.errors.*;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoData;
<span class="category1">import</span> com.facebook.utils.FacebookSessionUtil;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.FacebookUser;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.users.GetInfoFieldValues;
<span class="category1">import</span> com.facebook.commands.users.GetInfo;
<span class="category1">import</span> com.facebook.commands.friends.*;
<span class="category1">import</span> com.facebook.<span class="category2">data</span>.friends.*;
<span class="category1">import</span> com.facebook.net.FacebookCall;
<span class="category1">import</span> com.facebook.events.FacebookEvent;
<span class="category1">import</span> com.facebook.Facebook;

<span class="category1">var</span> fbook:Facebook;
<span class="category1">var</span> session:FacebookSessionUtil;
<span class="category1">var</span> user:FacebookUser;

session = <span class="category1">new</span> FacebookSessionUtil("<span class="quote">YOUR_API_KEY</span>", "<span class="quote">YOUR_SECRET</span>",loaderInfo);
fbook = session.facebook;

<span class="category1">var</span> mainXML:XMLDocument = <span class="category1">new</span> XMLDocument();

<span class="category1">var</span> questions:<span class="category2">Array</span> = <span class="category1">new</span> <span class="category2">Array</span>();
<span class="category1">var</span> users;

<span class="category1">var</span> gateway:<span class="category2">NetConnection</span> = <span class="category1">new</span> <span class="category2">NetConnection</span>();
<span class="category1">var</span> responder:Responder = <span class="category1">new</span> Responder(onResult, onFault);

gateway.<span class="category2">connect</span>("<span class="quote">http://www.yourserver.com/yourApp/amfphp/gateway.php</span>");
gateway.<span class="category2">call</span>("<span class="quote">FBServices.loadXML</span>", responder, "<span class="quote">questions.xml</span>");
 
<span class="category1">function</span> onResult(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">parseXML</span>(responds.<span class="category2">toString</span>());
}
 
<span class="category1">function</span> onFault(responds:<span class="category2">Object</span>):<span class="category1">void</span> {
 	<span class="category2">trace</span>("<span class="quote">fault </span>" + responds.description);
}

<span class="category1">function</span> <span class="category2">parseXML</span>(xmlStr:<span class="category2">String</span>):<span class="category1">void</span>{
 	
 	mainXML = <span class="category1">new</span> XMLDocument();
 	mainXML.<span class="category2">ignoreWhite</span> = <span class="category1">true</span>;
 	mainXML.<span class="category2">parseXML</span>(xmlStr);
 	
 	<span class="category1">var</span> xmlQ:<span class="category2">Array</span> = mainXML.<span class="category2">firstChild</span>.<span class="category2">childNodes</span>;
 	<span class="category1">var</span> i = 0;
 	<span class="category1">var</span> len = xmlQ.<span class="category2">length</span>;
 	
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  		
  		questions.<span class="category2">push</span>(xmlQ[i].<span class="category2">firstChild</span>.<span class="category2">toString</span>());
  		
  	}
 	
 	<span class="category1">var</span> <span class="category2">call</span>:GetFriends = <span class="category1">new</span> GetFriends();
 	<span class="category2">call</span>.addEventListener(FacebookEvent.COMPLETE, onFriends);
 	fbook.post(<span class="category2">call</span>);
 	
}

<span class="category1">function</span> onFriends(e:FacebookEvent):<span class="category1">void</span>{
 	<span class="category1">var</span> friendsData = (e.<span class="category2">data</span> as GetFriendsData);
 	<span class="category1">var</span> friends = friendsData.friends;
 	<span class="category1">var</span> i;
 	<span class="category1">var</span> len = friends.<span class="category2">length</span>;
 	<span class="category1">var</span> uids:<span class="category2">Array</span> = <span class="category1">new</span> <span class="category2">Array</span>();
 	<span class="category1">for</span>(i = 0; i &lt; len; i++){
  		<span class="category1">var</span> user = friends.<span class="category2">getItemAt</span>(i) as FacebookUser;
  		uids.<span class="category2">push</span>(user.uid);
  	}
 	
 	<span class="category1">var</span> <span class="category2">call</span>:FacebookCall = fbook.post(<span class="category1">new</span> GetInfo(uids, [GetInfoFieldValues.ALL_VALUES]));
 	<span class="category2">call</span>.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
     fbook.post(<span class="category2">call</span>);
 	
}

<span class="category1">function</span> onDataRecieve(e:FacebookEvent){
 	users = ((e.<span class="category2">data</span> as GetInfoData).userCollection);
 	setQuestion();
}

<span class="category1">function</span> setQuestion(){
 	
 	<span class="category1">var</span> randUserNum = <span class="category2">Math</span>.<span class="category2">round</span>(<span class="category2">Math</span>.<span class="category2">random</span>() * users.<span class="category2">length</span>) - 1;
 	<span class="category1">var</span> uid = (users.<span class="category2">getItemAt</span>(randUserNum)).uid;
 	<span class="category1">var</span> firstName = (users.<span class="category2">getItemAt</span>(randUserNum)).first_name;
 	<span class="category1">var</span> randQNum = <span class="category2">Math</span>.<span class="category2">round</span>(<span class="category2">Math</span>.<span class="category2">random</span>() * questions.<span class="category2">length</span>) - 1;
 	<span class="category1">var</span> question = replacePlaceHolder(questions[randQNum], firstName);
 	qHolder_mc.setQuestion(uid, question, fbook);
 	
}

<span class="category1">function</span> replacePlaceHolder(str:<span class="category2">String</span>, <span class="category2">name</span>:<span class="category2">String</span>){
 	<span class="category1">var</span> <span class="category2">index</span>:<span class="category2">Number</span> = str.<span class="category2">indexOf</span>("<span class="quote">(friend)</span>");
 	<span class="category1">var</span> firstChunk = str.<span class="category2">substr</span>(0, <span class="category2">index</span> - 1);
 	<span class="category1">var</span> secondChunk = str.<span class="category2">substr</span>(<span class="category2">index</span> + 9, str.<span class="category2">length</span>);
 	<span class="category1">var</span> sentence = firstChunk + "<span class="quote"> </span>" + <span class="category2">name</span> + "<span class="quote"> </span>" + secondChunk;
 	<span class="category1">return</span> sentence;
}

qHolder_mc.addEventListener("<span class="quote">yesClicked</span>", yesClicked);
qHolder_mc.addEventListener("<span class="quote">noClicked</span>", noClicked);

<span class="category1">function</span> yesClicked(e:Event):<span class="category1">void</span>{
 	<span class="linecomment">//do something before moving on...</span>
 	setQuestion();
}

<span class="category1">function</span> noClicked(e:Event):<span class="category1">void</span>{
 	<span class="linecomment">//do something before moving on...</span>
 	setQuestion();
}

&lt;div style="<span class="quote">text-align: left;</span>"&gt;And here is the code from the QuestionHolder first frame:&lt;/div&gt;

<span class="category1">import</span> com.facebook.Facebook;

<span class="category1">function</span> setQuestion(uid:<span class="category2">Number</span>, question:<span class="category2">String</span>, fBook:Facebook){
 	profilePic_mc.<span class="category2">load</span>(fBook, uid);
 	q_txt.<span class="category2">text</span> = question;
}

yes_btn.addEventListener(MouseEvent.CLICK, yesClicked);
no_btn.addEventListener(MouseEvent.CLICK, noClicked);

<span class="category1">function</span> yesClicked(e:MouseEvent):<span class="category1">void</span>{
 	dispatchEvent(<span class="category1">new</span> Event("<span class="quote">yesClicked</span>"));
}

<span class="category1">function</span> noClicked(e:MouseEvent):<span class="category1">void</span>{
 	dispatchEvent(<span class="category1">new</span> Event("<span class="quote">noClicked</span>"));
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Now you might ask, where are the effects the article is talking about? Well, I do not want to make it to boring. As a readers exercise, opet the ProfilePicDisplay class file and try to add various effects. Also, we talked about that we want to notify users of the answers. You can do that in both functions:</div>

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

<span class="category1">function</span> yesClicked(e:Event):<span class="category1">void</span>{
 	<span class="linecomment">//do something before moving on...</span>
 	setQuestion();
}

<span class="category1">function</span> noClicked(e:Event):<span class="category1">void</span>{
 	<span class="linecomment">//do something before moving on...</span>
 	setQuestion();
}</pre>
</code>

</div></div> 

<div style="text-align: left;">Try to use the notifications command classes and you will get the desired result.</div>

<div style="text-align: left;">I hope you enjoyed the article, I really did!</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.35908-comment:2124971</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35908" type="text/html" href="http://www.insideria.com/2009/05/extended-profilepic-component.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/05/extended-profilepic-component.html#comment-2124971" />
    <title>Comment from tykebloke on 2009-10-02</title>
    <author>
        <name>tykebloke</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>hi. very helpful series. can you point me to any info on publishing images from a flash application to the profile pic or wall? I can find very little information on the web for this, and i see this as the rossetta stone for flash developers wanting to create facebook apps via actionscript 3.</p>

<p>thanks<br />
</p>]]>
    </content>
    <published>2009-10-02T10:13:57Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35908-comment:2125002</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35908" type="text/html" href="http://www.insideria.com/2009/05/extended-profilepic-component.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/05/extended-profilepic-component.html#comment-2125002" />
    <title>Comment from Mirza Hatipovic on 2009-10-02</title>
    <author>
        <name>Mirza Hatipovic</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>you can publish a full sized story to the profile...:-) check my article<br />
on publishing news...it covers short sized stores, but you cehck <br />
experiment</p>]]>
    </content>
    <published>2009-10-02T10:48:05Z</published>
  </entry>

</feed
