kids encyclopedia robot

ActionScript facts for kids

Kids Encyclopedia Facts
Quick facts for kids
ActionScript
ActionScript icon.png
Paradigm Multi-paradigm: object-oriented (prototype-based), functional, imperative, scripting
Family ECMAScript
Designed by Gary Grossman
Developer Macromedia (merged into Adobe Systems, 2005)
First appeared 1998; 27 years ago (1998)
Stable release
3.0 / June 27, 2006; 19 years ago (2006-06-27)
Typing discipline strong, static
Scope lexical
Major implementations
Adobe Flash Player, Adobe AIR, Apache Flex, Scaleform GFx
Influenced by
HyperTalk, JavaScript, Java
Influenced
Haxe, TypeScript
ActionScript
Filename extension
.as
Internet media type
application/ecmascript

ActionScript is a special programming language that helps create interactive websites and software. It was first made by a company called Macromedia, which later became part of Adobe. ActionScript is a lot like JavaScript, which is another popular language used on the internet.

ActionScript is mainly used to build things for the Adobe Flash platform. This includes fun web pages with animations, online games, and even rich applications that work right in your web browser. It also helps create desktop and mobile apps using the Adobe AIR system. You might even find ActionScript used in some video games for things like menus and information displays.

What is ActionScript?

ActionScript was first designed to control simple 2D animations in Adobe Flash. Imagine making a cartoon move or a button light up when you click it. Early versions of Flash content didn't have much interactivity. But over time, ActionScript grew to let people create web-based games and complex web applications. These applications could even stream videos and audio.

Today, ActionScript is powerful enough for building apps for computers and mobile devices through Adobe AIR. It's even used in some database programs and basic robotics projects.

ActionScript 2.0 and 3.0

In 2004, Flash MX 2004 introduced ActionScript 2.0. This version was better for making bigger and more complex Flash applications. It saved time by letting developers write code instead of animating everything by hand. This also made it easier to change things later.

A newer version, ActionScript 3.0, came out in 2006. This was a big change! It was designed to run on a completely new "virtual machine" called AVM2. Think of a virtual machine as a special engine that runs the code. Because of this new engine, ActionScript 3.0 code runs much faster, sometimes up to 10 times faster than older ActionScript code. This version works with Flash Player 9 and newer versions.

ActionScript 3.0 is also the base for Adobe's Flex product line. Flex helps developers build rich web applications that run using Flash technology.

How ActionScript Developed

ActionScript started as a way to add simple actions to Flash animations. In the beginning, Flash tools only offered a few ways to make things interactive. Developers could add basic commands like "play," "stop," or "go to a specific part of the animation."

When Flash 4 was released in 1999, these simple actions became a small scripting language. New features like variables (which store information), if statements (which make decisions), and loops (which repeat actions) were added. Even though it was called "ActionScript" internally, the user manuals still called them "actions."

Key Milestones in Flash Player History

  • Flash Player 2 (1996): This was the first version with basic scripting. It allowed simple controls like playing or stopping animations.
  • Flash Player 4 (1999): This player had a more complete scripting system. It included support for loops, conditions, and variables.
  • Flash Player 5 (2000): This version introduced the first official ActionScript. It was influenced by JavaScript and allowed more complex programming.
  • Flash Player 7 (2003): This player added support for ActionScript 2.0. This new language was better for building larger applications.
  • Flash Player 9 (2006): This was a major update! It brought ActionScript 3.0 and a new, much faster virtual machine (AVM2). It also added support for things like binary sockets and full-screen mode.
  • Flash Player 10 (2008): This version added basic 3D abilities, allowing objects to rotate in 3D space. It also improved performance by using the computer's graphics card.
  • Flash Player 11 (2011): This version greatly improved 3D capabilities with Stage3D, making it possible to create more advanced 3D games and applications. It also added support for mobile platforms like iOS and Android.
  • Later Flash Player versions (2012-2013): These versions continued to improve performance, add features for gaming (like mouse-lock and better audio), and enhance security. They also improved support for mobile devices and new hardware.

ActionScript Versions Over Time

ActionScript 1.0 (2000-2004)

When Flash 5 came out in 2000, the "actions" were officially named "ActionScript." This version was influenced by JavaScript and allowed developers to create their own functions. A key feature was its "loose type system," meaning a variable could hold any type of data. This made it quick to write small scripts. It also used "prototype-based inheritance," a way for objects to share features.

ActionScript 2.0 (2003-2006)

ActionScript 2.0 was introduced in 2003 with Flash MX 2004. Developers wanted a language that could handle bigger and more complex applications. ActionScript 2.0 added "type checking" (making sure variables hold the right kind of data) and a "class-based syntax." This meant developers could organize their code using "classes," similar to languages like Java. Even though it looked more like a class-based language, the code still compiled down to ActionScript 1.0, so it could run on older Flash Players.

