Generally Flash comes with two meanings – 1) Flash for Designer & 2) Flash for Developers (ActionScript). Designer alwaysÂ threaten about ActionScripting. It is not that complicated at basic level where Designer can levarage the benefits of ActionScripting to their Creative Work without having Programming knowledge.
If you already know the Flash, using tools and creating animations, you may want to add some interactivity to your skills.
Actionscript is written as a series of statements within a Flash movie, and is placed either in a frame or in an external class file. In the Flash intro class, we also put actionscript on buttons and movieclips, but that was done for the sake of easier learning.
ActionScript, an object oriented programming (OOP) language builtÂ for Flash/Flex developement. There are versions of actionscript like Flash (7/8/ cs2 etc..), these are ActionScript 1.0, 1.1, 2.0, 3.0.Â Based on the Flash version, adobe provides default scripting version which is located at Publish Settings in Flash IDE (Integrated Development Environment).
Â 1. TRACE
Trace function allows you to print information to your output window in Flash. This is not visible to those who view the SWF on the web. Trace is especially useful for debugging, if something goes wrong and you want to figure out why. You can trace simple text or the contents of variables.
trace(â€Text or variables can go hereâ€);
Functions are basically reusable chunks of code that you donâ€™t want to rewrite over and over again.Â It saves your coding time and add scalability layer to your code.
Flash Timeline refers to the sequence of frames and keyframes in either a movieclip or on the Stage or main movie. The stage’s timeline can be treated in actionscript as an instance of a movieclip. It is represented either as _root (from any timeline in the movie which is deeply nested to N-level), or as _parent from a movieclip placedÂ onÂ main timeline frames. It is often referred to as the main timeline.
5. PLAYHEAD CONTROL
Using simple playhead control, you can take control of your timeline. A lot of animations you can place on timeline which can be easily played using playhead functions. These include:
Assigning attributes allows you to dynamically store or update items in your variables(Container) using Actionscript. This includes visibily, scale, alpha, position etc… Some examples:
7. IF STATEMENTS
if statements are used to take decisions inside code. It is straightforward.
Â Â trace(“Alpha is 50”);
Â Â //do something
Â //do alternative
8. FOR LOOP & WHILE LOOP
Loops are used to perform specific tasks to certain number of times or until a condition satifies. There are two kind of loops – FOR loop, & WHILE loop.
for (var startCounter=0; startCounter<5; startCounter++)
while (startCounter != 10)
trace(“Count “+ startCounter);
ButtonsÂ can be used to control movies.Â To accomplish this, you need to attach action to the button or movie clip with theÂ on() function. You could write actions in the Timeline using event handler functions with instance names of button or movie clips or you can write actions on button or movie clips, for this you need to select button or movie clip and Press F9 to open Action window.
Hope you like this tutorials. I am working on it to proceed further with more detailed one.
Happy Coding 🙂