Hello ActionScript (with Flex Builder 2)
This Tutorial will show you how to write a simple ActionScript Hello World application.
Main Learning's
After following this tutorial you will learn how to:
- Use FlexBuilder 2
- Create an ActionScript Application
- Create an ActionScript class
- Run the ActionScript Application
Versions used:
- Flex Builder 2
- ActionScript 3
Assumptions:
Flex Builder 2 is properly installed in your machine. Hello Flex Builder 2 tutorial shows how to download and install flex Builder 2.
Tutorial Steps:
- Open Flex Builder 2
- Create a helloActionscript project
- In Flex Builder, select File > New> Flex Project,

- Select Basic, and then click Next
- Type helloActioncript as the Project Name
- Select your code base location (in my case C:\codebase\flex\hello)

- Click on Finish
- helloActionscript project on Flex Bulder 2

- Create HelloWorld ActionScript class
- Select File > New > ActionScript File

- Click on Finish
- HelloWorld.as

- Add the following ocde to HelloWorld.as
- package
{
public class HelloWorld
{
public function greeting():String
{
return "Hello World!";
}
}
}

- Update the HelloActionscript application to use the HelloWorld.as class
- Open the HelloActionscript.mxml file adn replace it for hte following code
- <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
layout="vertical"
creationComplete = "initApp()" >
<mx:Script>
<![CDATA[
private var myHelloWorld:HelloWorld = new HelloWorld();
public function initApp():void
{
mainTxt.text = myHelloWorld.greeting();
}
]]>
</mx:Script>
<mx:TextArea id = "mainTxt" width="400" />
</mx:Application>
- Run your application
- Run/Run/helloActionscript

Comments (0)
You don't have permission to comment on this page.