Flash and Actionscript Basics

I’m trying to learn more about Flash since it’s fun and challenging. A lot of times when you’re dealing with clients their inclination is to have something visually interesting with animation and some level of interactivity and Flash is good for that. Flash has several other good things going for it, like it’s harder to reverse engineer someone else’s Flash work, which has obvious benefits from the point of view of keeping business.

As I learn I am going to show the things I’ve learned to everyone else because many people are in a similar position in terms of being Flash novices. When I get more time I may put together a few tutorials in Wink.

A couple basics about Flash that bear mention:

  1. Flash uses vector graphics. Vector graphics use geometrical primitives like lines and circles to represent images rather than a collection of pixels as in bitmapped images. This makes the graphic easier to manipulate and store in memory.
  2. Flash is scalable. Since Flash is vector-based, Flash movies can be scaled or resized while retaining the same appearance at every size. This is useful when designing for the web because many people view websites at different sizes and resolutions.
  3. Flash looks the same on every computer. According to a recent presentation by Kevin Lynch of Macromedia, “the Flash Player has more reach than any browser or operating system”, which means that when you design in Flash you can be confident that it will look the same wherever you go.

One of the great things about Flash is that it supports scripting capabilities that allow you to give certain behaviors to different parts of your Flash movies. You can create buttons that move around when you click them, or you can play multimedia clips, for example. It’s very flexible. Flash has its own scripting language called ActionScript, which uses a syntax similar to JavaScript.

Here are a couple useful ActionScript things I learned last night you can use to for simple behaviors. I used Macromedia Flash MX. That may make a difference in how I do it. Just FYI.

  1. Create a button that opens a webpage when you click on it. Quick and dirty. Create a keyframe. Add a graphic to your scene. Convert it into a symbol, specifically a button by right-clicking the graphic and selecting “Convert to symbol”. Click on the object and open your “Actions” dialog menu. Add the following ActionScript:

    on (press) {
         getUrl ("http://www.website.com", "_blank");
    }
    

    Now when you test the movie, you should be able to click the button graphic and have it open the desired link in a new browser window. Tada! Simple.

  2. Create a new button to launch a new scene. Sometimes in Flash you need to layer your movies with different ways they could play out depending on the user behavior. Think of it as forks in the road. When your movie gets to a certain point, you may want the viewer to decide which direction they would like to go, “Do you want to take the red pill or the blue pill?”, and for that you might need separate scenes. A red pill scene and a blue pill scene. This is pretty simple to do in Flash.

    Quick and dirty. Follow the directions above to create a button symbol in your default scene. Go to the menu and select “Insert” then “Scene” this will add an additional scene to your Flash movie. Use the “Edit scene” icon to switch to your various scenes. You may want to rename your scene by double clicking it’s name in the Scenes panel. I’ll go ahead and rename it to “blippo”. Throw a graphic into this new scene then switch back to your main scene.

    Now add the following ActionScript to your button symbol just like you did in the previous example:

    on (press) {
       gotoAndPlay ("blippo", 1);
    }
    

    Now test the movie. When you click the button, it should go to the scene we named “blippo” at frame 1. You can obviously set the scene and frame number to whatever you need. Often times, you may want to goto a particular animation that starts in a particular frame. This is a good way to nest commonly used animations.

This is very very basic stuff. If I need to get any more basic let me know.

One comment

  1. hi, i would like to some more basics i am using a next and previous buttons. for next button, i gave the following AS.

    on (release) {
    gotoAndPlay(“34″);
    }

    This tells to goto or jump to particular frame.

    but when used the same script for previous button like

    on (release) {
    gotoAndPlay(“5″);
    }

    in the above AS am asking to play back the 5th frame instead it plays the next frame only i.e the 35th frame. wats wrong with my AS. please do clear my doubt and give any idea how to do it.