Embed
Email

ActionScript

Document Sample

Shared by: roy ashbrook
Categories
Tags
Stats
views:
1
posted:
2/7/2012
language:
pages:
6
From Wikipedia, the free encyclopedia ActionScript









ActionScript

ActionScript Flash MX 2004 introduced ActionScript 2.0, a script-

ing programming language more suited to the develop-

ment of Flash applications. It is often possible to save

time by scripting something rather than animating it,

which usually also enables a higher level of flexibility

when editing.

Paradigm(s) Multi-paradigm: object-oriented

Since the arrival of the Flash Player 9 alpha (in 2006)

(prototype-based), functional,

imperative, scripting a newer version of ActionScript has been released, Ac-

tionScript 3.0. ActionScript 3.0 is an object-oriented pro-

Appeared in 1998 gramming language allowing far more control and code

Designed by Gary Grossman reusability when building complex Flash applications.

This version of the language is intended to be compiled

Developer Macromedia (now Adobe Systems)

and run on a version of the ActionScript Virtual Machine

Stable release 3.0 (June 27, 2006 (2006-06-27)) that has been itself completely re-written from the

ground up (dubbed AVM2).[2] Because of this, code writ-

Typing strong, static

discipline ten in ActionScript 3.0 is generally targeted for Flash

Player 9 and higher and will not work in previous ver-

Major Adobe Flash, Adobe Flex sions. At the same time, ActionScript 3.0 executes up to

implementations

10 times faster than legacy ActionScript code.[3]

Influenced by JavaScript, Java Flash libraries can be used with the XML capabilities

of the browser to render rich content in the browser.

OS Cross-platform

This technology is known as Asynchronous Flash and

ActionScript XML, much like AJAX. Adobe offers its Flex product line

to meet the demand for Rich Internet Applications built

Filename extension .as

on the Flash runtime, with behaviors and programming

Internet media type application/ecmascript[1] done in ActionScript. ActionScript 3.0 forms the founda-

tion of the Flex 2 API.

ActionScript is an object-oriented language originally de-

veloped by Macromedia Inc. (now owned by Adobe Sys-

tems). It is a dialect of ECMAScript (meaning it is a su-

History

perset of the syntax and semantics of the language more Action Script started as an object-oriented language for

widely known as JavaScript), and is used primarily for Macromedia’s Flash authoring tool, now developed by

the development of websites and software targeting the Adobe Systems as Adobe Flash. The first three versions

Adobe Flash Player platform, used on Web pages in the of the Flash authoring tool provided limited interactivity

form of embedded SWF files. The language itself is open- features. Early Flash developers could attach a simple

source in that its specification is offered free of charge command, called an "action", to a button or a frame.

and both an open source compiler (as part of Adobe Flex) The set of actions was basic navigation controls, with

and open source virtual machine (Mozilla Tamarin) are commands such as "play", "stop", "getURL", and "go-

available. toAndPlay".

ActionScript was initially designed for controlling With the release of Flash 4 in 1999, this simple set

simple 2D vector animations made in Adobe Flash (for- of actions became a small scripting language. New capa-

merly Macromedia Flash). Initially focused on animation, bilities introduced for Flash 4 included variables, expres-

early versions of Flash content offered few interactivity sions, operators, if statements, and loops. Although re-

features and thus had very limited scripting capability. ferred to internally as "ActionScript", the Flash 4 user

Later versions added functionality allowing for the cre- manual and marketing documents continued to use the

ation of Web-based games and rich Internet applications term "actions" to describe this set of commands.

with streaming media (such as video and audio). Today,

ActionScript is suitable for use in some database applica-

tions, and in basic robotics, as with the Make Controller

Kit.



1

From Wikipedia, the free encyclopedia ActionScript





Timeline by player version Timeline by ActionScript version

• : The first version with scripting support. Actions 2000–2003: ActionScript "1.0" With the release of Flash

included gotoAndPlay, gotoAndStop, nextFrame and 5 in September 2000, the "actions" from Flash 4 were

nextScene for timeline control. enhanced once more and named "ActionScript" for the

• : Expanded basic scripting support with the ability to first time.[6] This was the first version of ActionScript

load external SWFs (loadMovie). with influences from JavaScript and the ECMA-262 (Third

• : First player with a full scripting implementation Edition) standard, supporting the said standard’s object

(called Actions). The scripting was a flash based model and many of its core data types. Local variables

syntax and contained support for loops, conditionals, may be declared with the var statement, and user-de-

