How to Program in Flash (Basic Actionscript 2.0)

Опубликовал Admin
26-09-2016, 17:20
3 947
0
Adobe Flash is an awesome program that creates movies, games, presentations, and almost anything else. It combines a paint program, a movie editor, and a programming language to make a great program. "Where do I start?", you ask. Well, you came to the right place.

Steps

  1. Know your Flash version. Anything at or above Flash 7 (Not CS7, just 7; all CS Flash versions should work) should be able to handle what we will cover here.
  2. Understand what a programming language is. A programming language is an intermediate language between humans ("Hey, what's up") and computers (10111010001000x101110001110). Let's say you met someone who didn't speak English, and spoke Spanish. If you both knew French, you can communicate, just not the way you naturally would.
  3. Understand we will be using ActionScript 2. ActionScript is the programming language for Flash. ActionScript 1 is outdated and ActionScript 3 is too complex for a short wikiHow article.
  4. Now that we've laid some ground rules, we can begin with a basic script. Open a new project in Flash, making sure it's ActionScript 2. Using the drawing tools, draw a simple button on the screen. Highlight it with the mouse (the selection tool), right click, and click "Convert to Symbol". You can also press F8 with the button selected.
  5. A dialog should pop up. Just set the type as button and click OK for now. Note that it pops up in the Library.
  6. Double-click the button. In the timeline, use Insert Keyframe to put in a little box in the rows labeled Up, Over, Down, and Hit. You can mess with these on your own time, just make sure there is a button in up and hit, at minimum. On the top of the stage, click Scene 1 to return.
  7. In the timeline, insert another frame and use the text tool to write "YAY!" on the middle. This isn't really important and is only for reference. You can put anything on the second frame.
  8. We can begin scripting now. With the first frame selected, press F9 or right-click, and click Actions. In the window that appears, type "stop();" without the quotation marks. When this runs, the movie will stop on the first frame (to avoid bugs in the future you may want to do this to Frame 2 as well).
  9. Now that your frames are coded, open the Actions window for the button the same way you did with the frame. Type in: on (release) {     gotoAndStop(2); } This tells Flash when your mouse button releases over the button, you want the timeline to go to Frame 2 ("YAY!") and stop there, if you didn't type that in for Frame 2. You can also use gotoAndPlay to trigger an animation, but that's more advanced.
  10. Press Ctrl + Enter to run your movie (Cmd + Return on Macs). Click the button.

Tips

  • Keep it sweet and simple. Programming is only half of Flash, and that's why some people prefer ActionScript 2. ActionScript 3 is a bit more complex.
  • Work your way up from impossible quizzes to first-person shooters to get yourself going. You'll learn a lot on the way.
  • There are innumerable YouTube tutorials to get you started, and probably some great books at your local bookstore.

Warnings

  • This can get very confusing. Walk before you run, and always save/backup your work, especially when you're new and might not be able to figure it out again.

Things You'll Need

  • Adobe Flash (Version 7+, it may be Macromedia if it's really old)
  • A basic understanding of programming languages
Теги:
Information
Users of Guests are not allowed to comment this publication.