Thursday, February 28, 2013

Introduction

Note: In this draft of Programming ActionScript 3.0, this chapter includes only heading titles,
with no further content. The following chapters include more complete information:
■ “ActionScript Language and Syntax”
■ “Display Programming”
■ “Working with Strings”
■ “Using Regular Expressions”
■ “Working with XML”
■ “Event Handling”
■ “Networking and Communication”
■ “Client System Environment”
■ “Using the External API”

What Is ActionScript?
Why Use ActionScript?
Documentation Map
Links to other docs
Developer Center
ActionScript in Context
Based on ECMAScript standards
Why ECMAScript compliance is important
One language used by many products: Flash, Flex,
Remoting, Comm Server
What’s New in ActionScript 3.0
New features
Language changes
Performance improvements

Wednesday, February 27, 2013

Getting Started with ActionScript

Note: In this draft of Programming ActionScript 3.0, this chapter includes only heading titles,
with no further content. The following chapters include more complete information:
■ “ActionScript Language and Syntax”
■ “Display Programming”
■ “Working with Strings”
■ “Using Regular Expressions”
■ “Working with XML”
■ “Event Handling”
■ “Networking and Communication”
■ “Client System Environment”
■ “Using the External API”

A basic ActionScript development process
Designing your ActionScript Application
Creating ActionScript Code
Options for organizing your code
Storing code on frames in a Flash timeline
Embedding code in Flex MXML files
Storing code in separate ActionScript files
Creating the HelloWorld class
Creating a Flash or Flex application that uses your ActionScript code
Using external ActionScript files in your application
Referencing the HelloWorld class
Publishing and testing your ActionScript application
Enhancing the Hello World application

Tuesday, February 26, 2013

ActionScript Language and Syntax

ActionScript 3.0 comprises both the core ActionScript language and the Flash Player Application Programming Interface (API). The core language is the part of ActionScript that implements the draft ECMAScript (ECMA-262) edition 4 language specification. The Flash Player API provides programmatic access to Flash Player.
This chapter provides a brief introduction to the core ActionScript language and syntax. After reading this chapter, you should have a basic understanding of how to work with data types and variables, how to use proper syntax, and how to control the flow of data in your program. 



Monday, February 25, 2013

Language Overview

Objects lie at the heart of the ActionScript 3.0 language—they are its fundamental building blocks. Every variable you create, every function you write, and every class instance you instantiate is an object. You can think of an ActionScript 3.0 program as a group of objects that carry out tasks, respond to events, and communicate with one another.

Programmers familiar with object-oriented programming (OOP) in Java or C++ may think of objects as modules that contain two kinds of members: data stored in member variables or properties, and behavior accessible through methods. ECMAScript, the standard upon which ActionScript 3.0 is based, defines objects in a similar, but slightly different way. In ECMAScript, objects are simply collections of properties. These properties are containers that can hold not only data, but also functions or other objects. If a function is attached to an object in this way, it is called a method. While the ECMAScript definition may seem a little
odd to programmers with a Java or C++ background, in practice, defining object types with ActionScript 3.0 classes is very similar to the way classes are defined in Java or C++. The distinction between the two definitions of object is important when discussing the ActionScript object model and other advanced topics, but in most other situations the term properties means class member variables as opposed to methods. The ActionScript Language Reference, for example, uses the term properties to mean variables or getter/setter properties, and the term methods to mean functions that are part of a class.

One subtle difference between classes in ActionScript and classes in Java or C++ is that in ActionScript, classes and are not just abstract entities. ActionScript classes are represented by class objects that store the class’s properties and methods. This allows for techniques that may seem alien to Java and C++ programmers, such as including statements or executable code at the top-level of a class or package. Another difference between ActionScript classes and Java or C++ classes is that every ActionScript class has something called a prototype object. In previous versions of ActionScript, prototype objects linked together into prototype chains served collectively as the foundation of the entire class inheritance hierarchy. In ActionScript 3.0, however, prototype objects play only a small role in the inheritance system. The prototype object can still be useful, however, as an alternative to static properties and methods if you want to share a property and its value among all the instances of a class.
In the past, advanced ActionScript programmers could directly manipulate the prototype chain with special built-in language elements. Now that the language provides a more mature implementation of a class-based programming interface, many of these special language elements, such as __proto__ and __resolve are no longer part of the language. Moreover, optimizations of the internal inheritance mechanism that provide significant Flash Player performance improvements preclude direct access to the inheritance mechanism.

Sunday, February 24, 2013

Objects and Classes


In ActionScript 3.0 every object is defined by a class. A class can be thought of as a template or a blueprint for a type of object. Class definitions can include variables and constants, which hold data values, and methods, which are functions that encapsulate behavior bound to the class. The values stored in properties can be primitive values or other objects. Primitive values are numbers, strings, or Boolean values.
ActionScript contains a number of built-in classes that are part of the core language. Some of these built-in classes, such as Number, Boolean and String, represent the primitive values available in ActionScript. Others, such as the Array, Math, and XML classes, define more complex objects that are part of the ECMAScript standard.
All classes, whether built-in or user-defined, derive from the Object class. For programmers with previous ActionScript experience, it is important to note that the Object data type is no longer the default data type, even though all other classes still derive from it. In ActionScript 2.0, the following two lines of code were equivalent because the lack of a type annotation meant that a variable would be of type Object:
var someObj:Object;
var someObj;
ActionScript 3.0, however, introduces the concept of untyped variables, which can be designated in the following two ways:
var someObj:*;
var someObj;
An untyped variable is not the same as a variable of type Object. The key difference is that untyped variables can hold the special value undefined, while a variable of type Object cannot hold that value.
You can define your own classes using the class keyword. You can declare class properties in three ways: constants can be defined with the const keyword, variables are defined with the var keyword, and getter and setter properties are defined by using the get and set attributes in a method declaration. You can declare methods with the function keyword.
You create an instance of a class by using the new operator. The following example creates an instance of the Date class called myBirthday.
var myBirthday:Date = new Date();

Saturday, February 23, 2013

Packages and Namespaces


Packages and namespaces are related, but different, concepts. Packages allow you to bundle class definitions together in a way that facilitates code sharing and minimizes naming conflicts. Namespaces allow you to control the visibility of identifiers, such as property and method names, and can be applied to code whether it resides inside or outside of a package. Packages let you organize your class files, and namespaces let you manage the visibility of properties and methods.
Programming Actionscript 3. Powered by Blogger.