What is variable.
A variable is a value that is not constant. This value is changed
conditionally. For example weather is a variable, it is not same always.
Now in SWiSHScript, for example "X" is a variable and its value is
assigned x=10; in the beginning of Movie, but we want to change its
value at runtime (means you can change value while your SWF file is
playing), so we will simply assign a new value to "X" as x=20; at any frame.
Why we use variables?
Variables are used in many different ways to perform any specific task. For example
for getting/changing X,Y postions of sprite, for changing alpha, width etc. You can
direclty assign a new value to the object property (_width, _alpha, _X, _Y etc). Variables are also used to send/retierve data to/from PHP,ASP, JScript etc.
Here is an Example
For example you have a sprite named as circle and you want to know
its X position (what is the exact locaion of x where circle sprite is located).
Also check the provided example.
[swf=200x103]http://www.swish-db.com/Board/attach/smax/drgcir.swf[/swf]
On the very first frame of movie we have assigned a Static value to variable
vartext
| CODE |
onFrame (1) {
vartext=43;
}
|
This variable is assigned to display its value 43 in dynamic textbox.
Now see the Script on shape circle
| CODE |
on (press) {
startDragUnlocked();
}
on (release) {
stopDrag();
_root.vartext=_root.circle._X;
}
|
here we have assigned a dynamic value to a variable vartext, which is not static,
it changes when you drop cirle to any other point.
Download Example
In the above explanantion you have learned how to assign a vlaue to a variable.
For more details about Data Types of variables please read the following tutorial.
Data type is basically the characteristic of Variables (what kind of data they are supposed
to handle i.e numeric, string, boolean).
http://www.swish-db.com/phpBB2/viewtopic.php?t=5469
regards
Ali Roman.
|
|
|