Packageyourminis.api.social
Classpublic class SocialBase
InheritanceSocialBase Inheritance flash.events.EventDispatcher
ImplementsISocial
SubclassesBebo, Facebook, OpenSocial, SocialNone

Social Base class.



Public Properties
 PropertyDefined by
  ACTIVITY_CREATED : String
[read-only] Event fired when an activity has been created
SocialBase
  AUTHENTICATION_COMPLETE : String
[read-only] Event fired when authentication is completed
SocialBase
  delegate_friends : *
SocialBase
  Friends : Array
[read-only] Get Friends - returns the yourminis version of friends, returning common data across opensocial and facebook
SocialBase
  SOCIAL_ONGETFRIENDS : String
[read-only] Event fired when social friends have been retrieved
SocialBase
  ym_friends : *
SocialBase
  ym_social_type : String
SocialBase
Protected Properties
 PropertyDefined by
  api : IApiBase
SocialBase
  widget : Widget
SocialBase
Public Methods
 MethodDefined by
  
SocialBase(_widget:Widget)
SocialBase serves as the delegate class for all Social Platforms, and stives to unify the various social platforms under one API.
SocialBase
  
createActivity(title:String, body:String, summary:String = null, url:String = null, media:Array = null):void
SocialBase
  
getCurrentView():String
Returns the current view the widget is being displayed in, varies across platforms
SocialBase
  
getParameter(parameter_name:String):String
Returns the value of the specified parameter if it has been passed in by the social application, an empty string if not.
SocialBase
  
isBebo():Boolean
This function returns true if the widget is running on the Bebo platform, false otherwise
SocialBase
  
isFacebook():Boolean
This function returns true if the widget is running on the Facebook platform, false otherwise
SocialBase
  
isOpensocial():Boolean
This function returns true if the widget is running on the OpenSocial platform, false otherwise
SocialBase
  
isSocial():Boolean
This function returns true if the widget is running on a social platform, false otherwise
SocialBase
Property detail
ACTIVITY_CREATEDproperty
ACTIVITY_CREATED:String  [read-only]

Event fired when an activity has been created

Implementation
    public function get ACTIVITY_CREATED():String

Example
The following code prints out a message to the console when a social activity is created in Facebook
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.debugMode = true;
   widget.initWidget(300,250,0x000000); 
   widget.social.addEventListener(widget.social.ACTIVITY_CREATED, onActivityCreated);
   widget.social.createActivity("clicked a link", "The full URL is: http://www.yourminis.com");
  }
  function onActivityCreated(evt:Event):void {
   widget.debug("activity created");
  }
 

apiproperty 
protected var api:IApiBase
AUTHENTICATION_COMPLETEproperty 
AUTHENTICATION_COMPLETE:String  [read-only]

Event fired when authentication is completed

Implementation
    public function get AUTHENTICATION_COMPLETE():String