variables and other basic language constructs. fined functions with parameter passing and return val-

• : Included the first version of ActionScript. Used ues can also be created. Notably, ActionScript could now

prototype-based programming based on also be typed with a text editor rather than being assem-

ECMAScript, and allowed full procedural bled by choosing actions from drop-down lists and dia-

programming and object-oriented programming. log box controls. With the next release of its authoring

• : Added an event handling model, accessibility tool, Flash MX, and its corresponding player, Flash Player

controls and support for switch. The first version 6, the language remained essentially unchanged; there

with support for the AMF and RTMP protocols which were only minor changes, such as the addition of the

allowed for on demand audio/video streaming. switch statement and the "strict equality" (===) oper-

• : Additions include CSS styling for text and support ator, which brought it closer to being ECMA-262-compli-

for ActionScript 2.0, a programming language based ant. Two important features of ActionScript that distin-

on the ECMAScript 4 Netscape Proposal with class- guish it from later versions are its loose type system and

based inheritance. However, ActionScript 2.0 can its reliance on prototype-based inheritance. Loose typ-

cross compile to ActionScript 1.0 byte-code, so that it ing refers to the ability of a variable to hold any type

can run in Flash Player 6. of data. This allows for rapid script development and

• : Further extended ActionScript 1/ActionScript 2 by is particularly well-suited for small-scale scripting pro-

adding new class libraries with APIs for controlling jects. Prototype-based inheritance is the ActionScript 1.0

bitmap data at run-time, file uploads and live filters mechanism for code reuse and object-oriented program-

for blur and dropshadow. ming. Instead of a class keyword that defines common

• : Added ActionScript 3.0 with the advent of a new characteristics of a class, ActionScript 1.0 uses a special

virtual machine, called AVM2 (ActionScript Virtual object that serves as a "prototype" for a class of objects.

Machine 2), which coexists with the previous AVM1 All common characteristics of a class are defined in the

needed to support legacy content. Performance class’s prototype object and every instance of that class

increases were a major objective for this release of contains a link to that prototype object.

the player including a new JIT compiler. Support for 2003–2006: ActionScript 2.0 The next major revision

binary sockets, E4X XML parsing, full-screen mode of the language, ActionScript 2.0, was introduced in

and Regular Expressions were added. This is the first September 2003 with the release of Flash MX 2004 and its

release of the player to be titled Adobe Flash Player. corresponding player, Flash Player 7. In response to user

• : Added basic 3D manipulation, such as rotating on demand for a language better equipped for larger and

the X, Y, and Z axis, a 3D drawing API, and texture more complex applications, ActionScript 2.0 featured

mapping. Ability to create custom filters using Adobe compile-time type checking and class-based syntax, such

Pixel Bender. Several visual processing tasks are now as the keywords class and extends. (While this al-

offloaded to the GPU which gives a noticeable lowed for a more structured object-oriented program-

decrease to rendering time for each frame, resulting ming approach, the code would still be compiled to Ac-

in higher frame rates, especially with H.264 video. tionScript 1.0 bytecode, allowing it to be used on the pre-

There is a new sound API which allows for custom ceding Flash Player 6 as well. In other words, the class-

creation of audio in flash, something that has never based inheritance syntax was a layer on top of the exist-

been possible before.[4] Furthermore, Flash Player 10 ing prototype-based system.) With ActionScript 2.0, de-

supports Peer to Peer (P2P) communication with velopers could constrain variables to a specific type by

Real Time Media Flow Protocol (RTMFP). adding a type annotation so that type mismatch errors

• : The major addition in this version are advanced could be found at compile-time. ActionScript 2.0 also in-

(graphics accelerated) 3D capabilities. Other features troduced class-based inheritance syntax so that devel-

include H.264 encoding for cameras, Native JSON opers could create classes and interfaces, much as they

support, Cubic Bézier Curves, a secure random would in class-based languages such as Java and C++. This

number generator, LZMA compression for swf files version conformed partially to the ECMAScript Fourth

as well as some other minor additions. [5] Edition draft specification.





2

From Wikipedia, the free encyclopedia ActionScript





2006–today: ActionScript 3.0 In June 2006, Ac- ActionScript 2.0

tionScript 3.0 debuted with Adobe Flex 2.0 and its cor-

The following code, which works in any compliant play-

responding player, Flash Player 9. ActionScript 3.0 was a

er, creates a text field at depth 0, at position (0, 0) on the

fundamental restructuring of the language, so much so

