Flash Templates Tutorials - Flash ActionScript
Flash uses ActionScript web language for creating online animation, web applications, web programs and presentations. This effective object-oriented web language of script creation is based on ECMAScript standards. There are two versions of ActionScript language: 1.0 and 2.0, although any of them can be used in Flash document. Regardless of the fact that one can insert scripts into the projects, there is no need in using ActionScript for creating animation and various effects. However, you have lots of creative possibilities when using ActionScript within Flash files. In case you have never used ActionScript code before, you will be able to insert it by yourself and you will see that it is very simple.
ActionScript symbols examples management
ActionScript presents convenient opportunity of changing any properties at the objects scene. One can even create a video consisting of 1-2 pictures but full of motion. Creating scripts little in volume saves the necessity of creating complicated scenes and allows to reduce the size of the operating file greatly. Lets see how to move objects by setting its position data:
There is an essential minimum firstly:
You will need two text fields to enter position data, two symbols situated in the library – button and the object to move.
Place the editing text fields with the names ‘x’ and ‘y’; move the button and object symbols from the library. Now set the name of the object (let it be ‘toy’ for instance) which we will experiment with.
Symbols examples names:
Left click twice on the symbol – Instance Properties window is opened, set the symbol behavior as the movie clip even if it is static image, at the Instance Name field enter the name of the example and press OK.
Objects management is carried out with the help of Set Property action:
Set it for the button just like you have been doing it previously with other actions, the following items will become available at the right part of the window: Set – here we select the necessary property of the object; Target – enter the name of the object (toy as we have agreed) in case the object is situated on another layer you should set its path; Value – set the value.
Set the values at the text fields for the position data of the moved object. Your script will look like this one:
Set Property ("toy", X Position) = x
Set Property ("toy", Y Position) = y
If during the testing of the project you set the necessary values in the fields and press the button, then the object will be moved to the set position data. In order to examine all the possible ways of object management, add the separate fields for every value and set the appropriate property for the button:
X Position – object position in horizontal line
Y Position – object position in vertical line
X Scale – object width in % regarding the value set previously
Y Scale – object height in % regarding the value set previously
Alpha – object transparency, range of value from 0 – transparent till 100 – nontransparent
Visibility – object turn on/off, True – turned on, False – turned off (it is impossible to change other properties in this case)
Rotation – object rotation, the values are set in degrees (positive – the object is rotated clockwise, negative degree – the object is rotated counter-clockwise)
Name – sets the name of the object
The following properties which changing manages the entire movie:
High Quality – quality of demonstration set, 0-low, 1-normal, 2-high quality
Show Focus Rectangle – turns on the frame when switching on buttons with the help of Tab, True – shows the frame, False – the frame is hidden
Sound Buffer Time – buffer size set in seconds when using streams of sound
Call – actions reuse.
Perhaps, you would like to use the same set of instructions for various buttons or within various pictures. In order not to copy and paste the set of instructions at ten places you can write it one time at the separate picture and then use it with the help of Call command. Define the picture where the movie should switch to with the help of Go To command. In case the desired picture can not be found because of the wrong name or it wasn’t uploaded into the player, Flash will ignore the Call instruction. (In order to check if the required picture is uploaded into the player you can use _framesloaded). When the set of instructions is already launched the movie goes back to the instruction set up by the Call. In order to create a library of instructions sets, create a movie where you will write a separate instruction set for the every individual picture. Then create a name label for every picture in order to make it easier to know what is going on. If you want to deliver the values into another movie, you can do it with the help of variables. The set movie should also contain all the necessary numbers by way of variables. In order to receive or deliver numbers when using Call instruction you can use Set Variable.
For example, this instruction sets all the variables at the data base before operating AddDatabaseRecord:
Set Variable: "/Database:Name" = "Franz Schubert"
Set Variable: "/Database:Occupation" = "Musician"
If (/Database:Result eq "OK")
Go to And Stop ("OK")
Go To And Stop ("Error")