Example
The following code prints displays an alert when the widget is authenticated in facebook
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);//We must use a string literal instead of a constant because the event constants are not yet initialized in the widget class
  function onWidgetLoaded(evt:Event):void {
   widget.initWidget(300,250,0x000000);
   widget.requireLibrary("facebook", ");
   widget.addEventListener(widget.LIBRARIES_LOADED, onLibrariesLoaded);
  }
  function onLibrariesLoaded(evt:Event):void{
   widget.initWidget();
   widget.libraries.facebook.api_key = "5efb77b97275f66bde1ba5347f1116c2";
   widget.libraries.facebook.secret = "ba566af38313fbb961034ab477b90c92";
   widget.libraries.facebook.addEventListener(widget.social.AUTHENTICATION_COMPLETE, onAuthenticated);
   widget.libraries.facebook.dispatchEvent(new Event(widget.social.NEED_AUTHENTICATION));
  }
  function onAuthenticated(evt:Event):void
  {
   widget.alert("authenticated!");
  }
 

delegate_friendsproperty 
public var delegate_friends:*
Friendsproperty 
Friends:Array  [read-only]

Get Friends - returns the yourminis version of friends, returning common data across opensocial and facebook

Implementation
    public function get Friends():Array

See also

SOCIAL_ONGETFRIENDSproperty 
SOCIAL_ONGETFRIENDS:String  [read-only]

Event fired when social friends have been retrieved

Implementation
    public function get SOCIAL_ONGETFRIENDS():String

Example
The following code prints out a single friend uid to the console when the user's friends have been retreived
  import yourminis.api.IWidget
  var widget:IWidget;
  addEventListener("widget-loaded",onWidgetLoaded);
  function onWidgetLoaded(evt:Event):void {
   widget.debugMode = true;
   widget.initWidget(300,250,0x000000); 
   widget.social.addEventListener(widget.social.SOCIAL_ONGETFRIENDS, onGetFriends);
   widget.social.getFriends();
  }
  function onGetFriends(evt:Event):void {
   var friends:Array = widget.social.Friends;
   for (var i=0; i < friends.length; i++)
   {
    var name = friends[i].name;
    var gender = friends[i].gender;
    var thumbnailurl = friends[i].thumbnailurl;
    widget.debug("name: " + name + ", gender: " + gender + ", thumbnailurl: " + thumbnailurl);
   }
  }
 

widgetproperty 
protected var widget:Widget
ym_friendsproperty 
public var ym_friends:*
ym_social_typeproperty 
public var ym_social_type:String
Constructor detail
SocialBase()constructor
public function SocialBase(_widget:Widget)

SocialBase serves as the delegate class for all Social Platforms, and stives to unify the various social platforms under one API.

Parameters
_widget:Widget

See also


Example
Example The following code will determine whether we are running in facebook, and if so, publish a user action providing a template bundle id and optional variable data
   //this is from our social rss sample available in yourminis developer downloads
   import yourminis.api.IWidget

   var rss;
   var textfield:TextField;
   var widget:IWidget;
   
   addEventListener("widget-loaded",onWidgetLoaded);
   
   function onWidgetResize( evt:Event ):void 
   { 
    textfield.width = widget.width -20;
    textfield.height = widget.height -20;
   }
   
   function onDropDownLoaded( evt:Event):void
   {
    widget.chrome.addDropDownItem("yourminis","http://feeds.feedburner.com/yourminis",loadFeed);
    widget.chrome.addDropDownItem("digg","http://digg.com/rss/index.xml",loadFeed);
    widget.chrome.addDropDownItem("flickr","http://api.flickr.com/services/feeds/photos_public.gne?format=rss2",loadFeed);
   }
   
   
   function onWidgetLoaded(evt:Event)
   {
    //your widget has started and is ready for display
    widget.initWidget(300,350,0xffffff);
    widget.addEventListener(widget.WIDGET_RESIZED,onWidgetResize);
    widget.addEventListener(widget.DROPDOWN_LOADED,onDropDownLoaded);
    
    //add the textfield to the form
    textfield = new TextField();
    textfield.x = 5;
    textfield.y = 5;
    textfield.width = 280;
    textfield.height = 330;
    textfield.multiline = true;
    textfield.wordWrap = true;
      
    addChild(textfield);
    
    rss = widget.newRSS();
    rss.addEventListener(Event.COMPLETE,onRSSLoaded);
    rss.load(new URLRequest(widget.getSetting("feedurl","http://feeds.feedburner.com/yourminis")));
   
    addEventListener(TextEvent.LINK, linkHandler);
   }
   
   function loadFeed(feed)
   {
    widget.setSetting("feedurl",feed);
    
    rss = widget.newRSS();
    rss.addEventListener(Event.COMPLETE,onRSSLoaded);
    rss.load(new URLRequest(feed));
   }
   
   function linkHandler(evt:TextEvent) {
    //determine whether we are running in facebook then
    //create a newsfeed item / opensocial activity
     
    if (widget.social.isFacebook()) {
     var fb:IFacebook = (widget.social as IFacebook);
     var obj = new Object();
     obj.link = evt.text; // this would replace a link variable in your template content
     fb.publishUserAction(36440856409,obj,"","",1);
    }
    else {
     widget.social.createActivity("clicked a link", "The full URL is: " + evt.text + "");
    }
    widget.reporting.trackURL(evt.text);
   }
   
   function onRSSLoaded(evt:Event)
   {
    var loader:URLLoader = URLLoader(evt.target);
    var rssxml:XML = XML(loader.data);
    
    var str = "";
    for each (var item:XML in rssxml..item)
    {
     str+="" + 
        item.title + "
" + item.description + "

"; } textfield.htmlText = str; }

Method detail
createActivity()method
public function createActivity(title:String, body:String, summary:String = null, url:String = null, media:Array = null):voidParameters
title:String
 
body:String
 
summary:String (default = null)
 
url:String (default = null)
 
media:Array (default = null)
getCurrentView()method 
public function getCurrentView():String

Returns the current view the widget is being displayed in, varies across platforms

Returns
String

See also


Example
The following example prints the current view in the debug console
   import yourminis.api.IWidget
   var widget:IWidget;
   addEventListener("widget-loaded",onWidgetLoaded);
   function onWidgetLoaded(evt:Event):void {
    widget.initWidget(300,250,0x000000);
    widget.debugMode = true;
    widget.debug("Current View: " + widget.social.getCurrentView());
   }
  

getParameter()method 
public function getParameter(parameter_name:String):String

Returns the value of the specified parameter if it has been passed in by the social application, an empty string if not.

Parameters
parameter_name:String — The name of the social parameter to get the value for (e.g. 'fb_sig_locale').

Returns
String
isBebo()method 
public function isBebo():Boolean

This function returns true if the widget is running on the Bebo platform, false otherwise

Returns
Boolean

Example
The following example displays whether or not the widget is running in Bebo in the debug console
   import yourminis.api.IWidget
   var widget:IWidget;
   addEventListener("widget-loaded",onWidgetLoaded);
   function onWidgetLoaded(evt:Event):void {
    widget.initWidget(300,250,0x000000);
    widget.debugMode = true;
    widget.debug("Running on Bebo: " + widget.social.isBebo());
   }
  

isFacebook()method 
public function isFacebook():Boolean

This function returns true if the widget is running on the Facebook platform, false otherwise

Returns
Boolean

Example
The following example displays whether or not the widget is running in Facebook in the debug console
   import yourminis.api.IWidget
   var widget:IWidget;
   addEventListener("widget-loaded",onWidgetLoaded);
   function onWidgetLoaded(evt:Event):void {
    widget.initWidget(300,250,0x000000);
    widget.debugMode = true;
    widget.debug("Running on Facebook: " + widget.social.isFacebook());
   }
  

isOpensocial()method 
public function isOpensocial():Boolean

This function returns true if the widget is running on the OpenSocial platform, false otherwise

Returns
Boolean

Example
The following example displays whether or not the widget is running in OpenSocial in the debug console
   import yourminis.api.IWidget
   var widget:IWidget;
   addEventListener("widget-loaded",onWidgetLoaded);
   function onWidgetLoaded(evt:Event):void {
    widget.initWidget(300,250,0x000000);
    widget.debugMode = true;
    widget.debug("Running on OpenSocial: " + widget.social.isOpenSocial());
   }
  

isSocial()method 
public function isSocial():Boolean

This function returns true if the widget is running on a social platform, false otherwise

Returns
Boolean

Example
The following example displays whether or not the widget is running in a social platform in the debug console
   import yourminis.api.IWidget
   var widget:IWidget;
   addEventListener("widget-loaded",onWidgetLoaded);
   function onWidgetLoaded(evt:Event):void {
    widget.initWidget(300,250,0x000000);
    widget.debugMode = true;
    widget.debug("Is running on a Social platform: " + widget.social.isSocial());
   }