FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/ActionScript

ActionScript

Contents
        2006–2020: ActionScript 3.0
    Flash Lite
    AIR
Syntax
    ActionScript 2.0
    ActionScript 3.0
Data structures
    Data types
    Using data types
Code protection

ActionScript
ParadigmMulti-paradigm: object-oriented (prototype-based), functional, imperative, scripting
FamilyECMAScript
Designed byGary Grossman
DeveloperMacromedia (merged into Adobe Systems, 2005)
First appeared1998;28 years ago (1998)
ActionScript
Filename extension
.as
Internet media type===) operator, which brought it closer to being ECMA-262-compliant. Two important features of ActionScript that distinguish it from later versions are its loose type system and its reliance on prototype-based inheritance. Loose typing refers to the ability of a variable to hold any type of data. 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. Instead of a extends. While this allowed for a more structured 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. In other words, the class-based inheritance syntax was a layer on top of the existing prototype-based system. 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. 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++. This version conformed partially to the ECMAScript Fourth Edition draft specification.

2006–2020: ActionScript 3.0

edit

In June 2006, ActionScript 3.0 debuted with Adobe Flex 2.0 and its corresponding player, Flash Player 9. ActionScript 3.0 was a fundamental restructuring of the language, so much so that it uses an entirely different virtual machine. Flash Player 9 contains two virtual machines, AVM1 for code written in ActionScript 1.0 and 2.0, and AVM2 for content written in ActionScript 3.0. ActionScript 3.0 added limited support for hardware acceleration (DirectX, OpenGL).

The update to the language introduced several new features:

  • Compile-time and run-time type checking—type information exists at both compile-time and runtime.
  • Improved performance from a class-based inheritance system separate from the prototype-based inheritance system.
  • Support for packages, namespaces, and regular expressions.
  • Compiles to an entirely new type of bytecode, incompatible with ActionScript 1.0 and 2.0 bytecode.
  • Revised Flash Player API, organized into packages.
  • Unified event handling system based on the DOM event handling standard.
  • Integration of ECMAScript for XML (E4X) for purposes of XML processing.
  • Direct access to the Flash runtime display list for complete control of what gets displayed at runtime.
  • Completely conforming implementation of the ECMAScript fourth edition draft specification.
  • Limited support for dynamic 3D objects. (X, Y, Z rotation, and texture mapping)

Flash Lite

edit
  • Flash Lite 1.0: Flash Lite is the Flash technology specifically developed for mobile phones and consumer electronics devices. Supports Flash 4 ActionScript.
  • Flash Lite 1.1: Flash 4 ActionScript support and additional device APIs added.
  • Flash Lite 2.0 and 2.1: Added support for Flash 7 ActionScript 2.0 and some additional fscommand2 API.
  • Flash Lite 3: Added support for Flash 8 ActionScript 2.0 and also FLV video playback.
  • Flash Lite 4: Added support for Flash 10 ActionScript 3.0 as a browser plugin and also hardware graphics acceleration.

AIR

edit

Adobe AIR supports ActionScript, in addition to some extended contents, such as the Stage3D engine Adobe has developed. The number of APIs (Application programming interfaces) available to ActionScript 3.0 has also risen dramatically.

Syntax

edit

ActionScript code is free form and thus may be created with any amount or style of whitespace that an author desires. The basic syntax is derived from ECMAScript.

ActionScript 2.0

edit

The following code, which works in any compliant player, creates a text field at depth 0, at position (0, 0) on the screen (measured in pixels), that is 100 pixels wide and high. Then the text parameter is set to the "packageorg.wikipedia.example{ importflash.display.MovieClip; classGreeterextendsMovieClip{ publicfunctionGreeter(){ vartxtHello:TextField=this.createTextField("txtHello",0,0,0,100,100); txtHello.text="Hello, world"; } } }

ActionScript 3.0

edit

