Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting/Basic

Categories Flash Actionscript Programming Basics
Author: Steve Happ | Website: http://www.video-animation.com |

 
Page 1
1 2 3 4 5 next»

Flash Actionscript Programming Basics

There are currently 2 versions of Actionscript. Actionscript 1.0 (AS 1.0) is the version that works with Flash MX. Actionscript 2.0 (AS 2.0) is the new language that ships with Flash MX2004. Most items in these tutorials will cover both AS 1 and AS 2. Where there is a difference I will indicate it. Actionscript 1.0 will work with Flash MX2004 but Actionscript 2.0 will not work with Flash MX.

To enter actionscript code, open the Actions window by hitting the F9 key or selecting menu item "Window" - "Actions", and start writing in that window.
Start Now!
Open the Actions window and type in this code:

var myNumber;
What you have done is a simple VARIABLE DECLARATION. You have reserved space in memory where some information/data is to be stored.
Now write this in place of above.:
var myNumber = 10;
You have assigned a value to the variable. i.e. stored the value 10 in the variable myNumber.

The trace( ) function prints whatever is between the parentheses to the output window. It displays the value of the argument of trace. To sequence text and variables in a trace function use "+" to add text to number and variables etc.
e.g.

trace("some Text " + someVariable);
So, here is our complete script,
var myNumber = 10;
trace("The value is " + myNumber);
Now execute or run the script. To execute a script hit the keys "Control + Enter" together, or use menu item "Control" - " Test Movie".

After a script is written, the next step is to compile it. Compiling means to write to bytecode that Flash understands. The compiler has 2 jobs:

  1. error checking - the compiler will examine the script for language correctness or errors.
  2. Translate what we have to instructions that the machine can understand.

Statements

A Statement is an expression terminated by a semi-colon (";"). A statement in AS is similar to a sentence in the English language. E.g.

var score;
score = 80;
trace(score);
Lets analyse the above script
  1. is a declaration statement. It tells the machine "we exist"
  2. Assignment(=) statement. Assigns the value 80 to the computer memory space associated with the variable "score". Here we have initialised score. We have given it an initial value.
  3. - prints the value of score to the output window.
Do it now and hit Control+Enter.

Different values can be placed in the boxes for each name. The name is called a variable. It can be created or thrown away at any time. When you declare a variable, you set up a space in memory for it and also leave a space (connected with it) for a variable's value.(8, 16, "Frodo", whatever).
What we have used so far as variables has been numbers. There are a number of variable types (called datatypes) The main datatypes are Numbers (35), Strings ("a bunch of text") and Boolean (true or false).
Lets do another example. Write this in the actions window:

 var string1 = "This is a test";
 trace(string1);
What did you get in the output window? Try another:
 var isTrue = true;
 trace(isTrue);

1 2 3 4 5 next»

» Level Basic

Added: : 2005-08-10
Rating: 8.17 Votes: 12
Hits: 674
» Author
Steve Happ is the founder of Steve's Tutes and has been going hard at it developing Flash for Web and CD-rom.
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments