Citizendia
Your Ad Here

ActionScript
Paradigm Multi-paradigm
Appeared in 1998
Designed by Gary Grossman
Developer Macromedia, Adobe Systems
Latest release 3. A programming paradigm is a fundamental style of Computer programming. A multi-paradigm programming language is a Programming language that supports more than one Programming paradigm. Year 1998 ( MCMXCVIII) was a Common year starting on Thursday (link will display full 1998 Gregorian calendar) A software developer is a person or organization concerned with facets of the software development process wider than design and coding a somewhat broader scope of Macromedia was a North American graphics and Web development Software house headquartered in San Francisco, California producing such products Adobe Systems Incorporated (pronounced a-DOE-bee əˈdoʊbiː ( is an American Computer software company headquartered in San Jose California A software release is the distribution whether public or private of an initial or new and upgraded version of a Computer software product 0/ June 27, 2006
Typing discipline strong, static, safe
Major implementations Adobe Flash, Adobe Flex
Influenced by JavaScript, Java
OS Cross-platform
ActionScript
File name extension . In Computer science, a type system defines how a Programming language classifies values and expressions into '''types''', how it can In Computer science and Computer programming, the term strong typing is used to describe those situations where Programming languages specify one or more In Computer science, a type system defines how a Programming language classifies values and expressions into '''types''', how it can In Computer science, type safety is a property of some Programming languages that is defined differently by different communities but most definitions involve Implementation is the realization of an application or execution of a Plan, idea Model, Design, Specification, standard, Algorithm Adobe Flash (previously called Shockwave Flash and Macromedia Flash) is a set of Multimedia software created by Macromedia and currently Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform Rich Internet applications based on the proprietary JavaScript is a Scripting language most often used for Client-side web development An operating system (commonly abbreviated OS and O/S) is the software component of a Computer system that is responsible for the management and coordination In computing cross-platform (also known as multi-platform) is a term used to refer to Computer software or computing methods and concepts that are implemented A filename extension is a suffix to the name of a Computer file applied to indicate the encoding convention ( File format) of its contents as
Internet media type application/actionscript[1]

ActionScript is a scripting language based on ECMAScript. An Internet media type, originally called a MIME type after MIME and sometimes a Content-type after the name of a header in several protocols whose value ECMAScript is a Scripting language, standardized by Ecma International in the ECMA-262 specification. ActionScript is used primarily for the development of websites and software using the Adobe Flash Player platform (in the form of SWF files embedded into Web pages), but is also used in some database applications (such as Alpha Five). The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe Alpha Five a Relational database management system and Rapid Application Development system (RAD for building Windows desktop and Web (including AJAX applications Originally developed by Macromedia, the language is now owned by Adobe (which acquired Macromedia in 2005), which continues its development. Macromedia was a North American graphics and Web development Software house headquartered in San Francisco, California producing such products Adobe Systems Incorporated (pronounced a-DOE-bee əˈdoʊbiː ( is an American Computer software company headquartered in San Jose California ActionScript was initially designed for controlling simple 2D vector animations made in Adobe Flash (formerly Macromedia Flash). Adobe Flash (previously called Shockwave Flash and Macromedia Flash) is a set of Multimedia software created by Macromedia and currently Later versions added functionality allowing for the creation of Web-based games and rich Internet applications with streaming media (such as video and audio). Rich Internet applications (RIAs are Web applications that have the features and functionality of traditional desktop applications.

Contents

History

ActionScript started as a scripting language for the Adobe Flash authoring tool. "Scripting" redirects here For other uses see Script. Adobe Flash (previously called Shockwave Flash and Macromedia Flash) is a set of Multimedia software created by Macromedia and currently The first three versions of the Flash authoring tool provided limited interactivity features. Early Flash developers could attach a simple command, called an "action", to a button or a frame. The set of actions was limited to basic navigation controls, with commands such as "play", "stop", "get URL", and "goto and play".

With the release of Flash 4 in 1999, this simple set of actions matured into a small scripting language. "Scripting" redirects here For other uses see Script. New capabilities introduced for Flash 4 included variables, expressions, operators, if statements, and loops. A variable (ˈvɛərɪəbl is an Attribute of a physical or an abstract System which may change its Value while it is under Observation. An expression in a Programming language is a combination of values Variables operators and functions that are interpreted ( Programming languages generally support a set of operators that are similar to operators in mathematics. In Computer science, conditional statements, conditional expressions and conditional constructs are features of a Programming language which In Computer science control flow (or alternatively flow of control refers to the order in which the individual statements, instructions or Function Although referred to internally as "ActionScript", the Flash 4 user manual and marketing documents continued to use the term "actions" to describe this set of commands .

Timeline by player

Example of ActionScript 2.0 running on Macromedia Flash 8.
Example of ActionScript 2. 0 running on Macromedia Flash 8.

Timeline by ActionScript version

2000–2003: ActionScript "1. 0" With the release of Flash 5 in September 2000, the "actions" from Flash 4 were enhanced once more and named "ActionScript" for the first time. [2] This was the first version of ActionScript with influences from JavaScript and the ECMA-262 (Third Edition) standard, supporting the said standard's object model and many of its core data types. JavaScript is a Scripting language most often used for Client-side web development ECMAScript is a Scripting language, standardized by Ecma International in the ECMA-262 specification. A data type in Programming languages is an attribute of a datum which tells the computer (and the programmer something about the kind of datum it is Local variables may be declared with the var statement, and user-defined functions with parameter passing and return values can also be created. A variable (ˈvɛərɪəbl is an Attribute of a physical or an abstract System which may change its Value while it is under Observation. In Computer science, a subroutine ( function, method, procedure, or subprogram) is a portion of code within a larger In Computer programming, a parameter is a variable which takes on the meaning of a corresponding Argument (computer science is same article--> argument In Computer programming, a return statement causes execution to leave the current Subroutine and resume at the point in the code immediately after where the subroutine Notably, ActionScript could now also be typed with a text editor rather than being assembled by choosing actions from drop-down lists and dialog box controls. With the next release of its authoring tool, Flash MX, and its corresponding player, Flash Player 6, the language remained essentially unchanged; there were only minor changes, such as the addition of the switch statement and the "strict equality" (===) operator, which brought it closer to being ECMA-262-compliant. The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe ECMAScript is a Scripting language, standardized by Ecma International in the ECMA-262 specification. Two important features of ActionScript that distinguish it from later versions are its loose type system and its reliance on prototype-based inheritance. Prototype-based programming is a style of Object-oriented programming in which classes are not present and behavior reuse (known as inheritance in class-based In Object-oriented programming, inheritance is a way to form new classes (instances of which are called objects using classes that have already been defined Loose typing refers to the ability of a variable to hold any type of data. A variable (ˈvɛərɪəbl is an Attribute of a physical or an abstract System which may change its Value while it is under Observation. This allows for rapid script development and is particularly well-suited for small-scale scripting projects. Prototype-based inheritance is the ActionScript 1. 0 mechanism for code reuse and object-oriented programming. Object-oriented programming (OOP is a Programming paradigm that uses " objects " and their interactions to design applications and computer programs Instead of a class keyword that defines common characteristics of a class, ActionScript 1. In Object-oriented programming, a class is a Programming language construct that is used as a blueprint to create objects This blueprint includes attributes 0 uses a special object that serves as a "prototype" for a class of objects. In Object-oriented programming, a class is a Programming language construct that is used as a blueprint to create objects This blueprint includes attributes All common characteristics of a class are defined in the class's prototype object and every instance of that class contains a link to that prototype object. In Object-oriented programming, a class is a Programming language construct that is used as a blueprint to create objects This blueprint includes attributes In Object-oriented programming, a class is a Programming language construct that is used as a blueprint to create objects This blueprint includes attributes In its simplest embodiment an object is an allocated region of storage In Object-oriented programming, a class is a Programming language construct that is used as a blueprint to create objects This blueprint includes attributes

2003–2006: ActionScript 2. 0 The next major revision of the language, ActionScript 2. 0, was introduced in September 2003 with the release of Flash MX 2004 and its corresponding player, Flash Player 7. The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe In response to user demand for a language better equipped for larger and more complex applications, ActionScript 2. 0 featured compile-time type checking and class-based syntax, such as the keywords class and extends. In Computer science, compile time refers to either the operations performed by a Compiler (the "compile-time operations" or Programming language In Computer science, a type system defines how a Programming language classifies values and expressions into '''types''', how it can In Computer science, the syntax of a Programming language is the set of rules that a sequence of characters in a Source code file must follow to be considered as a (While this allowed for a more flexible object-oriented programming approach, the code would still be compiled to ActionScript 1. 0 bytecode, allowing it to be used on the preceding Flash Player 6 as well. Bytecode is a term which has been used to denote various forms of Instruction sets designed for efficient execution by a software interpreter as well as being suitable In other words, the class-based inheritance syntax was a layer on top of the existing prototype-based system. Class-based programming, or more commonly class-orientation, refers to the style of Object-oriented programming in which inheritance is achieved by defining classes In Computer science, the syntax of a Programming language is the set of rules that a sequence of characters in a Source code file must follow to be considered as a Prototype-based programming is a style of Object-oriented programming in which classes are not present and behavior reuse (known as inheritance in class-based ) With ActionScript 2. 0, developers could constrain variables to a specific type by adding a type annotation so that type mismatch errors could be found at compile-time. A variable (ˈvɛərɪəbl is an Attribute of a physical or an abstract System which may change its Value while it is under Observation. In Computer science, compile time refers to either the operations performed by a Compiler (the "compile-time operations" or Programming language ActionScript 2. 0 also introduced class-based inheritance syntax so that developers could create classes and interfaces, much as they would in class-based languages such as Java and C++. In Computer science, the syntax of a Programming language is the set of rules that a sequence of characters in a Source code file must follow to be considered as a C++ (" C Plus Plus " ˌsiːˌplʌsˈplʌs is a general-purpose Programming language. This version conformed partially to the ECMAScript Fourth Edition draft specification. ECMAScript is a Scripting language, standardized by Ecma International in the ECMA-262 specification.

2006–today: ActionScript 3. 0 In June 2006, ActionScript 3. 0 debuted with Adobe Flex 2.0 and its corresponding player, Flash Player 9. Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform Rich Internet applications based on the proprietary The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe ActionScript 3. 0 was a fundamental restructuring of the language, so much so that it uses an entirely different virtual machine. In Computer science, a virtual machine (VM is a Software implementation of a machine (computer that executes programs like a real machine Flash Player 9 contains two virtual machines, AVM1 for code written in ActionScript 1. The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe In Computer science, a virtual machine (VM is a Software implementation of a machine (computer that executes programs like a real machine 0 and 2. 0, and AVM2 for content written in ActionScript 3. 0. ActionScript 3. 0 provides not only a significant enhancement in performance, but also a more robust programming model that lends itself to complex Rich Internet Application development. Rich Internet applications (RIAs are Web applications that have the features and functionality of traditional desktop applications.

The update to the language introduced several new features:

Syntax

ActionScript code is free form and thus may be created with whichever amount or style of whitespace that the author desires. In Computer programming, a free-form language is a Programming language in which the positioning of characters on the page in program text is not significant The basic syntax is similar to the Java programming language.

ActionScript 2. 0

When one is working with the Macromedia Flash IDE, it is possible to use the trace() function to print information in the application's output terminal. Adobe Flash (previously called Shockwave Flash and Macromedia Flash) is a set of Multimedia software created by Macromedia and currently In Computing, an integrated development environment ( IDE) is a Software application that provides comprehensive facilities to Computer programmers If one uses this command, then a very short "legal" program in ActionScript would be the following code on frame 1 of layer 1 in an otherwise empty Flash document:

trace("Hello, world!");

However, due to this command being unused in other interpreters of the language, such as the standard Adobe Flash Player, it is reasonable to suggest that this does not suffice. The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe For such a reason, one can consider the following code instead, which works in any compliant player, as the shortest program instead:[3]

createTextField("greet", 0, 0, 0, 100, 100);
greet. text = "Hello, world!";

This creates a text field at depth 0, at location 0, 0 px on the screen, that is 100 px wide and high. Then the "text" parameter is set to the "Hello, world!" string, and it is automatically displayed in the player.

When writing external ActionScript 2. 0 class files the above example could be written in a file named Greeter. as as following.

class com. example. Greeter extends MovieClip
{
        public function Greeter()
        {
                var txtHello:TextField = this. createTextField("txtHello", 0, 0, 0, 100, 100);
                txtHello. text = "Hello World";
        }
}

ActionScript 3. 0

ActionScript 3. 0 has a similar syntax to ActionScript 2. 0 but different set of APIs for creating objects. Compare the below to the previous ActionScript 2. 0 version:

var greet:TextField = addChild(new TextField()) as TextField;
greet. text = "Hello world";

Minimal ActionScript 3. 0 programs may be somewhat larger and more complicated due to the increased separation of the programming language and the Flash IDE.

Presume the following file to be Greeter. as:

package com. example
{
        import flash. text. TextField;
        import flash. display. Sprite;
 
        public class Greeter extends Sprite
        {
                public function Greeter()
                {
                        var txtHello:TextField = new TextField();
                        txtHello. text = "Hello World";
                        addChild(txtHello);
                }
        }
}

Finally, an example of using ActionScript when developing Flex applications, again presuming the following content to be in a file named Greeter. Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform Rich Internet applications based on the proprietary as:

package 
{
        public class Greeter
        {
                public static function sayHello():String
                {
                        var greet:String = "Hello, world!";
                        return greet;
                }
        }
}

This code will work with the following MXML application file:

<?xml version="1. MXML is an XML -based User interface markup language first introduced by Macromedia in March 2004. 0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www. adobe. com/2006/mxml" xmlns="*" layout="vertical" creationComplete="initApp()">
 
        <mx:Script>
                <![CDATA[
                      public function initApp():void
                      {
                              // Prints our "Hello, world!" message into "mainTxt". 
                              mainTxt. text = Greeter. sayHello();
                      }
              ]]>
        </mx:Script>
 
        <mx:Label id="title" fontSize="24" fontStyle="bold" text='"Hello, world!" Example'/>
        <mx:TextArea id = "mainTxt" width="250"/>   
 
</mx:Application>

Examples

ActionScript 2. 0 examples

The following code prints Hello world to the stage (screen). A "Hello World" program is a Computer program that prints out "Hello world!" on a Display device.

_root. createTextField("myText", 1, 0, 0, 100, 25);
_root. myText. text = "Hello world!";

The following code outputs the current mouse position when the mouse moves, by using the onMouseMove event. Again this will only work in the Flash IDE.

onMouseMove = function ()
{
        trace("X: " + _root. _xmouse);
        trace("Y: " + _root. _ymouse);
};

The following code, when placed on a Button, begins to play the timeline of the MovieClip the button is placed in. In Computing, a button (sometimes known as a command button or Push button) is a widget that provides This also applies to the root timeline since the root is considered a MovieClip as well.

on(release)
{
        play();
}

This more advanced example creates an array containing numbers and strings, and assigns a number to a variable called num and a string to a variable called str using prototype functions and function recursion. Then, using the MovieClip API, a text field is drawn on screen, into which the variable values are written.

Array. prototype. pickNumber = function():Number
{
        var rand:Number = random(this. length);
        return (typeof (this[rand]) == "number") ? this[rand] : this. pickNumber();
};
 
Array. prototype. pickString = function():String
{
        var rand:Number = random(this. length);
        return (typeof (this[rand]) == "string") ? this[rand] : this. pickString();
};
 
var myArray:Array = new Array("Hello", "ActionScript", 3, 7, 11, "Flash");
var num:Number = myArray. pickNumber();
var str:String = myArray. pickString();
_root. createTextField("txt", 1, 10, 10, 530, 390);
txt. text = "Array = " + myArray + "\nRandom Number = " + num + "\nRandom String = " + str;

Array and dataProvider example:

var aData:Array = [{name: "J.  Bell", age: "55"}, {name: "B.  Longman", age: "21"}];
dataGrid. dataProvider = aData;

ActionScript 3. 0 examples

This Hello World example uses ActionScript 3. 0 by Kamran Sarkar:

package
{
        import flash. display. Sprite;
        import flash. text. TextField;
        import flash. filters. DropShadowFilter;
 
        public class HelloWorld2 extends Sprite
        {
                public function HelloWorld2()
                {
                        var shad:DropShadowFilter = new DropShadowFilter (2, 45, 0x000000, 25, 3, 3, 2, 2);
                        var txt:TextField = new TextField();
                        txt. textColor = 0xFFFFFF;
                        txt. filters = [shad];
                        txt. width = 200;
                        txt. x = Math. random() * 300;
                        txt. y = Math. random() * 300;
                        txt. selectable = false;
                        txt. text = "Hello World welcome! [" + Math. round(txt. x) + "," + Math. round(txt. y) + "]";
                        addChild(txt);
                }
        }
}

Data structures

Data types

ActionScript primarily consists of "fundamental" or "simple" data types which are used to create other data types. These data types are very similar to Java data types. Since ActionScript 3 was a complete rewrite of ActionScript 2, the data types and their inheritances have changed.

ActionScript 2 top level data types

ActionScript 2 complex data types

There are additional "complex" data types. These are more processor and memory intensive and consist of many "simple" data types. For AS2, some of these data types are:

ActionScript 3 top level data types (see Data type descriptions)

ActionScript 3 complex data types (see Data type descriptions)

Using data types

Using these data types in ActionScript is quite simple. The basic syntax is:

var yourVariableName:YourVariableType = new YourVariableType(Param1, Param2, . . . , ParamN);

So in order to make an empty Object:

var myObject:Object = new Object();

Some types are automatically put in place:

var myString:String = "Hello Wikipedia!"; // This would automatically set the variable as a string. 
var myNumber:Number = 5; // This would do the same for a number. 
var myObject:Object = {Param1:"Hi!", Param2:76}; //This creates an object with two variables. 
// Param1 is a string with the data of "Hi!",
// and Param2 is a number with the data of 76. 
var myArray:Array = [5,"Hello!",{a:5, b:7}] //This is the syntax for automatically creating an Array. 
//It creates an Array with 3 variables. 
//The first (0) is a number with the value of 5,
//the second (1) is a string with the value of "Hello!",
//and the third (2) is an object with {a:5, b:7}. 

ActionScript 2. 0/3. 0 differentiate between variable `references` and absolute pointers. Pointers retrieve data directly and are duplicated when assigned to a new value. Absolute values are direct assignments of primitive values; those values that make up the core data types in Flash. These include base strings, boolean values, numbers, and basic arrays.

var item1:String="ABC";
var item2:String=item1;
item2+="D";
//item1 is "ABC" but item2 is "ABCD"; the assignment copied the value. 

Primitive values are constructed in the following manner:

var item1:String="ABC";
var item2:Boolean=true;
var item3:Number=12
var item4:Array=["a","b","c"];

A reference in ActionScript is a pointer to an instance of a class. This does not create a copy but accesses the same memory space. As a general rule, any objects created using the "new" keyword will be accessed as references by new variables rather than being copied.

var item1:XML=new XML("<node><child/></node>");
var item2:XML=item1;
item2. firstChild. attributes. value=13;
//item1 now equals item2 since item2 simply points to item1. 
//Both are now:
//<node><child value="13"/></node>

Removal of objects and data is done by the Flash Player garbage collector which checks for any existing references in the Flash memory space. If none are found (no other object is using the orphaned object), it is removed from memory. Only references may be removed by using the "delete" keyword. For this reason, memory management in ActionScript is tricky and requires careful application development planning.

var item1:XML=new XML("<node><child/></node>");
delete item1;
//If no other reference to item1 is present anywhere else in the application, 
//it will be removed on the garbage collector's next pass

Footnotes

  1. ^ RFC 4329
  2. ^ Note that the name "ActionScript 1. 0" is a retronym, coined after the release of ActionScript 2. A retronym is a type of Neologism coined for an old object or concept whose original name has come to be used for something else is no longer unique or is otherwise inappropriate 0.
  3. ^ Note that this is also valid ActionScript "1. 0", the original scripting language of Flash. However, it does not produce a visible text box in Flash Player versions lower than 6, as an embedded font is required. The Adobe Flash Player is a widely distributed proprietary multimedia and application player created by Macromedia and now developed and distributed by Adobe

See also

External links

Adobe documentation and references

Tools and scripts


© 2009 citizendia.org; parts available under the terms of GNU Free Documentation License, from http://en.wikipedia.org
Dapyx Software network: MP3 Explorer | Ebook Manager | Zenithic