Flash Actionscript for Beginners

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 0 people | Log in to rate

Ranked #2,496 in Tech & Geek, #60,976 overall

Flash Actionscript for Beginners

Action script is the in built programming language attached to Flash which transforms it from a linear animation tool into a versatile program capable of creating interactive applications.

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:

TO CREATE A BUTTON WHICH LINKS TO A NEW SCENE OR A NEW SECTION OF THE SCENE. 

Essential to navigation in Flash applications are the buttons a user will click on to get them around from place to place. To have a button perform this function simply select it and attach the following code by typing it into the actions window.

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 

Let's say you have a movie clip and you place an instance of it on the stage. It would be nice to have a button that plays your movie. Using the properties panel give your movie clip instance a name and then create the button you wish to be used as a play control.

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 

Say you want to have a button that can make the movie clip you have on your stage stop playing.

Create your button and attach the following code to it.

on (release) { mymovie.stop(); }

BUTTON TO SEND AN E-MAIL 

A useful aspect of any application is a way for the user to make contact with you (or your client if you are creating the application for someone else). Attach the following code to a contact button to give the button this functionality.

on (release) { getURL("mailto:name@domain.com"); }

BUTTON TO DISPLAY A PREVIOUSLY HIDDEN ITEM 

In this example let's say you want a user to be able to click on a button and have a previously invisible picture materialise on the screen. Here's how to do it;

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 

In this example let's say you want a user to be able to click on a button and have something on the screen disappear from view.

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 

You will be able to appreciate the versatility of these scripts as you play around with them and whilst they are fairly simple they will make a flash application interactive and smarter in appearance.

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

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

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

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

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

ActionScript 3.0 Game Programming University by Gary Rosenzweig

<p style="MARGIN: 0px"> </p> more...0 points

New Guestbook 

submit

by StefaninaHill

I am a freelance graphic designer and writer, head over to www.fluffylikerazors.co.uk to see more. Updates here coming soon. (more)

Explore related pages

Create a Lens!