Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] (Actionscript) - Basics
Index -> Graphics and Design, Web Design -> Flash MX Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheZsterBunny




PostPosted: Sun Oct 24, 2004 9:47 pm   Post subject: [Tutorial] (Actionscript) - Basics

Preamble
Alright, For this tutorial (and any/all future flash tutorials) I am going to assume the following things:
    -You have some basic programming background (ie turing or java).
    -You already know how to animate in flash.
    -You are using Flash MX 2004 (others should work, but just to be sure).


Also note, that I am still learning this stuff, so i may not be able to explain it all too well.

Actionscript is derived from C as are Java and Javascript (and others). Knowing the correct syntax will help you well. Actionscript is given to movie clips/buttons/frames by selecting the movie clip/button/frame and clicking on the actions toolbar.

Actionscript is also a very flexible, forgiving and leniant language. Any methods I show here can also be performed in a number of different ways.

With that said and done, let us begin.

Variables

To begin, let me show you how to make a variable.

code:

x = 5;


We have just created the variable x, and its value is 5. Here is another example.

code:

x = 5;
x = "Mississippi";


We have just created the variable x, and its value is 'Mississippi'.

its all pretty simple.


Mathematics

Mathematical operations are the same as in java, but do not forget your semicolons.

Conditional Statements

Java.

Timeline Manipulation

As much as this sounds like a 'back to the future' phenomenon, I assure you it is not.

To move to different frames in your movieclip, you can use one of two actions:
code:

gotoAndPlay(#);
// -or-
gotoAndStop(#);


The # sign is either the frame number or the name of the frame. The number can change if you modify the timeline, so be careful. Also, do not use the prevframe(); or nextframe(); commands (something like that), as they are depreciated.

The next bit is something that bugs me greatly. Please do not forget about it.
Stopping an animation

code:

stop();


This stops the current animation when the frame reaches that point. If this is in the main timeline, the movie will halt (except for movieclips). It will stop, and stay stopped until told otherwise.

Other
Other commands can be found by using the help menu (build in in mx2k4). I will however list some useful sites which may help you.

Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Tue Oct 26, 2004 6:25 pm   Post subject: (No subject)

i may be not great at this, but somehow my former programming experience tells me that

code:

x = 5;
x = "Mississippi"; [quote]

would give u an error[/quote]
TheZsterBunny




PostPosted: Wed Oct 27, 2004 6:39 am   Post subject: (No subject)

not at all.

in actionscript, that is perfectly valid.

however, if you try to perform mathematical calculations with that variable, it would return 'NaN' instead of a number.

NaN = Not a Number

In flash, the programming side is extra, not integral. They don't expect everyone to know how to program perfectly. There are advanced concepts in actionscript, but most of it is pretty basic.

-Z
Hikaru79




PostPosted: Wed Nov 24, 2004 5:52 pm   Post subject: (No subject)

TheZsterBunny wrote:
not at all.

in actionscript, that is perfectly valid.


I think what he's talking about is the fact that you used 'x' twice for both variables. Does ActionScript support dynamic types like that? X can switch from 'int' to 'String' in a flash? (no pun intended...)
TheZsterBunny




PostPosted: Mon Jan 03, 2005 9:16 pm   Post subject: (No subject)

Absolutely. This is valid anywhere.


Also flash supports named arrays.

i.e.

cars ["Sporty"] = "Ferrari";
cars ["Cool"] = "Volvo XC 90";
cars ["Crappy"] = "Yours";

trace (cars["Crappy"]);

^_^.

---edit---

erm. sorry for bringing up an old post. even though it was the top of the list.
Hikaru79




PostPosted: Mon Jan 03, 2005 9:31 pm   Post subject: (No subject)

TheZsterBunny wrote:
Absolutely. This is valid anywhere.


Also flash supports named arrays.

i.e.

cars ["Sporty"] = "Ferrari";
cars ["Cool"] = "Volvo XC 90";
cars ["Crappy"] = "Yours";

trace (cars["Crappy"]);

^_^.

---edit---

erm. sorry for bringing up an old post. even though it was the top of the list.


I was wondering when you'd reply to this Wink

Well, the dynamic-ness is cool. You couldn't do that to Java, Turing, etc., that's for sure. As for the arrays, you can use Hash Tables for (pretty much) the same functionality.
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> Flash MX Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: