Welcome to Virtual Tutorial World Guest!




Everything Actionscript - Part 1

 
Post new topic   Reply to topic    VTW Forum Index -> Actionscript
View previous topic :: View next topic  
Author Message
computergeek67
Administrator
Administrator


Joined: 31 Jul 2007
Posts: 144
Tokens: 147
Location: US

PostPosted: Fri Nov 16, 2007 11:14 pm    Post subject: Everything Actionscript - Part 1 Reply with quote

What is Actionscript?
Actionscript is the language of Macromedia, or now Adobe, Flash. It was created in 1998 by Macromedia for Flash 3. The first version of Actionscript lasted for six years from 1999 until 2004. In 2005, when Flash 8 was released, Macromedia introduced Actionscript 2. This is the most commonly used Actionscript to date. In 2007, Adobe created Flash CS3 (Flash 9) for their Creative Suite products. (Adobe bought Macromedia in 2005.) Flash CS3 introduced Actionscript 3, a more complicated cleanup of Actionscript 2.

What is this Going to Teach Me?
This tutorial is going to teach you everything about Actionscript 2. When finished with the tutorial series, you will have full knowledge of Actionscript and will be able to tackle any project. So, let's get started!

Learning Actionscript

Actionscript Syntax
The Actionscript syntax is very unique. The three main characters of the syntax are the curly braces {}, the semicolon ;, and the parentheses ().

You use the curly braces to indicate the end of the code. This tells Flash to stop parsing, or reading, the code.

The semicolon indicates the end of a statement. For example, when you were in English class a while back, you probably learned that a period ended a sentence, or a statement. Think of the semicolon as a period.

Parentheses usually indicate a specific thing. Maybe an action or number for example. You can see all the characters in action with this code:
Code:
on(press){
gotoAndStop(2);
}
I'll explain the code.The fist line, "on(press){", says that when you press a button, Flash should do something (which is the second line). Notice that the word "press" is in parentheses. In this case, it is an action. Also note the curly brace. It can also be used to tell Flash that the next line of code is something that it should do.

I'm not going to go very in-depth with the second line of code. I'm just going to tell you about the second set of parentheses and the semicolon. The second set of parentheses, in this case, are used to encase a number. The semicolon in the code is used, just as mentioned, to mark the end of the statement.

The last line of code is just a curly brace. This is used, as also mentioned, to mark the end of the code.

Dot Syntax
You use dots, or periods, to separate usually an abject from its properties. Take this part of a code for example:
Code:
_root.car
"_root" would refer to the main timeline of Flash. And car would refer to the Movie Clip with an instance name of "car" without the quotes. That might sound complicated, but you'll get it.

Statements
A statement is an instruction to make an action happen. Actionscript can consist of only a single statement to many statements. Actionscript parses statements from top to bottom, but you can use if statements and loops to change that order.

Arguments
"An argument is a value associated with an action or function" -Master Visually
For example, remember the code I gave you:
Code:
on(press){
gotoAndStop(2);
}
What I did not mention was that the values enclosed in the parentheses are also arguments. Arguments can contain a literal value or an expression. Enclose literal values in quotes. Do not enclose expressions in quotes. An example of this is:
Code:
on(press){
gotoAndStop("Scene 2", 1);
}
The "Scene 2" part is a literal value. The number, "1" is an expression. That is why it is not in quotes.

Comments
Using comments is essential when wanting to explain code. When parsing the code, Flash ignores the comments that are written and continues executing the script. You write comments like this:
Code:
//this is a single line comment.

/*This is
a multiline
comment*/
You probably will never use the multiline comment unless you are writing a long comment. Otherwise, use the single line comment.

Putting it All Together
With everything that I have taught you in this first part, you can put that all together and make this code:
Code:
onClipEvent(enterFrame){
if(this.hitTest(_root.thing)){
_root.gotoAndStop("Scene 2", 1);
}
}


Thank you for reading this long and detailed tutorial. I hope this will get you started in the amazing world of Actionscript.


_________________



Come to me if you have any questions
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    VTW Forum Index -> Actionscript All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Virtual Tutorial World ©2007-2008 computergeek67

Affiliates