Clever Geek Handbook
📜 ⬆️ ⬇️

ActionScript

ActionScript is an object-oriented programming language , one of the ECMAScript dialects that adds interactivity, data processing, and much more to the contents of Flash applications. ActionScript is executed by the virtual machine (ActionScript Virtual Machine), which is part of Flash Player. ActionScript is compiled into bytecode , which is included in the SWF file.

ActionScript
ActionScript File Icon.png
Language classObject Oriented , Prototype , Imperative , Script
Appeared in1998
AuthorHarry grossman
Developer
Release3.0
Type systemstrong , static
Key implementations:Adobe Flash Player , Adobe AIR , Apache Flex
InfluencedJavascript java
Site
ActionScript
MIME typeapplication / ecmascript [1]
Developer
Format type, and
Site

SWF files are executed by Flash Player. Flash Player exists as a plug-in for a web browser , as well as a standalone application (standalone). In the second case, it is possible to create executable exe files (projector) when the Flash Player application is combined with a swf file by analogy with SFX .

With ActionScript, you can create interactive multimedia applications, games , websites, and more.

ActionScript is an open programming language, its specification is publicly available on the Adobe website [2] . The compiler (as part of Apache Flex ) and the open virtual machine ( Tamarin ) are open source software .

Content

History

ActionScript as a language appeared with the release of the 5th version of Macromedia Flash , which became the first ActionScript-programmed environment. The first released version of the language was called ActionScript 1.0. The 6th version of Flash (MX) also used ActionScript 1.0. In 2004, Macromedia introduced a new version of ActionScript 2.0 along with the release of Flash 7 (MX 2004), which introduced strong typedefinition, as well as class-based programming. That is, new keywords appeared:

  • class
  • interface
  • extends (setting inheritance)
  • access modifiers: private, public;
  • and others.

Also, Macromedia has released a modification of the Flash Lite language for programming for mobile phones.

ActionScript 1.0 is a prototype programming language . That is, it fully implements all three principles of object-oriented programming.

ActionScript 2.0 is an add-on for ActionScript 1.0. Type checking and working with the class hierarchy is performed at compile time, which ends with the generation of a bytecode similar to ActionScript 1.0.

In 2006, ActionScript 3.0 was released in the Adobe Flex programming environment, and later in Adobe Flash 9.

ActionScript 3.0 represents, compared with ActionScript 2.0, a qualitative change, it uses the new AVM 2.0 virtual machine and, instead of the previous formal class syntax, provides object-oriented class-based programming . ActionScript 3.0 provides up to 700 times faster performance compared to ActionScript 1.0 / 2.0 (this is just processing instructions without affecting the graphics). ActionScript 3.0 allows you to work with binary data, with BitMap (which provides a significant performance increase: up to 10,000 times). ActionScript 3.0 is close in speed to programming languages ​​such as Java and C # . Performance increase based on dynamic code translation ( JIT ). Such an increase in performance is possible only for certain types of data and requires special organization of the code [3] . The amount of code, as a rule, increases several times [4] (compared with AS1)

Player versionsInnovations
2

“Actions” appeared, hereinafter known as:

  • gotoAndStop ();
  • gotoAndPlay ();
  • nextFrame ();
  • prevFrame ();
  • getURL ();
3The advent of loadMovie ();
fourThe first version with full support for script implementation.
fiveThe first version of ActionScript appeared. We used prototype programming based on ECMAScript and provided full support for procedural and object-oriented programming.
6
  • Event Model Added
  • switch
  • Support for AMF and RTMP protocols has appeared.
7
  • The advent of AS2, based on ECMAScript 4 with class-based programming.
  • Added CSS support for text.
eight
  • The emergence of new safety rules.
  • Adding an AS1 / AS2 filter.
  • The appearance of the class to view Bitmap Data in real time.
9
  • New ECMAScript scripting engine, ActionScript Virtual Machine AVM2. AVM saved for compatibility, added support for ActionScript 3 through AVM2 .
  • The appearance of the E4X extension for XML .
ten
  • 3D effects
  • Various filters and effects
  • Extended text layout
  • Improved Drawing API
10.2
  • improved p2p support, added noise reduction.
eleven
  • The emergence of a low-level API for working with graphics, USB devices
  • 3D Acceleration
Support for ActionScript versions:
Not supportedAS1AS1, AS2AS1, AS2, AS3

Syntax

The ActionScript syntax is based on the ECMAScript specification.

ActionScript 2.0

This code creates a new text field, at a depth of 0, at a point (0, 0) and a size of 100 per 100 pixels. The text parameter is equal to the string “ Hello, world ”. The code should be written in the action - frame window

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

An example class written in AS2. The code should be stored in a separate .as file and located in the same folder with the project .fla source.

  class com .  example .  Greeter extends movieclip
 {
     public function Greeter ()
     {
     }
     public function onLoad () : Void
     {
         var txtHello : TextField = this .  createTextField ( "txtHello" , 0 , 0 , 0 , 100 , 100 );
         txtHello .  text = "Hello Ako!"  ;
     }
 }

ActionScript 3.0

