|
|
WidgetWidget Managementwidget provides functions for registering and updating registered widgets. It also allows you to reconfigure a widget at run-time (e.g., to use your own preferences engine).
Contents
API Reference
Reloads a running widget with new configuration; new configuration will propagate with any shares, but will not persist past current session. Parameters
ReturnNoneExample UsageAS2
// Sets 'color' to red; sets 'number' to 6.
// Widget will be reloaded to display the new configuration,
// but will still count as the same user interaction session.
_level0.cs.widget.configure({color: 0xff0000, number: 6});
AS3
// Sets 'color' to red; sets 'number' to 6.
// Widget will be reloaded to display the new configuration,
// but will still count as the same user interaction session.
_api.widget.configure({color: 0xff0000, number: 6});
JavaScript
// Note: Only available within JS kernel
//
// Sets 'color' to red; sets 'number' to 6.
// Widget will be reloaded to display the new configuration,
// but will still count as the same user interaction session.
_api.widget.configure({color: 0xff0000, number: 6});
Register a new widget. Not so much for registering mass numbers of widgets, as you're capped at 50 per day, but rather so you don't have to ever manually register a widget using our console if you'd prefer to just work with our API suite. N.B.: We strongly discourage making this call in a production widget, as no matter how obfuscated you make it, your widget code can ultimately be compromised once it's in the wild due to the interpreted nature of both Flash and JavaScript. Protect your user ID; only make this call from within a trusted environment. Parameters
ReturnNoneExample UsageAS2
function callback(status:Number, result:Object):Void
{
if (status)
{
trace('An error occurred: ' + status);
}
else
{
trace('Successfully registered widget; widget ID=' + result.widgetId);
}
}
_level0.cs.widget.register('userid',
'my first widget',
{content: '<h1>an exciting header</h1>"},
callback);
AS3
function callback(status:Number, result:Object):Void
{
if (status)
{
trace('An error occurred: ' + status);
}
else
{
trace('Successfully registered widget; widget ID=' + result.widgetId);
}
}
_api.widget.register('userid',
'my first widget',
{content: '<h1>an exciting header</h1>"},
callback);
JavaScript
function callback(status, result):Void
{
if (status)
{
alert('An error occurred: ' + status);
}
else
{
alert('Successfully registered widget; widget ID=' + result.widgetId);
}
}
_api.widget.register('userid',
'my first widget',
{content: '<h1>an exciting header</h1>"},
callback);
Update a registered widget. For changing a widget's content on the fly. N.B.: We strongly discourage making this call in a production widget, as no matter how obfuscated you make it, your widget code can ultimately be compromised once it's in the wild due to the interpreted nature of both Flash and JavaScript. Protect your user ID; only make this call from within a trusted environment. Parameters
ReturnNoneExample UsageAS2
function callback(status:Number, result:Object):Void
{
if (status)
{
trace('An error occurred: ' + status);
}
else
{
trace('Successfully updated widget');
}
}
_level0.cs.widget.update('userid',
'widgetid',
{content: '<h1>an <strong>even more</strong> exciting header</h1>"},
callback);
AS3
function callback(status:Number, result:Object):Void
{
if (status)
{
trace('An error occurred: ' + status);
}
else
{
trace('Successfully updated widget');
}
}
_api.widget.update('userid',
'widgetid',
{content: '<h1>an <strong>even more</strong> exciting header</h1>"},
callback);
JavaScript
function callback(status, result):Void
{
if (status)
{
alert('An error occurred: ' + status);
}
else
{
alert('Successfully updated widget');
}
}
_api.widget.update('userid',
'widgetid',
{content: '<h1>an <strong>even more</strong> exciting header</h1>"},
callback);
Error Codes
|