Packageyourminis.api
Classpublic class Widget
InheritanceWidget Inheritance flash.display.Sprite
Implementsyourminis.api.IWidget

Main Widget Class that provides an ActionScript 3 API to the yourminis Widget Platform.


Example
This is the minimal code necessary to initialize and hook into the widget API
  var widget; //Widget
  addEventListener("widget-loaded",onWidgetLoaded);
  
  function onWidgetLoaded(evt:Event)
  {
   //your widget has started and is ready for display
  }
 

Example The following code will parse an rss feed and display the title and description of each item in a text field
  var widget; //Widget
  var rss;
  addEventListener("widget-loaded",onWidgetLoaded);
  
  function onWidgetLoaded(evt:Event)
  {
   //your widget has started and is ready for display
   rss = widget.newRSS();
   rss.addEventListener(Event.COMPLETE,onRSSLoaded);
   rss.load(new URLRequest("http://feeds.feedburner.com/yourminis"));
  }
  
  function onRSSLoaded(evt:Event)
  {
   var loader:URLLoader = URLLoader(evt.target);
   
   namespace dc="http://purl.org/dc/elements/1.1/";
   namespace content="http://purl.org/rss/1.0/modules/content/";
   namespace geo="http://www.w3.org/2003/01/geo/wgs84_pos#";
   
   var rssxml:XML = XML(loader.data);
   
   var str = "";
   for each (var item:XML in rssxml..item)
   {
    str+="<b><a href='" + item.link + "' target='_blank'><u>" + item.title + "</u></a></b>";
    str+="<br/>" + item.description + "<br/><br/>";
    
   }
   output_txt.htmlText = str;
  }
 

See also

http://www.yourminis.com/developers


Public Properties
 PropertyDefined by
  air : Boolean
[read-only] Adobe AIR(TM) widget flag
Widget
  ajax : Boolean
[read-only] ajax widget flag
Widget
  allowFullScreen : Boolean
Call this method to allow the widget to go into full screen mode when copied (wont work on MySpace)
Widget
  api : IApiBase
[read-only] Provides REST API access to the yourminis widget server
Widget
  APIWidget : Boolean
[read-only] API widget flag
Widget
  bgcolor : uint
background color of the widget
Widget
  chrome : IChrome
[read-only] Provide access to Chrome API
Widget
  compiler : Boolean
[read-only] compiler widget flag
Widget
  content : *
[read-only] Provide read-only access to the content of the widget
Widget
  debugMode : Boolean
private
Widget
  DROPDOWN_LOADED : String
[read-only] Event fired when the Widget dropdown is finished loading
Widget
  embedded : Boolean
[read-only] embedded widget flag
Widget
  guid : String
[read-only] Provide read-only access to the guid setting
Widget
  height : Number
height of the widget
Widget
  hostname : String
[read-only] Provide read-only access to the API hostname
Widget
  loading : Boolean
loading indicator
Widget
  macdashboard : Boolean
[read-only] Mac Dashboard(TM) widget flag
Widget
  reporting : IReporting
[read-only] Provide access to the Reporting API
Widget
  reportingEnabled : Boolean
[read-only] reportingEnabled flag
Widget
  sandbox : Boolean
[read-only] sandbox widget flag
Widget
  settings : Object
[read-only] Provides read-only access to the settings array;
Widget
  SETTINGS_UPDATED : String
[read-only] Event fired when the widget updates a setting
Widget
  social : ISocial
[read-only] Provide access to the Social API
Widget
  STAGE_MOUSEOUT : String
[read-only] Event fired when the mouse leaves the widget display area
Widget
  STAGE_MOUSEOVER : String
[read-only] Event fired when the mouse enters the widget display area
Widget
  startpage : Boolean
[read-only] startpage widget flag
Widget
  statshostname : String
[read-only] Provide read-only access to the API statshostname
Widget
  swfhost : String
[read-only] Provide read-only access to the Widget hostname
Widget
  syndication : ISyndication
[read-only] Provide access to the Syndication API
Widget
  SYNDICATION_LOADED : String
[read-only] Event fired when the widget syndication has loaded
Widget
  testpanel : Boolean
[read-only] testpanel widget flag
Widget
  title : String
[read-only] Provide read-only access to the title setting
Widget
  tooltip : Object
[read-only] Provide access to the tooltip
Widget
  uri : String
[read-only] Provide read-only access to the uri setting
Widget
  vista : Boolean
[read-only] Windows Vista(TM) widget flag
Widget
  WIDGET_CLOSING : String
[read-only] Event fired when the widget is about to close (to allow opportunity to close streams);
Widget
  WIDGET_COPIED : String
[read-only] Event fired when the Widget has successfully copied to another location
Widget
  WIDGET_FULLSCREEN : String
[read-only] Event fired when fullscreen mode is toggled
Widget
  WIDGET_LOADED : String
[read-only] Event fired when the Widget is finished loading
Widget
  WIDGET_RESIZED : String
[read-only] Event fired when the Widget has been resized
Widget
  WIDGET_THEMED : String
[read-only] Event fired when the Widget theme has changed
Widget
  width : Number
width of the widget
Widget
  yahoo : Boolean
[read-only] Yahoo Widgets(TM) widget flag
Widget
Public Methods
 MethodDefined by
  
Widget(__settings:Object, _widgetLocation:String)
Widget
  
addDropDownItem(title:String, data:* = null, callback:Function = null, nodeNumber:int = -1):void
Used to add items to the dropdown menu.
Widget
  
addTooltip(mc:InteractiveObject, tooltip:String, backgroundColor:Number = -1, borderColor:Number = -1, css:StyleSheet = null, delay:int = 1000):*
Used to add hover-over tooltips to movieclips, sprites, text, and buttons
Widget
  
alert(message:String, callback:Function = null, cancelcallback:Function = null):*
Used much like a javascript alert to display messages to the user
Widget
  
debug(msg:String):void
Call this method to trace a message (for debugging purposes).
Widget
  
displayFullScreen(evt:MouseEvent):*
Call this method to set the widget to fullscreen mode
Widget
  
getProxyURL(url:String):String
Widget
  
getSetting(settingName:String, defaultValue:*):*
Get a widget setting
Widget
  
initWidget(_w:Number = 300, _h:Number = 250, _c:uint = 0x000000):void
Call this method after the widget is loaded to initialize its dimensions and color (only if you are using the widget.chrome)
Widget
  
navigateToURL(urlreq:URLRequest, target:String = "_blank", track:Boolean = true):void
Used to navigate the user to the URL in the browser and track.
Widget
  
newHTTP():URLLoader
HTTP Class Factory method
Widget
  
newRSS():URLLoader
RSS Class Factory method
Widget
  
setSetting(name:*, data:*, init:Boolean = false):void
Set a widget setting
Widget
Property detail
airproperty
air:Boolean  [read-only]

Adobe AIR(TM) widget flag

Implementation
    public function get air():Boolean
ajaxproperty 
ajax:Boolean  [read-only]

ajax widget flag

Implementation
    public function get ajax():Boolean
allowFullScreenproperty 
allowFullScreen:Boolean  [read-write]

Call this method to allow the widget to go into full screen mode when copied (wont work on MySpace)

Implementation
    public function get allowFullScreen():Boolean
    public function set allowFullScreen(value:Boolean):void

See also

apiproperty 
api:IApiBase  [read-only]

Provides REST API access to the yourminis widget server

Implementation
    public function get api():IApiBase
APIWidgetproperty 
APIWidget:Boolean  [read-only]

API widget flag

Implementation
    public function get APIWidget():Boolean
bgcolorproperty 
bgcolor:uint  [read-write]

background color of the widget

Implementation
    public function get bgcolor():uint
    public function set bgcolor(value:uint):void
chromeproperty 
chrome:IChrome  [read-only]

Provide access to Chrome API

Implementation
    public function get chrome():IChrome
compilerproperty 
compiler:Boolean  [read-only]

compiler widget flag

Implementation
    public function get compiler():Boolean
contentproperty 
content:*  [read-only]

Provide read-only access to the content of the widget

Implementation
    public function get content():*
debugModeproperty 
debugMode:Boolean  [read-write]

private

Implementation
    public function get debugMode():Boolean
    public function set debugMode(value:Boolean):void
DROPDOWN_LOADEDproperty 
DROPDOWN_LOADED:String  [read-only]

Event fired when the Widget dropdown is finished loading

Implementation
    public function get DROPDOWN_LOADED():String
embeddedproperty 
embedded:Boolean  [read-only]

embedded widget flag

Implementation
    public function get embedded():Boolean
guidproperty 
guid:String  [read-only]

Provide read-only access to the guid setting

Implementation
    public function get guid():String
heightproperty 
height:Number  [read-write]

height of the widget

Implementation
    public function get height():Number
    public function set height(value:Number):void
hostnameproperty 
hostname:String  [read-only]

Provide read-only access to the API hostname

Implementation
    public function get hostname():String
loadingproperty 
loading:Boolean  [read-write]

loading indicator

Implementation
    public function get loading():Boolean
    public function set loading(value:Boolean):void
macdashboardproperty 
macdashboard:Boolean  [read-only]

Mac Dashboard(TM) widget flag

Implementation
    public function get macdashboard():Boolean
reportingproperty 
reporting:IReporting  [read-only]

Provide access to the Reporting API

Implementation
    public function get reporting():IReporting
reportingEnabledproperty 
reportingEnabled:Boolean  [read-only]