In the source code of the compiled Adobe Flex SDK (AS 3.0):

  package {

 import flash .  display .  Sprite
 import flash .  text .  TextField

 public class HelloWorld extends Sprite {
     public function HelloWorld () {
         var txtHello : TextField = new TextField ();
         txtHello .  text = "Hello world!"  ;
         addChild ( txtHello );
     }
 }

MXML

Code written in MXML (XML extension):

  <? xml version = "1.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>

Debugger

An example of a debugger. Displays output of any data that can be converted to String (AS2 and beyond):

  trace ( "Hello world!" );

Structure

ActionScript 2

Elementary Data Types

Type ofDescription
StringA string, an array of characters, for example: “Hello World”
NumberAny numeric value, for example: 0, 0.5, 1150
BooleanBoolean, can be either true or false.
ObjectAn object. An example of an object is classes, methods, functions, parameters ...

Complex data types

Type ofDescription
MovieclipA graphic containing frames.
TextfieldA dynamic or input text field.
ButtonButton. It is essentially a Movie Clip with a predefined behavior. Consists of 4 frames: Up, Over, Down and Hit.
DateAn object containing date / time information.
ArrayData array.
XMLXML object
XMLNodeXml node
LoadvarsServes for sending and receiving variables using HTTP POST and HTTP GET
SoundContains sound data .MP3 format
NetstreamContains audio data of other formats
NetconnectionAllows 2 flash movies to interact in the same scope (for example, on the desktop, or in one browser tab)
MovieClipLoaderClass for loading swf clips and .jpg .png images
EventlistenerEvent handler

ActionScript 3

Elementary Data Types

(see Adobe documentation )

Type ofDescription
BooleanBoolean, can be either true or false.
intan integer 32-bit numerical value in the range from −2 31 to 2 31 −1.
uintan integer 32-bit numeric value in the range 0 to 2 32 −1.
Numberfractional 64-bit numerical value in the range from −2 63 to 2 63 −1.
nullzero. Link to the void.
StringA string of 16-bit characters. The encoding is UTF-16.
voida single value data type is undefined. Used if the programmer wants to indicate the type of function as "non-returnable".

Complex data types

(see Adobe documentation )

Type ofDescription
ObjectAn object. The key class of OOP. It is the basis of all AS3 classes.
ArrayArray of data of weak typing. It can take any values, for example: ['a', 5, new TextField ()]
VectorAn array of strongly typed data. For example, the Vector. <String> array can contain only string data ['a', 'b', '']
DateA class containing date / time information.
ErrorThe class containing the errors.
FunctionMain class. An example is any AS3 method.
RegexpRegular expressions
XMLE4X-based XML object (ECMA-357 standard)
XMLListArray-based object for finding content in an XML class.

Packages

ActionScript 3.0 (or rather Flash Player 9 API - you can say the standard library written in C ++) consists of more than 700 classes organized in the following packages (analogs of namespaces in C ++):

PackageDescription
flash.accessibilityclasses to support access to Flash content and applications.
flash.displayThe main classes that Flash Player uses to display images.
flash.errorscommonly used error handling classes.
flash.externalcontains the ExternalInterface class, which is used to communicate with the Flash Player container.
flash.filtersclasses for working with raster image filters.
flash.geomclasses for working with geometric classes, such as points, rectangles and transformation matrices, to support the BitmapData class and the ability to cache images.
flash.mediaclasses for working with multimedia - for example, sounds and videos.
flash.netclasses for sending and receiving data over the network. For example, URL requests and Flash Remoting.
flash.printingclasses for printing the contents of a Flash movie.
flash.profilerfunctions used for debugging and profiling code.
flash.systemclasses for accessing the system at the level of functionality, such as security, multilingual content, etc.
flash.textclasses for working with text, its formatting, size, style and layout.
flash.uiuser interface classes, such as mouse and keyboard classes.
flash.utilsadditional classes, such as ByteArray for working with binary data, Timer for counting time intervals, etc.
flash.xmlprovides XML support and all the functions for working with XML. (Needed to support previous versions of AS)

There are also mx. * Packages, which consist of classes designed to create an application interface in the Flex environment and fl. * Packages for the Flash environment

Popular Media

  • Adobe Flash - Historically the first environment to support AS. Starting with Flash 5, the ACTIONS panel appeared, with the ability to edit code (AS1). For Flash 6, AS2 was created. Starting with Flash 9, support for AS3 appeared.
  • Adobe Flash Builder - A development environment for creating RIA applications for desktop and mobile devices.
  • Powerflasher FDT - An environment recognized by experienced flash programmers, is based on eclipse - a free integrated development environment for modular cross-platform applications.
  • FlashDevelop is a free development environment and editor written in C # that allows you to create Flash applications using the Flash IDE, Flex SDK, MTASC or haxe.
  • CodeDrive - A development environment and editor, with a fairly fast compiler, based on Microsoft Visual Studio.
  • SWFTools - A free package for working with swf files, the package includes the ActionScript 3.0 compiler (as3compile).

Notes

  1. ↑ RFC 4329 (limit compatible with EcmaScript)
  2. ↑ Archived copy (unopened) (inaccessible link) . Date of treatment July 9, 2015. Archived March 27, 2017.
  3. ↑ Ted Patrick | Entrepreneur, father, and interactive software developer Archived on September 30, 2009.
  4. ↑ Six reasons to use ActionScript 3.0 | Adobe Developer Connection

Links

  • Adobe Page
Source - https://ru.wikipedia.org/w/index.php?title=ActionScript&oldid=99877380


More articles:

  • Trikata parish
  • Diocese of Abbir-Germanicians
  • Saint Michel de Llion
  • Iceland Football Championship 2002
  • Kalmyk writing
  • Tugay, Anatoly Mikhailovich
  • Berezhnaya, Irina G.
  • Ivan Ulitin Street (Kiev)
  • Gomez Alfonso
  • Hello, Dolly! (album)

All articles

Clever Geek | 2019