View Single Post

Old 05-19-2005, 03:07 AM   #1 (permalink)
Ganondorf
Premium Brawler Account
Senior Member

Enlightened
 
Ganondorf's Avatar
 
Join Date: Feb 2005
Posts: 2,587
Ganondorf has a brilliant futureGanondorf has a brilliant futureGanondorf has a brilliant futureGanondorf has a brilliant futureGanondorf has a brilliant futureGanondorf has a brilliant futureGanondorf has a brilliant future
Send a message via AIM to Ganondorf Send a message via Yahoo to Ganondorf Send a message via Skype™ to Ganondorf
Macromedia Flash 2004: ActionScript Tutorial 1

Since Noober didn't specify whicih kind of tutorials he wants, I've decided to write a helpful actionscript one.

Introduction: (you may skip)
ActionScript is Flash's programming language. It is used to create all the fancy buttons and games you see in Flash. Actionscript is an OOP (object-orientieted programming) language, and is fairly simple. Lets start.

Tutorial 1: Start an animation on the click of a button

Section 1: Make a button in Flash. I'll name mine go.



Open up the actions panel. Make sure your button is selected. Put in the following code:

Code:
on (release) {
play();
}
Lets take a look at what this does in parts:

on (release) {
When the mouse button is released when over the button, do whats in between the { and the }.

play();
Start playing through the timeline from the current frame.

}
End up the statement.

There is only one more thing we need to do to make this work. On default, as soon as Flash player is loaded the movie starts playing. To stop this, open up the actions panel again, and select the first frame. Put in this code:

Code:
stop();
I'm sure this doesn't need explanation. Add another frame in the timeline, insert the stop(); onto that frame too, and draw a circle or such on it. Then test your movie (ctrl+enter) and see if it works. Lets take a look at something a little bit different now.

Section 2: Lets modify our code to do the same thing in a different way. In your second frame, you will no longer need the stop(); command.

Code:
on (release) {
gotoAndStop(2);
}
gotoAndStop(2);
This tells Flash Player to go to the frame 2 and stop. gotoAndPlay(2) would tell it to go to frame 2, but then continue playing through the rest of the movie.



I hope this tutorial was helpful, and any feedback is appreciated. If requested I will add more sections to this tutorial, and requests for other actionscript tutorials are welcome too.

I also realize this isn't the best spot for a programming tutorial, but A. This is FLASH! and B. I felt it belonged here.

Edit: Fix #2.
__________________
Ganondorf 15 0FF11|\|3   Reply With Quote
Advertisement
 
Advertisement
Sponsored links