XML loading picture auto rotation display

Source: Internet
Author: User
Tags continue connect setinterval
xml| Display

Simulate Korean scrolling advertising effect, read pictures and instructions from outside and connect

because of the use of XML and external pictures, this program needs to download after viewing effect, This work is only used for tutorials and therefore does not do loading processing.

  Click to download source files

XML file part code (IMGLIST.XML)
//----------------------------------------------------------------------------------
<?xml version= ' 1.0 ' encoding= ' GB2312 '?>

<list path= "swf/1.jpg" info= "Beauty 1" >http://www.ebidea.com<;/list>
<list path= "swf/2.jpg" info= "Beauty 2" >http://www.ebidea.com<;/list>
<list path= "swf/3.jpg" info= "Beauty 3" >http://www.ebidea.com<;/list>
<list path= "swf/4.jpg" info= "Beauty 4" >http://www.ebidea.com<;/list>
<list path= "swf/5.jpg" info= "Beauty 5" >http://www.ebidea.com<;/list>
<list path= "swf/6.jpg" info= "Beauty 6" >http://www.ebidea.com<;/list>
<list path= "swf/7.jpg" info= "Beauty 7" >http://www.ebidea.com<;/list>
<list path= "swf/8.jpg" info= "Beauty 8" >http://www.ebidea.com<;/list>
<list path= "swf/9.jpg" info= "Beauty 9" >http://www.ebidea.com<;/list>
<list path= "swf/10.jpg" info= "Belle" >http://www.ebidea.com<;/list>
<list path= "swf/11.jpg" info= "Beauty One" >http://www.ebidea.com<;/list>
</imgList>

Flash as code:
//----------------------------------------------------------------------------------
Stage.showmenu = false;
Stage.scalemode = "Noscale";
Fscommand (Allowscale, true);
Initialize screen size
System.usecodepage = true;
Chinese support
IMGW = 580;
IMGH = 386;
Initialize scene width and height
Jtime = 1500;//initialization of the scrolling interval, default 1.5 seconds
var myload = new XML ();
Myload.ignorewhite = true;
Myload.load ("Imglist.xml");
Myload.onload = function (success) {//Load XML file
if (success) {
Createemptymovieclip ("IMG_MC",-16383);//loaded successfully, initialize rolling MC element
Img_mc.createemptymovieclip ("LoadImg0", 1);//Create a child component of a loading picture
img_mc._x =-imgw;//initialization coordinate position
x = 0;//Initializes a pointer to the display picture
Imglist ()//Execute function imglist ();
MAKEBTN ()///Create control button
} else {
Trace ("Error!") Loading XML file is unsuccessful! ");//Return error message
}
};
function makebtn () {//This functions initializes the control button symbol
_root.attachmovie ("Next_btn", "n_btn", 50);/Connect the Back button
_root.attachmovie ("Next_btn", "u_btn", 51);/Link Forward button
U_btn._rotation = 180;//control forward button Flip angle
u_btn._x = imgw-50;//
U_btn._y = imgh-30;//
n_btn._x = imgw-25;//
N_btn._y = imgh-30;//initialization of two buttons
U_btn.onrelease = moveleft;//function to scroll left when this button is clicked
N_btn.onrelease = moveright;//' ' "'" ' right scrolling function
U_btn.onrollover = function () {//Clear auto scrolling option when mouse is on this button
Clearinterval (MA);
};
U_btn.onrollout = function () {//continue to scroll automatically when mouse is left
MA = SetInterval (MoveLeft, jtime);
};
N_btn.onrollover = function () {//
Clearinterval (MA);
};
N_btn.onrollout = function () {//
MA = SetInterval (MoveLeft, jtime);
};
}
function Imglist () {//xml analysis functions, and constructs a scrolling component
MyList = MyLoad.firstChild.childNodes;
Mylistlen = Mylist.length;
For (I=1 i<mylistlen+2; i++) {
Img_mc.loadImg0.duplicateMovieClip ("Loadimg" +i, i+1);
}
For (i=0 i<mylistlen+2; i++) {
Loadimgs = eval (img_mc["loadimg" +i));
Mcbtns = Img_mc.attachmovie ("BTN_MC", "btn" +i, i+mylistlen+4);//Connect Picture button
LOADIMGS.BTN = mcbtns;//Initialize the corresponding buttons for each picture
LOADIMGS.I = i;//Initializes a pointer to the current picture
LOADIMGS.LOADIMG ()//Execute Picture load function
}
}
function moveimg () {//Picture scrolling functions
if (X>mylistlen) {//control to the left loop
x = 1;
img_mc._x = 0;
}
if (x<1) {//Control loops right
x = Mylistlen;
img_mc._x =-IMG_MC._WIDTH+IMGW;
}
TextValue (Mylist[x-1].attributes.info),//Perform text display function
Onenterframe = function () {//Cyclic detection scrolling
Targetx =-X*IMGW;
Img_mc._x + = (targetx-img_mc._x) *0.2;
if (Math.Abs (targetx-img_mc._x) <=0.2) {//Position compliant after stop loop
img_mc._x = Targetx;
Delete Onenterframe;
}
};
}
function MoveLeft () {//left scroll
x + +;
Moveimg ();
}
function MoveRight () {//Scroll right
x--;
Moveimg ();
}
MA = SetInterval (MoveLeft, jtime);//automatic scrolling
MOVIECLIP.PROTOTYPE.LOADIMG = function () {//MC load picture functions
if (this.i = = 0) {//Add the last picture at the top to facilitate the left loop.
This.loadmovie (Mylist[mylistlen-1].attributes.path);
else if (this.i = = mylistlen+1) {//At the last frame position how to add the first picture to facilitate the right loop
This.loadmovie (Mylist[0].attributes.path);
} else {
This.loadmovie (Mylist[this.i-1].attributes.path);
}
this._x = this.i*imgw;//initialization position, connecting one by one
this.btn._x = this._x;//controls the position of the transparent button above the picture
This.btn._width = imgw;//
This.btn._height = imgh;//control ' "' corresponding dimension
This.btn.onRelease = function () {//Click the Picture button to connect to the URL
GetURL (Mylist[this.i-1].childnodes);
};
This.btn.onRollOver = function () {//When mouse stops automatic scrolling on picture
Clearinterval (MA);
};
This.btn.onRollOut = function () {//When the mouse leaves the picture, continue to scroll automatically
MA = SetInterval (MoveLeft, jtime);
};
};
Textfiled ();
function TextValue (myvalue) {//The description of the corresponding picture for the text box;
MyFormat = new TextFormat ();
Myformat.align = "right";
Myformat.color = 0XFFFFFF;
Myformat.font = "Song Body";
Myformat.size = 12;
Myformat.bullet = false;
Myformat.underline = false;
_root.createtextfield ("MyText", imgW-360, imgH-38, 300, 16);
Mytext.selectable = false;
Mytext.text = myvalue;
Mytext.settextformat (MyFormat);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.