Getting Started with Java programmer ActionScript 3

Source: Internet
Author: User
Tags constructor

Let's face it: The client is never a friendly place for Java programmers. Java's technology at the client side, including applets, swing, and JavaFX, has so far yielded only limited results. JavaScript has almost no place like the Java language except for its name. and Adobe Flash, it does look like JavaScript, really? It may have been a few years ago that Flash was as understandable as JavaScript, but as ActionScript 3 appeared, everything changed. And I'm sure you'll like a lot of it.

First, the ActionScript-oriented programming language for Adobe Flex and Flash is now strongly typed. It is also a first-class object-oriented language, including classes and interfaces. It also has what you can't find in Java--specifically, it contains the get and set methods for attributes, and a language extension called ECMAScript for XML (E4X) that converts any XML document into objects so that you can pass "." Operators directly refer to them, just like normal objects.

This article will guide you through the basics of ActionScript and show how different it is from your familiar Java environment. In the end, you will give up any bias against ActionScript and begin to be interested in playing with it. One of the greatest things about Flex, Flash, and ActionScript is that they are completely free. Just download the Adobe Flex Builder 3 to start. Flex Builder is a complex integrated development environment (IDE) and is not free, but the Flex Software Development Kit (SDK) used to build flash applications is completely free.

One piece of advice to the language enthusiasts who read this article is that I am not a language teacher, so I may be ignoring the details of some languages. And I'm not going to show all of ActionScript 3 in this article. If you really need this content, there are a lot of great ActionScript 3 books. What I can give you is your first feeling about the language. Let's get started.

Classes and Interfaces

Like Java, everything is an object in ActionScript 3. Although there are some basic types, such as integers, everything is an object except these. Similarly, like Java, ActionScript also has namespaces and packages, such as com.jherrington.animals, that represent classes under Company/jack herrington/animal. You can put the class in the default namespace, but the better way is for you to control your own namespace.

To define a class, you use the class keyword, which is the same as Java. Take a look at the example:

package com.jherrington.animals
{
   public class Animal
   {
     public function Animal()
     {
     }
   }
}

In this example, I have defined a animal class and a constructor that does nothing. I can also easily add some member variables and refine this constructor, see examples:

package com.jherrington.animals
{
   public class Animal
   {
     public var name:String = "";
     private var age:int = 0;
     private function Animal( _name:String, _age:int = 30 )
     {
       name = _name;
       age = _age;
     }
   }
}

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.