Developers > Learning Center > Hello World Tutorail
Welcome to the obligatory "Hello, World!" tutorial. In this lesson, you will learn to build the most simple of widgets using the wAPI. Once you have completed this and the subsequent tutorials, you'll be well on your way to becoming a veritable widget master!
- Adobe Flash CS3
- wAPI .mxp (If you don't have this installed yet, follow the steps found here)
- Download the source code for this example here: Samples.
The first step in this tutorial is to open Adobe Flash CSE. This is where you will do all of your widget development. While it's still possible to develop widgets using third party tools, it's probably easiest to use the Flash IDE until you are completely comfortable with the widget creation process. Once the Flash IDE is open, create a new "Flash File (AS3)".
In the Actions panel, (if it's not already open press F9) add the following lines of code to the first frame:
//This is the minimal code necessary to initialize
// and hook into the widget API (wAPI)
var widget; //Widget
addEventListener("widget-loaded",onWidgetLoaded);
function onWidgetLoaded(evt:Event)
{
//your widget has started and is ready for display
}
Add the following code to the onWidgetLoaded Event:
//init widget will enable and set the chrome dimensions and background color widget.initWidget(300,300,0xffffff); //add the textfield to the form var textfield:TextField = new TextField(); textfield.text = "HELLO WORLD"; textfield.x = 100; textfield.y = 100; addChild(textfield);
The resulting code should look like this:
Press the "Test this widget!" button in the wAPI Widget Panel. This will launch the wAPI Test Console with your widget inside. The wAPI Test Console is where you test and debug your widgets before uploading them to yourminis widget platform. If you've done everything correctly, you should wind up with a window that looks like the one in the image on the right.
Congratulations! You've created your first widget using the wAPI.
Advanced RSS Tutorial - This tutorial covers many of the advanced wAPI features including tracking and widget settings.
yourminis