ActionScript 3.0 has a similar syntax to ActionScript 2.0, but a different set of APIs for creating objects. Compare the script below to the previous ActionScript 2.0 version:

packageorg.wikipedia.example{ importflash.display.Sprite; importflash.text.TextField; publicclassGreeterextendsSprite{ publicfunction Greeter() { vartxtHello:TextField=newTextField(); txtHello.text="Hello World"; this.addChild(txtHello); } } }
\n\n <fx:Script>\n <![CDATA[\n public function initApp(): void {\n // Prints our \"Hello, world!\" message into title\n title.text = \"Hello, World!\";\n }\n ]]>\n </fx:Script>\n\n <s:Label id=\"title\" fontSize=\"54\" fontStyle=\"bold\" />\n</s:Application>\n"}}'><?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/mx/polysylabi" xmlns:mx="library://ns.adobe.com/flex/mx" layout="vertical" creationComplete="initApp()"> <fx:Script> <![CDATA[ publicfunction initApp():void{ // Prints our "Hello, world!" message into title title.text="Hello, World!"; } ]]> </fx:Script> <s:Labelid="title"fontSize="54"fontStyle="bold"/> </s:Application>

Data structures

edit

Data types

edit

ActionScript primarily consists of "fundamental" or "simple" data types that 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

  • String: A list of characters such as "Hello World"
  • Number: Any Numeric value
  • Boolean: A simple binary storage that can only be "true" or "false".
  • Object: Object is the data type all complex data types inherit from. It allows for the grouping of methods, functions, parameters, and other objects.

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:

  • MovieClip: An ActionScript creation that allows easy usage of visible objects.
  • TextField: A simple dynamic or input text field. Inherits the MovieClip type.
  • Button: A simple button with 4 frames (states): Up, Over, Down and Hit. Inherits the MovieClip type.
  • Date: Allows access to information about a specific point in time.
  • Array: Allows linear storage of data.
  • XML: An XML object
  • XMLNode: An XML node
  • LoadVars: A Load Variables object allows for the storing and send of HTTP POST and HTTP GET variables
  • Sound
  • NetStream
  • NetConnection
  • MovieClipLoader
  • EventListener

ActionScript 3 primitive (prime) data types

  • Boolean: The Boolean data type has only two possible values: true and false or 1 and 0. No other values are valid.
  • int: The int data type is a 32-bit integer between -2,147,483,648 and 2,147,483,647.
  • Null: The Null data type contains only one value, null. This is the default value for the String data type and all classes that define complex data types, including the Object class.
  • Number: The Number data type can represent integers, unsigned integers, and floating-point numbers. The Number data type uses the 64-bit double-precision format as specified by the IEEE Standard for Binary Floating-Point Arithmetic (IEEE-754). The Number type can store integers between -9,007,199,254,740,992 (-2) to 9,007,199,254,740,992 (2), and floating-point values between Number.MAX_VALUE (1.79769313486231e+308) and Number.MIN_VALUE (4.940656458412467e-324).
  • String: The String data type represents a sequence of 16-bit characters. Strings are stored internally as Unicode characters, using the UTF-16 format. Previous versions of Flash used the UTF-8 format.
  • uint: The uint (unsigned integer) data type is a 32-bit unsigned integer between 0 and 4,294,967,295.
  • void: The void data type contains only one value, undefined. In previous versions of ActionScript, undefined was the default value for instances of the Object class. In ActionScript 3.0, the default value for Object instances is null.

ActionScript 3 some complex data types

  • Array: Contains a list of data. Though ActionScript 3 is a strongly typed language, the contents of an Array may be of any type and values must be cast back to their original type after retrieval (support for typed Arrays has recently been added with the Vector class).
  • Date: A date object containing the date/time digital representation.
  • Error: A generic error object that allows runtime error reporting when thrown as an exception.
  • flash.display:Bitmap: A non-animated bitmap display object.
  • flash.display:MovieClip: Animated movie clip display object; Flash timeline is, by default, a MovieClip.
  • flash.display:Shape: A non-animated vector shape object.
  • flash.display:SimpleButton: A simple interactive button type supporting "up", "over", and "down" states with an arbitrary hit area.
  • flash.display:Sprite: A display object container without a timeline.
  • flash.media:Video: A video playback object supporting direct (progressive download) or streaming (RTMP) transports. As of Flash Player version 9.0.115.0, the H.264/MP4 high-definition video format is also supported alongside standard Flash video (FLV) content.
  • flash.text:TextField: A dynamic, optionally interactive text field object.
  • flash.utils:ByteArray: Contains an array of binary byte data.
  • flash.utils:Dictionary: Dictionaries are a variant of Object that may contain keys of any data type (whereas Object always uses strings for its keys).
  • Function: The core class for all Flash method definitions.
  • Object: The Object data type is defined by the Object class. The Object class serves as the base class for all class definitions in ActionScript. Objects in their basic form can be used as associative arrays that contain key-value pairs, where keys are Strings and values may be any type.
  • RegExp: A regular expression object for strings.
  • Vector: A variant of array supported when publishing for Flash Player 10 or above. Vectors are typed, dense Arrays (values must be defined or null) which may be fixed-length, and are bounds-checked during retrieval. Vectors are not just more typesafe than Arrays but also perform faster.
  • XML: A revised XML object based on the E4X (Standard ECMA-357); nodes and attributes are accessed differently from ActionScript 2.0 object (a legacy class named XMLDocument is provided for backwards compatibility).
  • XMLList: An array-based object for various content lookups in the XML class.

Using data types

edit

The basic syntax is:

varmyObject={};

Some types are automatically put in place:

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

Only references to an object may be removed by using the "delete" keyword. Removal of actual 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 reference is made to the orphaned object), it is removed from memory. For this reason, memory management in ActionScript requires careful application development planning.

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

Code protection

edit

Like most bytecode file formats, Flash SWF files can be decompiled into their source code and assets (similarly to how Microsoft .NET files can be decompiled). Some decompilers are capable of nearly full reconstruction of the original source file, approximate to the actual code that was used during creation (although results vary on a case-by-case basis).

In opposition to the decompilers, ActionScript obfuscators have been introduced, which transform code into a form that breaks decompiler output while preserving the functionality and structure of the program. Higher-quality obfuscators implement lexical transformations such as identifier renaming, control flow transformation, and data abstraction transformation which collectively make it harder for decompilers to generate output likely to be useful to a human. Less robust obfuscators insert traps for decompilers. Such obfuscators either cause the decompiler software to crash unexpectedly or to generate unintelligible source code."Apple's lost decade, HyperCard, and what might NOT have been if Apple then was like Apple is today". ZDNet. April 17, 2011. Archived from the original on April 21, 2011. Retrieved December 4, 2014.

  • ↑ Grossman, Gary; Huang, Emmy (June 27, 2006). "ActionScript 3.0 overview". Adobe Systems Incorporated. Retrieved June 18, 2010.
  • ↑ "Flash Player | Adobe Flash Player 11 | Overview". Adobe.com. April 9, 2013. Retrieved April 22, 2013.
  • ↑ "Flash Player 11, AIR 3 Release Notes". helpx.adobe.com. Retrieved October 7, 2016.
  • 1 2 "Third party review of another decompiler". Flashmagazine.com. October 21, 2007. Archived from the original on June 20, 2017. Retrieved April 22, 2013.
  • ↑ Warren, Tom (July 25, 2017). "Adobe will finally kill Flash in 2020". The Verge. Archived from the original on July 25, 2017. Retrieved December 16, 2020.
  • File
    formats
    Software
    (list)
    Players
    Animation
    tools
    Programming
    tools
    Libraries
    Converters
    Server-side
    Obsolete
    software
    Related
    topics
    Developers
    National
    Other

    View original on Wikipedia | Back | FazBrowse Home