In this tutorial the combo
box Compinent of Flash MX 2004 is used and the
contents of Combo Box and Description of each
combo bix item id given in a text file. First
of all we will give a look at out Text file.
&lst=jaipur,Bombay,Delhi,Calcutta
&jai=We live in jaipur.
&Bom=Bombay is the capital of Maharashtra
&Del=Delhi is the capital of India.
&Cal=Calcutta is Capital of West Bengal. |
This is our text file in which we will save
all our variables. The first variable is lst
which contain the total contents of the Combo
Box, this means what are the all elements of
our Combo Box. All other variables are the values
of each item of Combo Box. if you see you will
find that all other variables other then first
one have the names with first three characters
of the items of array (Combo Box Items).
In the first frame of our Flash Movie we will
read the variables from text file for this we
will write this simple one line script on the
first frame.
|
loadVariablesNum("cmtx.txt",0);
|
Now insert a keyframe on the third frame of our
movie and make one combo box and one dynamic text
box on the stage. Give combo box the name "mycmb"
and dynamic text box "txtb". After this
select the third frame and write this script on
third frame.
stop();
lstarr = lst.split(",");
j = lstarr.length;
for (i=0; i<j; i++) {
nmt = lstarr[i];
mycmb.addItem(nmt);
} |
This script is convertin the first variable "lst"
to an array. Finding lebgth of that array and
adding elements in the combo box from that array.
So first variable is used as the Combo Box Elements
(Items). Now we will see how on selecting any
option from combo box the value of dynamic text
box gets changed. For this we will add this script
on the action of combo box.
on(change) {
sec = this.getValue() ;
sec = sec.slice(0,3);
_root.txtb.variable = (sec);
} |
Tnis script is tracing the value of selected
item and the slicing the first three characters
of that item those are the variable names of
Combo Box Item Description. For any furthur
help you can download and see the final source
file from here.