flash+xml flash广告切换源码代码
这是一款广告切换代码哦,是用flash xml实现的一款哦,下面看看源码吧,如果你要下载就到我们的下载 地址吧。
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 < 8)
{
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 == 7 ? (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 < 8)
{
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 ? (7) : (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 = setInterval(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();
效果图片
xml文件格式
<?xml version="1.0" encoding="utf-8"?><content>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/01.jpg</image>
</item>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/02.jpg</image>
</item>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/03.jpg</image>
</item>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/04.jpg</image>
</item>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/05.jpg</image>
</item>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/06.jpg</image>
</item>
<item>
<title></title>
<url>http://www.226511.cn/</url>
<image>images/07.jpg</image>
</item>
</content>
素材包下载地址h
http://down.226511.cn/down/code/js/2009/0317/715.html
补充:flash教程,动画技术