Guest User

Untitled

a guest
Jul 24th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
  3.                 xmlns:s="library://ns.adobe.com/flex/spark"
  4.                 xmlns:mx="library://ns.adobe.com/flex/mx"
  5.                 autoDrawBackground="true"
  6.                 creationComplete="itemrenderer1_creationCompleteHandler(event)">
  7.     <fx:Script>
  8.         <![CDATA[
  9.             import mx.controls.Alert;
  10.             import mx.controls.Text;
  11.             import mx.events.FlexEvent;
  12.            
  13.            
  14.             protected function itemrenderer1_creationCompleteHandler(event:FlexEvent):void
  15.             {
  16.                
  17.                 if(data!=null)
  18.                 {                  
  19.                     // Retrieving the user's DOB
  20.                     var dateStr:String = data.dob;
  21.                     //Splitting the DOB up to make it compatible with Flex
  22.                     var parts:Array = dateStr.split("-");
  23.                    
  24.                     if(parts == null || parts.length != 3)
  25.                     {
  26.                         Alert.show("There is an error retrieving the user's DOB.");
  27.                     }
  28.                    
  29.                     var dobDay:* = parts[2];
  30.                     var dobMonth:* = parts[1] - 1;
  31.                     var dobYear:* = parts[0];
  32.                     // Pasting the DOB back together
  33.                     var userDOB : Date = new Date(dobYear, dobMonth, dobDay);
  34.                     var today : Date = new Date();
  35.                     var diff : Date = new Date();
  36.                     //Calculating & printing the Age
  37.                     diff.setTime( today.getTime() - userDOB.getTime() );
  38.                     var userAge : int = diff.getFullYear() - 1970;
  39.                     ageLbl.text = "Age: " + userAge.toString();
  40.                    
  41.                     //Re-formatting the date submitted
  42.                     var lastsubmittedStr:String = data.datesubmitted;
  43.                     var parts2:Array = lastsubmittedStr.split("-");
  44.                    
  45.                     if (parts2 == null || parts.length != 3)
  46.                     {
  47.                         Alert.show("There is an error retrieving datesubmitted");
  48.                     }
  49.                    
  50.                     var lastupdateDay:* = parts2[2];
  51.                     var lastupdateMonth:* = parts2[1];
  52.                     var lastupdateYear:* = parts2[0];
  53.                    
  54.                     lastupdatedLbl.text = "Last Updated: " + lastupdateDay + "/" + lastupdateMonth + "/" + lastupdateYear;
  55.                    
  56.                     if (data.gender == "male") {
  57.                         maleImg.visible=true;
  58.                         femaleImg.visible=false
  59.                     }
  60.                     else {
  61.                         femaleImg.visible=true;
  62.                         maleImg.visible=false;
  63.                     }
  64.                    
  65.                     flagImg.source = "flags/" + data.nationality + ".jpg";
  66.                    
  67.                     twitterIcon();
  68.                     youtubeIcon();
  69.                     flickrIcon();
  70.                    
  71.                    
  72.                    
  73.                 }
  74.                
  75.                
  76.             }
  77.            
  78.             public function viewUser():void
  79.             {
  80.                 //Creating a URL for a facebook profile
  81.                 trace(data.facebookid);
  82.                 var facebookUrl:* = "http://www.facebook.com/" + data.facebookid;
  83.                 navigateToURL(new URLRequest(facebookUrl));
  84.             }
  85.            
  86.             public function messageUser():void
  87.             {
  88.                 trace(data.facebookid);
  89.                 var messageUrl:* = "http://www.facebook.com/messages/" + data.facebookid;
  90.                 navigateToURL(new URLRequest (messageUrl));
  91.             }
  92.            
  93.             protected function twitterIcon():void
  94.             {
  95.                 if (data.twitterid.length <=3)
  96.                 {
  97.                     twittericonImg.includeInLayout=false;
  98.                     twittericonImg.visible=false;
  99.                 }
  100.                 else {
  101.                     twittericonImg.includeInLayout=true;
  102.                     twittericonImg.visible=true;
  103.                 }
  104.             }
  105.            
  106.             protected function youtubeIcon():void
  107.             {
  108.                 if (data.youtubeid.length <=3)
  109.                 {
  110.                     youtubeiconImg.includeInLayout=false;
  111.                     youtubeiconImg.visible=false;
  112.                 }
  113.                 else {
  114.                     youtubeiconImg.includeInLayout=true;
  115.                     youtubeiconImg.visible=true;
  116.                 }
  117.             }
  118.            
  119.             protected function flickrIcon():void
  120.             {
  121.                 if (data.flickrid.length <=3)
  122.                 {
  123.                     flickriconImg.includeInLayout=false;
  124.                     flickriconImg.visible=false;
  125.                 }
  126.                 else {
  127.                     flickriconImg.includeInLayout=true;
  128.                     flickriconImg.visible=true;
  129.                 }
  130.             }
  131.            
  132.             protected function viewTwitter():void
  133.             {
  134.                 navigateToURL(new URLRequest('http://www.twitter.com/#!/' + data.twitterid));
  135.                
  136.             }
  137.            
  138.             protected function viewYoutube():void
  139.             {
  140.                 navigateToURL(new URLRequest('http://www.youtube.com/user/' + data.youtubeid));
  141.                
  142.             }
  143.            
  144.             protected function viewFlickr():void
  145.             {
  146.                 navigateToURL(new URLRequest('http://www.flickr.com/photos/' + data.flickrid));
  147.             }
  148.            
  149.         ]]>
  150.     </fx:Script>
  151.     <fx:Style source="thevoyageapp.css" />
  152.    
  153.    
  154.     <s:Group>
  155.         <s:Rect width="737" height="100%">
  156.             <s:fill><s:SolidColor color="#fce7d6" /></s:fill>
  157.         </s:Rect>
  158.        
  159.         <s:Image id="fbImg" source="http://graph.facebook.com/{data.facebookid}/picture?type=normal" x="5" y="5" useHandCursor="true" buttonMode="true"
  160.              mouseChildren="false" click="viewUser()"/>
  161.     <s:Label id="firstnameLbl" x="120" y="5" styleName="normaltext" text="{data.firstname}" useHandCursor="true" buttonMode="true"
  162.              mouseChildren="false" click="viewUser()"/>
  163.     <s:Label id="lastnameLbl" x="120" y="30" styleName="normaltext" text="{data.lastname}" useHandCursor="true" buttonMode="true"
  164.              mouseChildren="false" click="viewUser()"/>
  165.     <s:Label id="ageLbl" text="" x="120" y="60" styleName="normaltext" />
  166.     <s:Image id="maleImg" source="@Embed('/images/male.png')" x="120" y="85" visible="false" />
  167.     <s:Image id="femaleImg" source="@Embed('/images/female.png')" x="120" y="85" visible="false" />
  168.     <s:Image id="flagImg" x="175" y="95" />
  169.     <s:Image id="messageImg" x="120" y="135" source="@Embed('/images/messageicon.png')" useHandCursor="true" buttonMode="true" mouseChildren="false" click="messageUser()" />
  170.     <s:Label id="messageLbl" x="152" y="139" text="Send Message" styleName="smalltext" useHandCursor="true" buttonMode="true" mouseChildren="false" click="messageUser()" />
  171.  
  172.  
  173.     <s:Label id="voyagestatusLbl" text="Voyage Status" styleName="normaltext" x="350" y="5" />
  174.     <s:TextArea id="voyageStatus"  text="{data.voyagestatus}" maxChars="200" editable="false" width="300" height="70" x="348" y="30" contentBackgroundColor="#fce7d6" />
  175.    
  176.     <s:HGroup id="usersocialMedia" x="350" y="110">
  177.         <s:Image id="twittericonImg" source="@Embed('/images/twittericon.png')" useHandCursor="true" visible="false" buttonMode="true" mouseChildren="false" includeInLayout="false"
  178.                  click="viewTwitter()"/>
  179.         <s:Image id="youtubeiconImg" source="@Embed('/images/youtubeicon.png')" useHandCursor="true" visible="false" buttonMode="true" mouseChildren="false" includeInLayout="false"
  180.                  click="viewYoutube()"/>
  181.         <s:Image id="flickriconImg" source="@Embed('/images/flickricon.png')" useHandCursor="true" visible="false" buttonMode="true" mouseChildren="false" includeInLayout="false"
  182.                  click="viewFlickr()"/>
  183.         <s:Label id="lastupdatedLbl" styleName="smalltext"/>
  184.     </s:HGroup>
  185.    
  186.        
  187.     </s:Group>
  188.    
  189.    
  190.    
  191.    
  192. </s:ItemRenderer>
Advertisement
Add Comment
Please, Sign In to add comment