screen (measured in pixels), that is 100 pixels wide and

that it uses an entirely different virtual machine. Flash

high. Then the text parameter is set to the "Hello,

Player 9 contains two virtual machines, AVM1 for code

world" string, and it is automatically displayed in the

written in ActionScript 1.0 and 2.0, and AVM2 for content

player:

written in ActionScript 3.0. Actionscript 3.0 added limit-

ed support for hardware acceleration (DirectX, OpenGL).

createTextField("greet", 0, 0, 0, 100, 100);

The update to the language introduced several new

greet.text = "Hello, world";

features:

• Compile-time and run-time type checking—type When writing external ActionScript 2.0 class files the

information exists at both compile-time and above example could be written in a file named

runtime. Greeter.as as following.

• Improved performance from a class-based

inheritance system separate from the prototype- class com.example.Greeter extends MovieClip

based inheritance system. {

• Support for packages, namespaces, and regular public function Greeter() {}

expressions. public function onLoad():Void

• Compiles to an entirely new type of bytecode, {

incompatible with ActionScript 1.0 and 2.0 bytecode. var txtHello:TextField = this.createTextF

• Revised Flash Player API, organized into packages. txtHello.text = "Hello, world";

• Unified event handling system based on the DOM }

event handling standard. }

• Integration of ECMAScript for XML (E4X) for

purposes of XML processing. ActionScript 3.0

• Direct access to the Flash runtime display list for

ActionScript 3.0 has a similar syntax to ActionScript 2.0

complete control of what gets displayed at runtime.

but a different set of APIs for creating objects. Compare

• Completely conforming implementation of the

the script below to the previous ActionScript 2.0 version:

ECMAScript fourth edition draft specification.

• Limited support for dynamic 3D objects. (X, Y, Z var greet:TextField = new TextField();

rotation, and texture mapping) greet.text = "Hello World";

this.addChild(greet);

Flash Lite

• : Flash Lite is the Flash technology specifically Minimal ActionScript 3.0 programs may be somewhat

developed for mobile phones and consumer larger and more complicated due to the increased sepa-

electronics devices. Supports Flash 4 ActionScript. ration of the programming language and the Flash IDE.

• : Flash 4 ActionScript support and additional device Presume the following file to be Greeter.as:

APIs added.

• : Added support for Flash 7 ActionScript 2.0 and package com.example

some additional fscommand2 API. {

• : Added support for Flash 8 ActionScript 2.0 and also import flash.text.TextField;

FLV video playback. import flash.display.Sprite;

• : Added support for Flash 10 ActionScript 3.0 as a

browser plugin and also hardware graphics public class Greeter extends Sprite

acceleration. {

public function Greeter()

{

Syntax var txtHello:TextField = new TextFiel

ActionScript code is free form and thus may be created txtHello.text = "Hello World";

with whichever amount or style of whitespace that the addChild(txtHello);

author desires. The basic syntax is derived from }

ECMAScript. }

}



(See also: Sprite)



3

From Wikipedia, the free encyclopedia ActionScript





Actionscript 3 can also be used in MXML files when • - A Load Variables object allows for the storing and

using Adobe’s Flex framework: send of HTTP POST and HTTP GET variables





ActionScript 3 primitive (prime) data types (see Data type

descriptions)

• - The Boolean data type has only two possible values:

the Object class.

• - The Number data type can represent integers,

unsigned integers, and floating-point numbers. The

uses the 64-bit double-precision

Number data type

format as specified by the IEEE Standard for Binary

Floating-Point Arithmetic (IEEE-754). values between

Data structures -9,007,199,254,740,992 (-253) to 9,007,199,254,740,992

(253) can be stored.

• - The String data type represents a sequence of

Data types 16-bit characters. Strings are stored internally as

ActionScript primarily consists of "fundamental" or Unicode characters, using the UTF-16 format.

"simple" data types which are used to create other data Previous versions of Flash used the UTF-8 format.

types. These data types are very similar to Java data • - The uint (Unsigned Integer) data type is a 32-bit

types. Since ActionScript 3 was a complete rewrite of Ac- unsigned integer between 0 and 4,294,967,295.

tionScript 2, the data types and their inheritances have • - The void data type contains only one value,

changed. undefined. In previous versions of ActionScript,

ActionScript 2 top level data types undefined was the default value for instances of the

• - A list of characters such as "Hello World" Object class. In ActionScript 3.0, the default value for

• - Any Numeric value Object instances is null.

