Flash image switching effect code

Source: Internet
Author: User
Tags eval setinterval

Function fadeTPl_1 (co, no)
{
CurrPicObj = co;
NextPicObj = no;
FadingLoop = setInterval (function ()
    {
If (nextPicObj. _ alpha >=100 & currentPic. _ alpha <= 0)
        {
ClearInterval (fadingLoop );
CurrentPic = nextPic;
IsFading = false;
Return (undefined );
} // End if
CurrPicObj. _ alpha = currPicObj. _ alpha-10;
NextPicObj. _ alpha = nextPicObj. _ alpha + 10;
}, 50 );
} // End of the function
Function getData ()
{
Var xmlObj = new XML ();
XmlObj. load ("xml/xml. xml ");
XmlObj. ignoreWhite = true;
XmlObj. onLoad = function (success)
    {
FixData (xmlObj );
};
} // End of the function
Function fixData (o)
{
Var _ l1 = 0;
While (_ l1 <o. firstChild. childNodes. length)
    {
PreLoadPic (_ l1, o. firstChild. childNodes [_ l1]. childNodes [2]. firstChild );
ArrUrl. push (o. firstChild. childNodes [_ l1]. childNodes [1]. firstChild );
ArrTitle. push (o. firstChild. childNodes [_ l1]. childNodes [0]. firstChild );
_ L1 ++;
} // End while
Linkbutton. onRelease = function ()
    {
GetURL (arrUrl [0], "_ blank ");
};
Btn1_mc.gotoAndStop (2 );
} // End of the function
Function preLoadPic (I, u)
{
I ++;
Eval ("img" + I + "_ mc"). loadMovie (u );
CheckPicLoad (I, eval ("img" + I + "_ mc "));
} // End of the function
Function checkPicLoad (I, o)
{
O. onEnterFrame = function ()
    {
If (int (o. getBytesLoaded ()/o. getBytesTotal () * 100)> = 100)
        {
Eval ("btn" + I + "_ mc"). _ visible = true;
Delete o ["onEnterFrame"];
} // End if
};
} // End of the function
Function start ()
{
GetData ();
} // End of the function
Function checkFade ()
{
Var I = 1;
While (I <5)
    {
If (eval ("btn" + I + "_ mc"). _ visible = false)
        {
Return (undefined );
} // End if
I ++;
} // End while
ClearInterval (picLoadLoop );
StartFade ();
} // End of the function
Function startFade ()
{
PlayerPlay ();
} // End of the function
Function picFade ()
{
NextPic = currentPic = 4? (1): (parseInt (currentPic) + 1 );
LoadFadeTpl (eval ("img" + currentPic + "_ mc"), eval ("img" + nextPic + "_ mc "));
} // End of the function
Function loadFadeTpl (co, no)
{
IsFading = true;
Linkbutton. onRelease = function ()
    {
GetURL (arrUrl [nextPic-1], "_ blank ");
};
SetButtonColor ();
FadeTPl_1 (co, no );
} // End of the function
Function setButtonColor ()
{
Var I = 1;
While (I <5)
    {
Eval ("btn" + I + "_ mc"). gotoAndStop (1 );
I ++;
} // End while
Eval ("btn" + nextPic + "_ mc"). gotoAndStop (2 );
} // End of the function
Function setCurrPic (cp)
{
If (currentPic = cp)
    {
Return (undefined );
} // End if
If (isFading = false)
    {
PlayerStop ();
NextPic = cp;
LoadFadeTpl (eval ("img" + currentPic + "_ mc"), eval ("img" + nextPic + "_ mc "));
    }
Else
    {
Trace (isFading );
} // End if
} // End of the function
Function playPrePic ()
{
PlayerStop ();
NextPic = currentPic = 1? (4): (parseInt (currentPic)-1 );
LoadFadeTpl (eval ("img" + currentPic + "_ mc"), eval ("img" + nextPic + "_ mc "));
} // End of the function
Function playNextPic ()
{
PlayerStop ();
PicFade ();
} // End of the function
Function playerStop ()
{
_ Root. player_mc.gotoAndStop (1 );
ClearInterval (fadeLoop );
} // End of the function
Function playerPlay ()
{
_ Root. player_mc.gotoAndStop (2 );
FadeLoop = setinteger (picFade, 4000 );
} // End of the function
Stop ();
Stage. scaleMode = "noScale ";
Stage. showMenu = false;
System. useCodepage = false;
Var picLoadLoop;
Var fadeLoop;
Var currentPic = 1;
Var nextPic;
Var arrUrl = [];
Var arrTitle = [];
Var isFading = false;
Var fadingLoop;
Var currPicObj;
Var nextPicObj;
PicLoadLoop = setInterval (checkFade, 500 );
Start ();

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.