Simple clear advice in plain English

Hands on: Get started with Flex Builder

Starting out with Adobe’s application platform

Hands On with Flex Builder
Here’s a short tutorial based on Flex Builder 3, which at the time of writing is a beta product available for download.

If you like the look of Flex, but cannot afford Flex Builder, remember that the SDK is free.

The free Javascript IDE, Aptana, supports AIR applications but not yet MXML, or you can use any editor.

Flex Builder, based on Eclipse, is a culture shock if you are used to Visual Studio. Here is a quick example. Start a new Flex project and choose Desktop application. Give the project a name and click Finish. Click the Design view if it is not already selected. This gives you a blank surface, onto which you can drag controls from the control palette. Drag a button and a label. Now imagine you want to click the button and have the label change. In Visual Studio you would double-click the button and write some code for the click event.

That won’t work in Flex. Here are the steps:
1. Select the label control and type an ID property. This is the equivalent of the Name property in Visual Basic.

2. Select the button again, and type

changeLabel()

for the On click event.

3. Now select the Source view. Move the cursor to line 3, which is just after the opening tag of .

4. Type

and press Enter. Flex Builder will automatically create a CDATA block. Script code is not well-formed XML, so it must be either in a CDATA block or in a separate file.

5. Type the following function:

private function changeLabel():void
{
myLabel.text = “Hello Flex”;
}

6. Now click the green Run button. The application will run and you can click the button successfully.

There are a few things to notice here. First, Actionscript is case-sensitive. Second, Flex Builder supports code completion. When the IDE pops up a list of possible statements, use the arrow keys to select the one you want, and press Enter to have it automatically typed in. You can summon the code completion list at any time by pressing Ctrl & Enter. Third, the visual designer in Flex Builder is more limited than the one in Visual Studio. Many Flex developers spend most of their time in the Source view. Fourth, anything you do in MXML can also be done in Actionscript. An MXML element is a shortcut to declaring and instantiating an object with certain properties.

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

Security shield illustration

How to use the Command Prompt

Lurking under Windows is the little-known world of the command line. We explain how to use this to fix faults and make your PC much more secure

Google illustration

Make the most of a Google search

A Google search can be easy, but did you know that you can refine that search? A little thought can improve the chances of finding exactly what you're after

Create a shortcut to switch between power schemes illustration

Switch between several power schemes with a click of the mouse

Do you want to save battery or mains power? Find out how to switch between power management settings with a nothing more complicated than a double-click

Question & Answer

Q.Why are some of the keys on my keyboard doing strange...

> Read the answer

Q.Is my phone’s Bluetooth any use?

> Read the answer

Q.Can I switch boot drives so that I can work on older...

> Read the answer

Best deals on the web

img

Samsung RV520-A07

£359.98- Buy it now

img

Acer Aspire 5750G (LX.RXP02.019)

£399.99- Buy it now

img

Apple MacBook Pro (MD313B/A)

£904.37- Buy it now

Latest issue & subscription deals

Poll

Are you concerned about viruses that target mobile phones?

Jargon Buster

Computing terms explained in plain English

Restore point

A Windows backup of system files and settings.

Great shopping deals from Computeractive