First, let's create the class template. Open your favorite class editor (personally I use Flashdevelop) and create a new ActionScript file called CelsiusConverter.as.

The best way to create autonomous widgets with SPAS 3.0 is to extend the Popup class (org.flashapi.swing.Popup). Thus, the widget will be independent of the environment in which you will place it (principle of weak coupling).

So, open the CelsiusConverter file and create a class called CelsiusConverter that extends the Popup class, as shown below:

package {
import org.flashapi.swing.*;
public class CelsiusConverter extends Popup {
public function CelsiusConverter() {
super();
}
}
}

The super statement calls the Popup constructor which has 3 parameters: title, width and height. The title specifies the text displayed on the face of the popup's title bar. We set its value to "Convert Celsius to Fahrenheit", which is not so bad, and we set the width to 250 pixels. (It is enough to display the widget's content). Moreover, in OOP we often prefer to initialize objects into an initializing method instead of the constructor method itself.

public function CelsiusConverter() {
super("Convert Celsius to Fahrenheit", 250);
initialize();
}

Once the construcor function is defined, we can concentrate on the initialize() method to create the widget.