First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Pascal ECHEMANN | Website: http://www.flashapi.org/

Page 1

The process to create impressive widgets with Flex and to integrate them into Flash is too much complicated. For these reasons, one of the aims of SPAS 3.0 is to really simplify the coding process, without restricting its possibilities.

In this tutorial we will learn how to make a simple Celsius to Fahrenheit degree converter with less than 30 lines of code. Then, we'll see how to integrate it into a Flash application directly from the Flash CS3 main timeline.

We assume that you are familiar with external files programming and that you already have downloaded SPAS 3.0.
You can download SPAS 3.0 alpha 1.0 release at http://www.flashapi.org/

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() {

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);

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

» Level Intermediate

Added: 2008-12-11
Rating: 1 Votes: 1
» Author
Pascal Echemann is a Web Developer and Project Manager for "Bananatree Design" on the French Riviera. He also is the creator of the "Swing Package for ActionScript 3.0" (SPAS 3.0).
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.