• - A simple binary storage that can only be "true" or ActionScript 3 some complex data types (see Data type

"false". descriptions)

• - Object is the data type all complex data types • - The Object data type is defined by the Object class.

inherit from. It allows for the grouping of methods, The Object class serves as the base class for all class

functions, parameters, and other objects. definitions in ActionScript. Objects in their basic

ActionScript 2 complex data types form can be used as associative arrays that contain

There are additional "complex" data types. These are key-value pairs, where keys are Strings and values

more processor and memory intensive and consist of may be any type.

many "simple" data types. For AS2, some of these data • - Contains a list of data. Though ActionScript 3 is a

types are: strongly typed language, the contents of an Array

• - An ActionScript creation that allows easy usage of may be of any type and values must be cast back to

visible objects. their original type after retrieval. (Support for typed

• - A simple dynamic or input text field. Inherits the Arrays has recently been added with the Vector

Movieclip type. class.)

• - A simple button with 4 frames (states): Up, Over, • - A variant of array supported only when publishing

Down and Hit. Inherits the MovieClip type. for Flash Player 10 or above. Vectors are typed,

• - Allows access to information about a specific point dense Arrays (values must be defined or null) which

in time. may be fixed-length, and are bounds-checked during

• - Allows linear storage of data. retrieval. Vectors are not just more typesafe than

• - An XML object Arrays but also perform faster.

• - An XML node



4

From Wikipedia, the free encyclopedia ActionScript





• - Dictionaries are a variant of Object that may erence types. In ActionScript, all variables are reference

contain keys of any data type (whereas Object always types. However, objects that belong to the primitive data

uses strings for its keys). types, which includes Boolean, Number, int, uint, and

• - A display object container without a timeline. String, have special operators that make them behave as

• - Animated movie clip display object; Flash timeline if they were passed by value.[7]

is, by default, a MovieClip. So if a variable of a supposedly primitive type, e.g.

• - A non-animated bitmap display object. an integer is passed to a function, altering that variable

• - A non-animated vector shape object. inside the function will not alter the original variable

• - Contains an array of binary byte data. (passed by value). If a variable of another (not primitive)

• - A dynamic, optionally interactive text field object. datatype, e.g. XML is passed to a function, altering that

• - A simple interactive button type supporting "up", variable inside the function will alter the original vari-

"over", and "down" states with an arbitrary hit area. able as well (passed by reference).

• - A date object containing the date/time digital Some data types can be assigned values with literals:

representation.

• - A generic error object that allows runtime error var item1:String="ABC";

reporting when thrown as an exception. var item2:Boolean=true;

• - The core class for all Flash method definitions. var item3:Number=12;

• - A regular expression object for strings. var item4:Array=["a","b","c"];

