A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


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

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


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

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


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 3
«prev 1 2 3 4 5 next»

Arithmetic "IF" operator

The syntactic form is:
Expression1 ? expr2 : expr3 ;
If expression1 evaluates to a true condition, then expression2 is evaluated, otherwise expression3 is evaluated. E.g.

x = 2;
y = 5;
max = x

Bitwise Operators

Bitwise operators operate on the value to base 2 (binary). Operands must be integers.
Left Shift ("<<") - shifts the bits of the left operand some number of positions to the left. e.g.

someNum = 1;
0 0	0 0	0 0 0 1
SomeNum = someNum<<1;
0 0 0 0 0 0 1 0
SomeNum = someNum<<2;
0 0 0 0 1 0 0 0
Right Shift (">>")
SomeNum = someNum>>3;
0 0 0 0 0 0 0 1
The leftShift operator inserts "0" from the right.
The Right Shift operator inserts "0" from the left.

Variables (AS 2.0)

A variable is identified by a user-supplied name. Each variable is of a particular data type. E.g.

Var num:Number;
"Number" is a type specifier. A declaration can follow the template:
var variableName:DataType;
  • The use of the ":Datatype" is not strictly enforced in AS2 but I strongly recommend it.
  • A variable can be composed of letters, numbers and underscore. Upper and lower case letters are different.
  • Variables need to be initialised. I.e. given an initial value.
    var myNum:Number;	//Declaration
    myNum = 0;		//Initialisation
    
  • In AS 1.0, variables are not strictly typed and can change types.

DataTypes (AS 2.0 only)

Variables in AS 2.0 can be given strict datatypes such as a Number or a String or a Boolean. e.g.

var myNum:Number;
var myString:String;
var isTested:Boolean;
In AS 1.0 there is no strict datatyping. A number can become a String and vice versa. e.g.
num = 10;
num = "Test";
Strict datatyping can capture errors.

Compiler Errrors

  1. Syntax errors - e.g. var numberOne:
  2. Spelling Mistakes - var mc:MoveiClip;
  3. DataType Errors - (AS 2.0)

var num1:Number;
var str1:String;
num1 = "Steve";
str1 = 27;

Flow control

IF

An if statement tests a condition. If it is true, then a set of actions is executed. Otherwise, the set is ignored or bypassed. Here is a template :

 If(expression){
 Statement1;
 }
Here is an example :
 var x = 23;
 if(x>3){
 trace("x is greater than 3");
 }

IF .. ELSE

If .. else allows for a kind of either .. or condition.
Template:

If(expression){
 Statement1;
 }else{
 statement2;
 }
If expression is true then statement1 is executed.
If expression is false then statement2 is executed.
e.g.
var x = 2;
if(x> 3){
trace("condition is true");
}else{
trace("condition is false");
}

Switch (AS 2.0 only)

A switch statement is an alternative to complex nested if .. else statements

switch(variable){
 case 1:
 //Statement1;
 break;
 case 2:
 //Statement2
 break;
 default:
 //statement3;
 break;
 }
The variable to be evaluated is inserted into the switch argument. If the first variable's value is 1 then statement1 is evaluated. A break statement is inserted after it so that the switch statement is terminated. The default label is the condition for "everything else".
var tester:Number;
tester = random(3);
switch (tester) {
case 1 :
 trace("tester = 1");
 break;
case 2 :
 trace("tester = 2");
 break;
case 3 :
 trace("tester = 3");
 break;
default :
 trace("Out of range");
 break;
}

«prev 1 2 3 4 5 next»

» Level Basic

Added: : 2005-08-10
Rating: 8.17 Votes: 12
Hits: 670
» 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
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs