First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
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() {
			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.

» Level Intermediate

Added: 2008-12-11
Rating: 1 Votes: 1
(10 being the highest)
» 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!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.