helloopensource

 

ActionScript

Page history last edited by paulo 1 yr ago

 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:

  1. Open Flex Builder 2
  2. Create a helloActionscript project
    1. In Flex Builder, select File > New> Flex Project,
    2. Select Basic, and then click Next
    3. Type helloActioncript as the Project Name
    4. Select your code base location (in my case C:\codebase\flex\hello)
    5. Click on Finish
    6. helloActionscript project on Flex Bulder 2
  3. Create HelloWorld ActionScript class
    1. Select File > New > ActionScript File
    2. Click on Finish
    3. HelloWorld.as
    4. Add the following ocde to HelloWorld.as
    5. package

      {

          public class HelloWorld

          {

              public function greeting():String

              {

                  return "Hello World!";

              }

          }

      }

  4. Update the HelloActionscript application to use the HelloWorld.as class
    1. Open the HelloActionscript.mxml file adn replace it for hte following code
    2. <?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>

  5. Run your application
    1. Run/Run/helloActionscript

 

Comments (0)

You don't have permission to comment on this page.