Flash Actionscript for Beginners
If you're at the stage where you are comfortable using Flash and you're ready to make applications that a user can interact with then you will need to become familiar with action script. Below I have listed six simple but useful scripts which I hope you enjoy trying out.
First of all make sure you are in default layout to ensure that you will be able to see all the options I'm going to refer to in this article.
Next ensure that you are in expert mode in your actions window. The function can be switched on and off via the View Mode menu inside the Actions panel, in expert mode you can type your code directly into the script panel.
Without further ado, here are the six scripts:
New Table of Contents
TO CREATE A BUTTON WHICH LINKS TO A NEW SCENE OR A NEW SECTION OF THE SCENE.
on (release) { gotoAndPlay("pagetwo", 1);
}
In this example "page two" refers to the name of the scene you want the button to take the user to and the number after the comma represents the frame number, these are the factors that need to be adjusted to suit your own project.
BUTTON TO PLAY A MOVIE CLIP
Attach the following code to the button.
on (release) { mymovie.play(); }
In this example "mymovie" refers to the name of the movie you want the button to play, this is the factor that needs to be adjusted to suit your own project.
BUTTON TO STOP A MOVIE CLIP
Create your button and attach the following code to it.
on (release) { mymovie.stop(); }
BUTTON TO SEND AN E-MAIL
on (release) { getURL("mailto:name@domain.com"); }
BUTTON TO DISPLAY A PREVIOUSLY HIDDEN ITEM
First create a movie clip and inside this clip put the image you want to appear in your function. Make the movie about twenty seconds long and put a keyframe in the first and last frames.
Select your image in the first key frame (frame 1) and use the properties panel to adjust the Alpha Color setting down to 0%. Now create a motion tween between the two keyframes.
Select the first keyframe and in the actions panel put the following
stop();
Repeat this process for the end keyframe.
Test your movie quickly and you should see your image fade in across the frames.
There's that bit done!
Go back to the stage and place an instance of your fade in movie clip on the stage and name it in the properties panel (under where it says Movie Clip).
Select the button you wish to affect your movie and type the following into the action panel
on (release) { first.play(); }
In this example "first" refers to the name of the movie you want the button to play, this is the factor that needs to be adjusted to suit your own project.
BUTTON TO HIDE A PREVIOUSLY DISPLAYED ITEM
Create a movie clip and inside this clip put the image you want to disappear in your function. Once again make the movie about twenty seconds long and put a keyframe in the first and last frames.
Select your image in the last key frame (frame 20) and use the properties panel to adjust the Alpha Color setting down top to 0%. Now create a motion tween between the two keyframes.
Select the first keyframe and in the actions panel put the following
stop();
Repeat this process for the end keyframe.
Test your movie quickly and you should see your image fade out across the frames.
Now it's back to the stage to get that button working!
Go back to the stage and place an instance of your fade out movie clip on the stage and name it in the properties panel.
Select the button you wish to affect your movie and type the following into the action panel
on (release) { second.play(); }
In this example "second" refers to the name of the movie you want the button to play, this is the factor that needs to be adjusted to suit your own project.
USEFUL LINKS
Here are a few actionscript web resources to get you further on your way;
http://www.actionscript.org/
http://www.actionscript.com/
http://www.adobe.com/devnet/actionscript/
http://www.friendsofed.com/downloads.html
Good luck!
New Amazon Voting (Plexo)
Essential ActionScript 3.0 (Essential) by Colin Moock
ActionScript 3.0 is a huge upgrade to Flash's prog more...0 points
Learning ActionScript 3.0: A Beginner's Guide by Rich Shupe, Zevan Rosser
<b>Product Description</b><br /> more...0 points
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers by Joey Lott, Darron Schall, Keith Peters
Well before Ajax and Microsoft's Windows Presentat more...0 points
Foundation Actionscript 3.0 Animation: Making Things Move! by Keith Peters
In this book, you'll learn <ul> <li>Al more...0 points
ActionScript 3.0 Game Programming University by Gary Rosenzweig
<p style="MARGIN: 0px"> </p> more...0 points









