Dynamic
When you do a picture Show or picture news, will often update the picture information in Flash, but if you manually add each time, it's a bit of a hassle. Now many websites use more, is the image of Sina online news scrolling flash. I also made a picture of scrolling up and down today.
source File Download:
Click here to download the source file
View Final effect
First, create a text file to store picture information, which can be modified by the background program (such as PHP) to modify the build.
New text file name is Imginfo.txt
The following is the text content, which is a sequence of picture names and descriptions:
Code:
Imgvar=1.png, picture one |2.png, picture two |3.png, picture three |4.png, picture four
Second, create Flash files
Create the "Next button (Btn_next)" "Previous button (btn_previous)" and The Empty MC (image) to load the picture and the dynamic text box (Var=imagetxt) that displays the picture description, respectively, in the home view.
The first frame of the main timeline is then written as the following code:
1. Load the text information file of the picture and convert it into a two-dimensional array.
Code:
System.usecodepage=true;
var lv_img=new loadvars ();
_global.img_array=new Array ();
_global.imginfo_array=new Array ();
Lv_img.onload=function (Success) {
if (success) {
Trace ("Load success!") ");
Img_array=this.imgvar.split ("|");
for (i=0;i<=img_array.length-1;i++) {
Imginfo_array[i]=img_array[i].split (",");
}
_root.image.loadmovie (Imginfo_array[0][0]);
_ROOT.IMAGETXT=IMGINFO_ARRAY[0][1];
Trace (Imginfo_array);
}else{
Trace ("Information loading failed!") ");
}
}
Lv_img.load ("Imginfo.txt");/Load Text information file
2. Add the previous and Next button action
Code:
var j=0;
Btn_previous.onpress=function () {
Trace (j);
if (j<=0) {j=img_array.length;}
_root.image.loadmovie (Imginfo_array[j-1][0]);
_ROOT.IMAGETXT=IMGINFO_ARRAY[J-1][1];
j--;
}
Btn_next.onpress=function () {
Trace (j);
if (j>=img_array.length-1) {j=-1;}
_root.image.loadmovie (Imginfo_array[j+1][0]);
_ROOT.IMAGETXT=IMGINFO_ARRAY[J+1][1];
j + +;
}
OK, put all the files in the same directory, the output is OK.