新浪体育频道FLASH,AS代码

Calchas 发表于 2010, February 23, 11:02 AM

请看新浪体育频道http://sports.sina.com.cn/中左上的那个flash,能自动循环播放,同时能自由点击1、2、3、4、5按钮 选择观看。

第一帧脚本:
function strtoarray(str, myarray)
{
while (str.indexOf("|") != -1)
{
myarray.push(str.slice(0, str.indexOf("|")));
var _l1 = str.slice(str.indexOf("|") + 1);
} // end while
myarray.push(_l1);
return(myarray);
} // End of the function
function replinkad(linkarray)
{
var _l1;
var _l3;
_l1 = 0;
while (_l1 < linkarray.length)
{
while (linkarray[_l1].indexOf("^") != -1)
{
_l3 = linkarray[_l1].slice(0, linkarray[_l1].indexOf("^"));
_l3 = _l3.concat("&");
_l3 = _l3.concat(linkarray[_l1].slice(linkarray[_l1].indexOf("^") + 1));
linkarray[_l1] = _l3;
} // end while
_l1++;
} // end while
} // End of the function
function replink_deleted(textarray)
{
var _l2;
var _l4;
_l2 = 0;
while (_l2 < textarray.length)
{
if (textarray[_l2].indexOf("
{
textarray[_l2] = "" + textarray[_l2] + "";
} // end if
_l2++;
} // end while
} // End of the function
function preloader1(target)
{
mc = target.pic;
var _l2 = int(mc.getBytesLoaded() / mc.getBytesTotal() * 100);
if (_l2 >= 100)
{
delete target["onEnterFrame"];
target._width = borderwidth;
target._height = borderheight;
} // end if
} // End of the function
stop();
pic_array = new Array();
link_array = new Array();
text_array = new Array();
strtoarray(String(pics), pic_array);
strtoarray(String(links), link_array);
replinkad(link_array);
if (_root.textheight > 0)
{
strtoarray(String(texts), text_array);
replink(text_array);
_root.text_m._x = -borderwidth / 2;
_root.text_m._y = borderheight / 2 - textheight / 2;
} // end if
var adPos = -1;
var ifSwf = false;
if (pic_array.length > 2)
{
if (pic_array[pic_array.length - 1].indexOf("http://ad") != -1)
{
var tempContent = pic_array[pic_array.length - 1];
var i = pic_array.length - 2;
while (i >= 2)
{
pic_array[i + 1] = pic_array[i];
i--;
} // end while
_root.pic_array[2] = tempContent;
tempContent = link_array[link_array.length - 1];
var i = link_array.length - 2;
while (i >= 2)
{
link_array[i + 1] = link_array[i];
i--;
} // end while
link_array[2] = tempContent;
if (_root.textheight > 0)
{
tempContent = text_array[text_array.length - 1];
var i = text_array.length - 2;
while (i >= 2)
{
text_array[i + 1] = text_array[i];
i--;
} // end while
text_array[2] = tempContent;
} // end if
} // end if
} // end if
Stage.scaleMode = "noScale";
_root.loader.swapDepths(9);
_root.loader._xscale = Math.ceil(_root.borderwidth * 100 / 329);
_root.loader._yscale = Math.ceil(_root.borderheight * 100 / 206);
_root.loader._x = -borderwidth / 2 + 1;
_root.loader._y = -borderheight / 2 - textheight / 2 + 1;
_root.border.swapDepths(10);
_root.border._width = borderwidth - 1;
_root.border._height = borderheight - 1;
_root.border._x = -borderwidth / 2 + 1;
_root.border._y = -borderheight / 2 - textheight / 2 + 1;
_root.linkbutton1._xscale = Math.ceil(_root.borderwidth * 100 / 400);
_root.linkbutton1._yscale = Math.ceil((_root.borderheight + _root.textheight) * 100 / 300);
_root.linkbutton1._x = -borderwidth / 2 + 1;
_root.linkbutton1._y = -borderheight / 2 - textheight / 2 + 1;
var current_pic = -1;
if (pic_array.length == 1)
{
m = createEmptyMovieClip("image0", 0);
m_load = m.createEmptyMovieClip("pic", 0);
m._x = -borderwidth / 2;
m._y = -borderheight / 2 - textheight / 2;
m_load.loadMovie(pic_array[0]);
m.onEnterFrame = function ()
{
preloader1(this);
};
current_pic = 0;
}
else
{
gotoAndPlay("multipic");
} // end if


第二帧脚本:
function init_trans()
{
for (n = 0; n < _root.trans_total; n++)
{
with (eval("_root.mask" + n))
{
_x = -_root.borderwidth / 2;
_y = -_root.borderheight / 2 - _root.textheight / 2;
} // End of with
} // end of for
} // End of the function
function preloader(target, flagSwfPre)
{
mc = target.pic;
var _l3 = int(mc.getBytesLoaded() / mc.getBytesTotal() * 100);
_root.loader.gotoAndStop(_l3);
if (_l3 >= 100)
{
delete target["onEnterFrame"];
setProperty("_root.buttonbanner.num" + (target.getDepth() + 1), _alpha, "100");
if (_level0.image0 == target)
{
mc._alpha = 100;
_root.buttonbanner.num1.gotoAndStop(3);
_root.current_pic = 0;
_root.timer.gotoAndPlay(2);
} // end if
target._width = borderwidth;
target._height = borderheight;
if (flagSwfPre == 1)
{
mc.stop();
} // end if
} // end if
} // End of the function
function swappic(d1, d2)
{
with (eval("_root.image" + _root.pre_pic))
{
swapDepths(6);
} // End of with
with (eval("_root.image" + _root.current_pic))
{
swapDepths(d1);
} // End of with
with (eval("_root.image" + _root.pre_pic))
{
swapDepths(d2);
} // End of with
} // End of the function
function changepic()
{
if (pic_array.length > 1)
{
for (i = 0; i < pic_array.length; i++)
{
setProperty("_root.image" + i + ".pic", _alpha, "0");
with (eval("_root.buttonbanner.num" + (i + 1)))
{
gotoAndStop(1);
} // End of with
} // end of for
_root.mask_total = eval("_root.mask" + _root.trans_cur + ".mask_total");
if (_root.mask_total > -1)
{
for (j = 0; j <= _root.mask_total; j++)
{
removeMovieClip("_root.mask" + _root.trans_cur + ".block" + j);
} // end of for
} // end if
with (eval("_root.image" + _root.pre_pic + ".pic"))
{
setMask(null);
} // End of with
if (_root.ifSwf && _root.pre_pic == _root.adPos)
{
with (eval("_root.image" + _root.adPos + ".pic"))
{
gotoAndStop(1);
} // End of with
_root.intervaltotaltime = _root.intervaltotaltimeSave;
} // end if
_root.trans_cur = random(_root.trans_total);
with (eval("_root.image" + _root.current_pic + ".pic"))
{
setMask("mask" + _root.trans_cur);
} // End of with
_root.masking = true;
with (eval("_root.mask" + _root.trans_cur))
{
play();
} // End of with
setProperty("_root.image" + _root.current_pic + ".pic", _alpha, "100");
setProperty("_root.image" + _root.pre_pic + ".pic", _alpha, "100");
if (_root.pre_pic > _root.current_pic)
{
_root.ifswaped = true;
_root.swappic(_root.pre_pic, _root.current_pic);
} // end if
with (eval("_root.buttonbanner.num" + (_root.current_pic + 1)))
{
gotoAndStop(3);
} // End of with
if (_root.textheight > 0)
{
with (_root.text_m.titletext)
{
htmltext = "" + _root.text_array[_root.current_pic] + "";
} // End of with
} // end if
} // end if
} // End of the function
function gotolink()
{
if (_root.pre_pic == -1)
{
getURL(link_array[0], "_blank");
}
else
{
getURL(link_array[_root.pre_pic], "_blank");
} // end if
} // End of the function
function gotolink_mask()
{
getURL(link_array[_root.current_pic], "_blank");
} // End of the function
function playandswitch(pic)
{
if (!_root.masking)
{
_root.timer.gotoAndStop(1);
_root.pre_pic = _root.current_pic;
_root.current_pic = pic;
_root.changepic();
}
else
{
_root.next_pic = pic;
} // end if
} // End of the function
function draw_mask(mask, a, b, c, d)
{
mask.clear();
mask.lineStyle(0, 0);
mask.moveTo(a, b);
mask.beginFill(0);
mask.lineTo(a, d);
mask.lineTo(c, d);
mask.lineTo(c, b);
mask.lineTo(a, b);
mask.endFill();
} // End of the function
stop();
_root.attachMovie("pointerchanger", "pointer_btn", 50000);
_root.pointer_btn._alpha = 0;
_root.pointer_btn._x = -borderwidth / 2;
_root.pointer_btn._y = borderheight / 2 - _root.textheight / 2;
_root.pointer_btn._height = _root.textheight;
_root.pointer_btn._width = borderwidth;
var pre_pic = -1;
var current_pic = -1;
var next_pic = -1;
var intervaltotaltime = 5;
var intervaltotaltimeSave = 0;
var intervalsecond = 0;
var mask_total = -1;
var mask_num = 0;
var trans_total = 21;
var trans_cur = 20;
var ifswaped = false;
var masking = false;
_root.linkbutton._xscale = Math.ceil(_root.borderwidth * 100 / 400);
_root.linkbutton._yscale = Math.ceil(_root.borderheight * 100 / 300);
_root.linkbutton._x = -_root.borderwidth / 2;
_root.linkbutton._y = -_root.borderheight / 2 - _root.textheight / 2;
init_trans();
var i = 0;
b = createEmptyMovieClip("buttonbanner", 8);
b_banner_back = b.attachMovie("banner_back", "banner_back", 0);
b_banner_back._x = _root.borderwidth / 2 - b_banner_back._width;
b_banner_back._y = _root.borderheight / 2 - _root.textheight / 2 - 13;
onEnterFrame = function ()
{
if (i < _root.pic_array.length)
{
m = createEmptyMovieClip("image" + i, i);
m_load = m.createEmptyMovieClip("pic", 0);
b_num = b.attachMovie("button" + (i + 1), "num" + (i + 1), i + 2);
b_num._alpha = 0;
b_num._x = Math.ceil(_root.borderwidth / 2 - (_root.pic_array.length - i) * 23 + 7);
b_num._y = Math.ceil(_root.borderheight / 2 - _root.textheight / 2 - 10);
m._x = -_root.borderwidth / 2;
m._y = -_root.borderheight / 2 - _root.textheight / 2;
m_load.loadMovie(pic_array[i]);
m_load._alpha = 0;
var flagSwf;
if (_root.ifSwf && i == _root.adPos)
{
flagSwf = 1;
}
else
{
flagSwf = 0;
} // end if
m.onEnterFrame = function ()
{
preloader(this, flagSwf);
};
}
else
{
delete i;
delete onEnterFrame;
_root.loader._alpha = 0;
} // end if
i++;
};

« 上一篇 | 下一篇 »

引用: 点击获得Trackback地址,Encode: UTF-8 点击获得Trackback地址,Encode: GB2312 or GBK 点击获得Trackback地址,Encode: BIG5
发表评论:( 你的参与是我最大的动力! )