reportingEnabled flag

Implementation
    public function get reportingEnabled():Boolean
sandboxproperty 
sandbox:Boolean  [read-only]

sandbox widget flag

Implementation
    public function get sandbox():Boolean
settingsproperty 
settings:Object  [read-only]

Provides read-only access to the settings array;

Implementation
    public function get settings():Object
SETTINGS_UPDATEDproperty 
SETTINGS_UPDATED:String  [read-only]

Event fired when the widget updates a setting

Implementation
    public function get SETTINGS_UPDATED():String
socialproperty 
social:ISocial  [read-only]

Provide access to the Social API

Implementation
    public function get social():ISocial
STAGE_MOUSEOUTproperty 
STAGE_MOUSEOUT:String  [read-only]

Event fired when the mouse leaves the widget display area

Implementation
    public function get STAGE_MOUSEOUT():String
STAGE_MOUSEOVERproperty 
STAGE_MOUSEOVER:String  [read-only]

Event fired when the mouse enters the widget display area

Implementation
    public function get STAGE_MOUSEOVER():String
startpageproperty 
startpage:Boolean  [read-only]

startpage widget flag

Implementation
    public function get startpage():Boolean
statshostnameproperty 
statshostname:String  [read-only]

Provide read-only access to the API statshostname

Implementation
    public function get statshostname():String
swfhostproperty 
swfhost:String  [read-only]

Provide read-only access to the Widget hostname

Implementation
    public function get swfhost():String
syndicationproperty 
syndication:ISyndication  [read-only]

Provide access to the Syndication API

Implementation
    public function get syndication():ISyndication
SYNDICATION_LOADEDproperty 
SYNDICATION_LOADED:String  [read-only]

Event fired when the widget syndication has loaded

Implementation
    public function get SYNDICATION_LOADED():String
testpanelproperty 
testpanel:Boolean  [read-only]

testpanel widget flag

Implementation
    public function get testpanel():Boolean
titleproperty 
title:String  [read-only]

Provide read-only access to the title setting

Implementation
    public function get title():String
tooltipproperty 
tooltip:Object  [read-only]

Provide access to the tooltip

Implementation
    public function get tooltip():Object
uriproperty 
uri:String  [read-only]

Provide read-only access to the uri setting

Implementation
    public function get uri():String
vistaproperty 
vista:Boolean  [read-only]

Windows Vista(TM) widget flag

Implementation
    public function get vista():Boolean
WIDGET_CLOSINGproperty 
WIDGET_CLOSING:String  [read-only]

Event fired when the widget is about to close (to allow opportunity to close streams);

Implementation
    public function get WIDGET_CLOSING():String
WIDGET_COPIEDproperty 
WIDGET_COPIED:String  [read-only]

Event fired when the Widget has successfully copied to another location

Implementation
    public function get WIDGET_COPIED():String
WIDGET_FULLSCREENproperty 
WIDGET_FULLSCREEN:String  [read-only]

Event fired when fullscreen mode is toggled

Implementation
    public function get WIDGET_FULLSCREEN():String
WIDGET_LOADEDproperty 
WIDGET_LOADED:String  [read-only]

Event fired when the Widget is finished loading

Implementation
    public function get WIDGET_LOADED():String
WIDGET_RESIZEDproperty 
WIDGET_RESIZED:String  [read-only]

Event fired when the Widget has been resized

Implementation
    public function get WIDGET_RESIZED():String
WIDGET_THEMEDproperty 
WIDGET_THEMED:String  [read-only]

Event fired when the Widget theme has changed

Implementation
    public function get WIDGET_THEMED():String
widthproperty 
width:Number  [read-write]

width of the widget

Implementation
    public function get width():Number
    public function set width(value:Number):void
yahooproperty 
yahoo:Boolean  [read-only]

Yahoo Widgets(TM) widget flag

Implementation
    public function get yahoo():Boolean
Constructor detail
Widget()constructor
public function Widget(__settings:Object, _widgetLocation:String)Parameters
__settings:Object
 
_widgetLocation:String
Method detail
addDropDownItem()method
public function addDropDownItem(title:String, data:* = null, callback:Function = null, nodeNumber:int = -1):void

Used to add items to the dropdown menu.

Parameters
title:String — The title of the menu item.
 
data:* (default = null) — data object to pass to the callback function.
 
callback:Function (default = null) — A callback function to call when the item is clicked.
 
nodeNumber:int (default = -1) — If a secondary level menu is desired, specify the node of the primary menu to place this item under.

See also


Example
The following example shows how to change the color of the widget from the dropdown menu:
   widget.addEventListener(widget.DROPDOWN_LOADED,onDropdownLoaded);
   function onDropdownLoaded(evt:Event)
   {
    widget.addDropDownItem("Set color: black",0x000000, widget.setTheme);
    widget.addDropDownItem("Set color: red"  ,0xFF0000, widget.setTheme);
    widget.addDropDownItem("Set color: green",0x00FF00, widget.setTheme);
    widget.addDropDownItem("Set color: blue" ,0x0000FF, widget.setTheme);
   }
  