ActionScript 3.0 (2006-2020)

ActionScript 3.0 arrived in 2006 with Adobe Flex 2.0 and Flash Player 9. This was a huge change because it used a completely different virtual machine. Flash Player 9 actually had two virtual machines: AVM1 for older ActionScript 1.0 and 2.0 code, and AVM2 for the new ActionScript 3.0. This update brought many new features:

  • Better performance because of a new class-based system.
  • Support for packages (ways to organize code), namespaces, and regular expressions (patterns for finding text).
  • A new type of bytecode (the code the computer understands) that was faster.
  • A new way to handle events (like mouse clicks or key presses).
  • Better ways to work with XML data.
  • Direct control over what appears on the screen.
  • Limited support for basic 3D objects.

ActionScript 3.0 was a big step forward, making Flash content much more powerful and efficient.

Flash Lite and AIR

  • Flash Lite: This was a special version of Flash made for mobile phones and other electronic devices. It supported different versions of ActionScript, eventually including ActionScript 3.0.
  • Adobe AIR: This system allows ActionScript to be used to create desktop and mobile applications that run outside of a web browser. It includes powerful features like the Stage3D engine for advanced 3D graphics.

How ActionScript Code Looks

ActionScript code is "free form," meaning you can arrange it with spaces and lines however you like. Its basic structure comes from ECMAScript, just like JavaScript.

ActionScript 2.0 Example

Here's a simple example in ActionScript 2.0 that creates a text box and puts "Hello, world" inside it:

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

This code tells the program to make a text field named "greet" at a certain spot on the screen, then put the words "Hello, world" into it.

ActionScript 3.0 Example

ActionScript 3.0 has a similar look but uses different ways to create objects. Here's the same "Hello World" example in ActionScript 3.0:

var txtHello: TextField = new TextField();
txtHello.text = "Hello World";
this.addChild(txtHello);

This code first creates a new text field, then sets its text, and finally adds it to the screen so you can see it.

ActionScript 3.0 can also be used within MXML files, especially when using Adobe's Flex framework. MXML is a special language that helps design the layout of an application.

Types of Data in ActionScript

ActionScript uses different "data types" to store information. Think of them as different kinds of containers for different kinds of things.

ActionScript 2.0 Data Types

  • String: Stores text, like "Hello World."
  • Number: Stores any number.
  • Boolean: Stores either `true` or `false`.
  • Object: A general type that can group together other data and actions.

There are also "complex" data types built from these basic ones:

  • MovieClip: Used for visible objects, like animated characters.
  • TextField: For text boxes.
  • Button: For interactive buttons.
  • Array: Stores a list of data.
  • Date: Stores information about a specific time.

ActionScript 3.0 Data Types

ActionScript 3.0 changed some of the data types:

  • Boolean: Still `true` or `false`.
  • int: Stores whole numbers (integers) between -2 billion and +2 billion.
  • Null: Means "no value."
  • Number: Stores numbers with decimals (like 3.14) or very large/small whole numbers.
  • String: Stores text, using a special format called Unicode (UTF-16).
  • uint: Stores only positive whole numbers (unsigned integers) up to about 4 billion.
  • void: Means "nothing" or "undefined."

Some complex data types in ActionScript 3.0 include:

  • Array: A list of data, similar to AS2.
  • Date: For date and time.
  • MovieClip: For animated objects.
  • Sprite: A container for display objects without a timeline.
  • TextField: For text fields.
  • Vector: A newer, faster type of array that holds only one type of data.
  • XML: For working with XML data.

How to Use Data Types

You declare a variable (a container for data) by giving it a name and a type:

var variableName: VariableType = new VariableType(param1, param2);

For example, to make a text variable:

var myString: String = "Hello Wikipedia!"; // This variable holds text.
var myNumber: Number = 5; // This variable holds a number.

ActionScript treats all variables as "references." This means the variable doesn't hold the actual data itself, but rather a pointer to where the data is stored in the computer's memory. If you copy a variable, you're copying the pointer, so both variables point to the same data.

Protecting Your Code

Like many computer programs, Flash SWF files (the files that run Flash content) can sometimes be "decompiled." This means someone can try to turn the compiled code back into something similar to the original source code.

To prevent this, developers can use "obfuscators." An obfuscator changes the code in a way that makes it very hard for decompilers to understand, while still letting the program work correctly. It's like scrambling a message so only the intended recipient can read it. Good obfuscators rename parts of the code and change its structure to make it confusing for anyone trying to reverse-engineer it.

See also

Kids robot.svg In Spanish: ActionScript para niños

kids search engine
ActionScript Facts for Kids. Kiddle Encyclopedia.