• - A video playback object supporting direct var item5:Object={name:"Actionscript",version:"3.

(progressive download) or streaming (RTMP) var item6:XML = ; //Note tha

transports. As of Flash Player version 9.0.115.0, the

H.264/MP4 high-definition video format is also A reference in ActionScript is a pointer to an instance of

supported along side standard Flash video (FLV) a class. This does not create a copy but accesses the same

content. memory space. All objects in ActionScript are accessed as

• - A revised XML object based on the E4X (Standard references instead of being copied.

ECMA-357); nodes and attributes are accessed

var item1:XML=new XML("");

differently from ActionScript 2.0 object (a legacy

var item2:XML=item1;

class named XMLDocument is provided for

item2.firstChild.attributes.value=13;

backwards compatibility).

//item1 now equals item2 since item2 simply point

• - An array-based object for various content lookups

//Both are now:

in the XML class.

//

Using data types Only references to an object may be removed by using

The basic syntax is: the "delete" keyword. Removal of actual objects and data

is done by the Flash Player garbage collector which

checks for any existing references in Param2, ...,

var yourVariableName:YourVariableType = new YourVariableType(Param1,the Flash memory ParamN);

space. If none are found (no other reference is made

So in order to make an empty Object:

to the orphaned object), it is removed from memory.

var myObject:Object = new Object(); For this reason, memory management in ActionScript re-

quires careful application development planning.

Some types are automatically put in place:

var item1:XML=new XML("");

var myString:String = "Hello Wikipedia!"; delete item1; automatically set the variable as

// This would

//If same for a number. to item1 is present anywh

var myNumber:Number = 5; // This would do the no other reference

//it will be removed on the garbage collector’s n

var myObject:Object = {Param1:"Hi!", Param2:76}; //This creates an object with two variabl

// Param1 is a string with the data of "Hi!",

// and Param2 is a number with the data of 76. ActionScript code protection

Often, Flash is the syntax that automatically creatin

var myArray:Array = [5,"Hello!",{a:5, b:7}] //Thisdevelopers will decidefor while they desire

//It creates an Array with 3 variables. the advantages that Flash affords them in the areas of

//The first (0) is a number with the value of 5, and interactivity, they do not wish to expose

animation

//the second (1) is a string with the value of "Hello!", However, as with all intermedi-

their code to the world.

//and the third (2) is an object with {a:5, b:7}. compiled code, once a .swf file is saved lo-

ate language

cally, it can be decompiled into its source code and assets.

Unlike some object-oriented languages, ActionScript Some decompilers are capable of nearly full reconstruc-

makes no distinction between primitive types and ref- tion of the original source file, down to the actual code



5

From Wikipedia, the free encyclopedia ActionScript





that was used during creation (although results vary on a [5] "Flash Player 11 and AIR 3 Release Notes for Adobe

case-by-case basis).[8][9][10] Labs". http://download.macromedia.com/pub/

In opposition to the decompilers, ActionScript ob- labs/flashplatformruntimes/shared/

fuscators have been introduced to solve this problem. flashplayer11_air3_b1_releasenotes_071311.pdf.

Higher-quality obfuscators implement lexical transfor- [6] Note that the name "ActionScript 1.0" is a

mations — such as identifier renaming, control flow retronym, coined after the release of ActionScript

transformation, and data abstraction transformation — 2.0.

that make it harder for decompilers to generate output [7] "Flex 3 - Function parameters".

likely to be useful to a human. Less robust obfuscators in- Livedocs.adobe.com. http://livedocs.adobe.com/

sert traps for decompilers. flex/3/html/03_Language_and_Syntax_19.html.

Retrieved 2009-12-17.

References [8] Third party review of another decompiler

[9] Customer comments on one Flash decompiler

[1] RFC 4329 (limit compatible with EcmaScript) [10] Customer comments on another Flash product

[2] Brimelow, Lee (2008-08-18). "Six reasons to use

ActionScript 3.0". Adobe Systems Incorporated.

http://www.adobe.com/devnet/actionscript/

External links

articles/six_reasons_as3.html. Retrieved • ActionScript Technology Center

2010-06-18. • ActionScript 2.0 Language Reference

[3] Grossman, Gary; Huang, Emmy (2006-06-27). • ActionScript 3.0 Language & Component Reference

"ActionScript 3.0 overview". Adobe Systems • Language Elements

Incorporated. http://www.adobe.com/devnet/ • Package Summary

actionscript/articles/actionscript3_overview.html. • Appendixes

Retrieved 2010-06-18. • Flex 3 LiveDocs: Programming ActionScript 3.0

[4] "Adobe Labs - Adobe Flash Player 10.1". • Adobe - Flash Developer Center

Labs.adobe.com. http://labs.adobe.com/ • Adobe Flex SDK

technologies/flashplayer10/. Retrieved • Adobe’s Flash Forum

2009-12-17. • Another non-Adobe ActionScript 3.0 Compiler

• EverythingFLA online ActionScript 3.0 School









Retrieved from "http://en.wikipedia.org/w/index.php?title=ActionScript&oldid=475313974"



Categories:

• Adobe Flash

• Scripting languages

• JavaScript programming language family

• Prototype-based programming languages





This page was last modified on 6 February 2012 at 00:20. Text is available under the Creative Commons Attribution-

ShareAlike License; additional terms may apply. See Terms of use for details. Wikipedia® is a registered trademark of

the Wikimedia Foundation, Inc., a non-profit organization.Contact us

Privacy policy About Wikipedia Disclaimers



6



Related docs
Other docs by roy ashbrook
Philip_Taaffe
Views: 53  |  Downloads: 0
Philip_Dodd__broadcaster_
Views: 43  |  Downloads: 0
Philippa_of_Champagne
Views: 41  |  Downloads: 0
Philadelphians
Views: 30  |  Downloads: 0
Phaansi
Views: 27  |  Downloads: 0
Peykasa
Views: 25  |  Downloads: 0
Pet_door
Views: 47  |  Downloads: 0
Peter_Rice__Chairman_of_Fox_Broadcasting_
Views: 40  |  Downloads: 0
Perittia_farinella
Views: 20  |  Downloads: 0
Perissoza_scripta
Views: 24  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!