addTooltip()method 
public function addTooltip(mc:InteractiveObject, tooltip:String, backgroundColor:Number = -1, borderColor:Number = -1, css:StyleSheet = null, delay:int = 1000):*

Used to add hover-over tooltips to movieclips, sprites, text, and buttons

Parameters
mc:InteractiveObject — The InteractiveObject to add a tooltip to.
 
tooltip:String — The string you wish to display in the tooltip.
 
backgroundColor:Number (default = -1) — The background color of the tooltip. Default is 0xFFFFCC;
 
borderColor:Number (default = -1) — The border color of the tooltip. Default is 0x000000.
 
css:StyleSheet (default = null) — The StyleSheet of the tooltip's text. Default is 0x000000.
 
delay:int (default = 1000) — The delay in miliseconds before the tooltip appears on hover over. Default is 1000 (one second).

Returns
*

See also


Example
The following code adds a tooltip to my_button that says "Click me!" when hovered over
  widget.addTooltip(my_button,"Click me!");
 

alert()method 
public function alert(message:String, callback:Function = null, cancelcallback:Function = null):*

Used much like a javascript alert to display messages to the user

Parameters
message:String — The text to display in the alert
 
callback:Function (default = null) — Optional. The callback function for when the alert is closed.
 
cancelcallback:Function (default = null)

Returns
*

See also


Example
The following code tracks a URL request and opens it in the user's browser
  widget.alert("This is a test!");
 

debug()method 
public function debug(msg:String):void

Call this method to trace a message (for debugging purposes). Note: widget.debugMode must be set to true to get debug statements outside of the Widget Test Panel

Parameters
msg:String — the desired message to log

See also


Example
The following example shows how to trace "Hello World!" in the debug console of the Widget Test Panel:
   widget.debug("Hello World!");
  

displayFullScreen()method 
public function displayFullScreen(evt:MouseEvent):*

Call this method to set the widget to fullscreen mode

Parameters
evt:MouseEvent

Returns
*

See also

getProxyURL()method 
public function getProxyURL(url:String):StringParameters
url:String

Returns
String
getSetting()method 
public function getSetting(settingName:String, defaultValue:*):*

Get a widget setting

Parameters
settingName:String — The name of the setting to retrieve
 
defaultValue:* — The default value if the setting does not exist

Returns
*

See also


Example
Example get widget setting
   var widget; //Widget
   addEventListener("widget-loaded",onWidgetLoaded);
   
   function onWidgetLoaded(evt:Event)
   {
    //your widget has started and is ready for display
    
    var playerid = widget.getSetting("playerid",null);
    
    //do something with player id
   }
  

initWidget()method 
public function initWidget(_w:Number = 300, _h:Number = 250, _c:uint = 0x000000):void

Call this method after the widget is loaded to initialize its dimensions and color (only if you are using the widget.chrome)

Parameters
_w:Number (default = 300) — The desired width
 
_h:Number (default = 250) — The desired height
 
_c:uint (default = 0x000000) — The desired color

See also

navigateToURL()method 
public function navigateToURL(urlreq:URLRequest, target:String = "_blank", track:Boolean = true):void

Used to navigate the user to the URL in the browser and track. (required for external URL support in myspace.com)

Parameters
urlreq:URLRequest — The URL to navigate to and optionally track
 
target:String (default = "_blank") — An optional parameter to specify the target window name
 
track:Boolean (default = true) — An optional parameter to enable/disable tracking

See also


Example
The following code tracks a URL request and opens it in the user's browser
  var widget = ...
  widget.navigateToURL(new URLRequest("http://www.yourminis.com/developers/"));
 

newHTTP()method 
public function newHTTP():URLLoader

HTTP Class Factory method

Returns
URLLoader — HTTP Object for http related widget requests
newRSS()method 
public function newRSS():URLLoader

RSS Class Factory method

Returns
URLLoader — RSS Object for RSS related widget requests
setSetting()method 
public function setSetting(name:*, data:*, init:Boolean = false):void

Set a widget setting

Parameters
name:* — The name of the setting to retrieve
 
data:* — The value of the setting
 
init:Boolean (default = false)

See also


Example
Example set widget setting
   var widget; //Widget
   addEventListener("widget-loaded",onWidgetLoaded);
   
   function onWidgetLoaded(evt:Event)
   {
    //your widget has started and is ready for display
    
    var playerid = widget.getSetting("playerid",null);
    
    if (playerid==null)
    {
     setSetting("playerid","0");
     playerid=0;
    }
   }