Beginners: ActionScript 3.0 (1): Hello World

Source: Internet
Author: User
Introduction:

ActionScript was developed for its flash product by Macromedia (which has been acquired by Adobe). It was initially a simple scripting language. The latest version 3.0 is a completely object-orientedProgramming LanguagePowerful, rich class libraries, similar to JavaScript syntax, mostly used for flash interactive, entertaining, and practical development, web page creation and RIA applicationsProgramDevelopment.
ActionScript is an ecmascript-based scripting language that can be used to compile Adobe Flash animations and applications. Since both ActionScript and JavaScript are based on the ecmascript syntax, theoretically they can be smoothly translated from one language to another. However, JavaScript's Document Object Model (DOM) is based on browser windows, documents and forms, while the Document Object Model (DOM) of ActionScript is based on SWF animation, which can include animation, audio, text and event processing.
Development Platform: Adobe Flash CS3, (Adobe Flash CS2 only supports ActionScript 1.0 and ActionScript 2.0 ).
Example:

After making a button, the screen displays "Hello World ". 1. Open Flash CS3 and create a new "Flash file (ActionScript 3.0 )". 2. Press Ctrl + F7 to open the "components" Panel, find the label and button controls in "User Interface", and place them in the work zone. 3. Name lable and button respectively "mylable and mybutton ". 4. Select the current frame and press F9 to open the action panel. (If the frame is selected correctly, the title of the open action panel is "action-frame ") 5. Write control statements on the Action panel.
// Declare a string variable and assign a value
VaR STR: String =   " Hello World " ;

// Declare a mouse event
VaR Myclick: Function =   Function (EVT: mouseevent)
{
Mylable. Text = STR;
}

// Add a click event to mybutton
Mybutton. addeventlistener ( " Click " , Myclick );


6. Press Ctrl + enter to view the running effect.
Extension:Display HTML with lableCode.The control statement is changed:


// Declare a string variable and assign a value
VaR Strhtml: String =   " <Font color = '# ff0000' size = '24'> <a href = \ " HTTP: // Www.isdata.cn \ "> click I to enter the isdata homepage </a> </font> ";

// Declare a mouse event
VaR Myclick: Function =   Function (EVT: mouseevent)
{
Mylable.html text = Strhtml; // Note: It is the htmltext attribute of lable.
}

// Add a click event to mybutton
Mybutton. addeventlistener ( " Click " , Myclick );

Press Ctrl + enter to view the running effect.Running Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.