User:Demoninabottle

From Wikipedia, the free encyclopedia

[edit] Basic ActionScript

This is demoninabottle's (Tim Nadeau-Rifkind's) guide to some of the basics of scripting games. Actionscript, like most computer languages, is tough stuff to learn, but once you get the hang of the basic, you can pretty much teach yourself everything else you need to know through the help section. However, this won't cover much code theory, but give you the code so you can get to work.

Buttons

Buttons tell your flash what to do when they are pressed, toggled, rolled over, etc. There are different instances for buttons then for mc's. For instance,if you gave an mc the actions "on(release){_root.play();}" the output would say "syntax error." That method only works for buttons, which I will now cover. Buttons make your flash animation or presentation much less linear. By putting "stop();" in the frame's actions panel, it will tell the movie to stop. Then put, on a button's action's panel that is in the same frame "on(release){_root.play();}" This means that the movie with remain stopped until the user presses the button with the code. If you want a button to play from a certain frame when pressed, the code would look like "on(release){_root.gotoAndPlay(frame,scene);}" Using "_root", buttons can target movieclips (mc). If you noticed in my "play" code, it said "_root.gotoAndPlay". If there was an mc or button on stage with an instance name of "ball", I could put "ball" between the "root" and the meathod looking like this. "on(press){_root.ball.play();}" Now, when the button is pressed, the mc ball plays as opposed to the animation.