效果:
http://www.gdys.cn/zhuzhu/pics.asp?MenuId=3
版本as2.0 场景高宽,975,510
第一祯as代码:
复制内容到剪贴板
代码:
//初始化部分
_global.elasticEaseOut = mx.transitions.easing.Elastic.easeOut;
System.useCodepage=true;
var myXML = new XML();
var L_Array = new Array();
var R_Array = new Array();
var idArray = new Array();
var xyArray = new Array();
var r_idArray = new Array();
var r_xyArray = new Array();
//初始化参数设置
var smallPicWidth = 50;
var smallPicHeight = 38;
var bigPicWidth = 613;
var bigPicHeight = 460;
var L_x = 300;
var L_y = 25;
var R_x = 300;
var R_y = 25-252;
myXML.ignoreWhite = true;
//初始化函数设置
myXML.onLoad = function(ok) {
if (ok) {
_global.scrollSpeed = myXML.firstChild.attributes.scrollSpeed;
albumText = myXML.firstChild.attributes.albumText;
_global.siz = myXML.firstChild.attributes.siz;
back.backin.picc.loadMovie("psd/wall.jpg");
leftback.pic.picc.loadMovie("psd/wall.png");
rightback.pic.picc.loadMovie("psd/wall.png");
praseXML();
}
};
//函数设置
downit.onPress = function() {
getURL(_global.down, "_blank");
};
function praseXML() {
var L_xml = myXML.firstChild.childNodes[0].childNodes;
var R_xml = myXML.firstChild.childNodes[1].childNodes;
for (var i = 0; i<L_xml.length; i++) {
var Obj_L = L_xml[i].attributes;
L_Array.push({linkURL:Obj_L.linkURL, imgURL:Obj_L.imgURL, imgText:Obj_L.imgText});
}
for (var i = 0; i<R_xml.length; i++) {
var Obj_R = R_xml[i].attributes;
R_Array.push({linkURL:Obj_R.linkURL, imgURL:Obj_R.imgURL, imgText:Obj_R.imgText});
}
x_revision = 10;
y_revision = 25;
ratio = 0.3;
drawLeft();
drawSmall()
}
function drawLeft() {
for (var i = 0; i<L_Array.length; i++) {
var PLoader_L = leftBar.createEmptyMovieClip("picLoader"+i, i);
var PCounter_L = leftBar.createEmptyMovieClip("picCounter"+i, i+200);
PCounter_L.id = i;
PLoader_L.loadMovie(L_Array[i].imgURL);
PCounter_L.onEnterFrame = function() {
var L_Name = leftBar["picLoader"+this.id];
if (L_Name._width>0) {
var L_Scale = Math.min(smallPicWidth/L_Name._width, smallPicHeight/L_Name._height);
L_Name._width = L_Scale*L_Name._width;
L_Name._height = L_Scale*L_Name._height;
L_Name.onPress = function() {
var tempNum = this._name.slice(9);
_global.down = L_Array[tempNum].imgURL;
textArea.contentText.text = "壁纸名称:"+L_Array[tempNum].imgText+" 壁纸大小:"+_global.siz;
Big_L(tempNum);
idArray.push(tempNum);
};
delete this.onEnterFrame;
}
};
}
counter = 0;
for (h_counter=1; h_counter<=Math.ceil(L_Array.length/3); h_counter++) {
for (v_counter=1; v_counter<=3; v_counter++) {
leftBar["picLoader"+counter]._x = leftBar["picLoader"+counter].origin_x=(12*v_counter)+(smallPicWidth*v_counter)-x_revision;
leftBar["picLoader"+counter]._y = leftBar["picLoader"+counter].origin_y=(2*h_counter)+(smallPicWidth*h_counter)+y_revision;
xyArray.push({old_x:leftBar["picLoader"+counter].origin_x, old_y:leftBar["picLoader"+counter].origin_y});
counter++;
if (counter>L_Array.length) {
break;
}
}
}
}
function Big_L(a) {
rightBar.old_x =r_xyArray[r_idArray[r_idArray.length-1]].old_x;
//trace(rightBar.old_x)
rightBar.old_y =r_xyArray[r_idArray[r_idArray.length-1]].old_y;
T_name=rightBar["R_Loader"+r_idArray[r_idArray.length-1]];
_root.timelineTween = new mx.transitions.Tween(T_name, "_x", elasticEaseOut, T_name._x, rightBar.old_x, 2, true);
_root.timelineTween = new mx.transitions.Tween(T_name, "_y", elasticEaseOut, T_name._y, rightBar.old_y, 2, true);
_root.timelineTween = new mx.transitions.Tween(T_name, "_width", elasticEaseOut, T_name._width, smallPicWidth, 2, true);
_root.timelineTween = new mx.transitions.Tween(T_name, "_height", elasticEaseOut, T_name._height, smallPicHeight, 2, true);
b = idArray[idArray.length-1];
newName = leftBar["picLoader"+a];
oldName = leftBar["picLoader"+b];
old_x = xyArray[b].old_x;
old_y = xyArray[b].old_y;
newName.imageShow();
_root.timelineTween = new mx.transitions.Tween(newName, "_y", elasticEaseOut, newName._y, L_y, 2, true);
oldName.imageOff();
}
function Big_R(a) {
leftBar.old_x =xyArray[idArray[idArray.length-1]].old_x;
leftBar.old_y =xyArray[idArray[idArray.length-1]].old_y;
T_name=leftBar["picLoader"+idArray[idArray.length-1]];
_root.timelineTween = new mx.transitions.Tween(T_name, "_x", elasticEaseOut, T_name._x, leftBar.old_x, 2, true);
_root.timelineTween = new mx.transitions.Tween(T_name, "_y", elasticEaseOut, T_name._y, leftBar.old_y, 2, true);
_root.timelineTween = new mx.transitions.Tween(T_name, "_width", elasticEaseOut, T_name._width, smallPicWidth, 2, true);
_root.timelineTween = new mx.transitions.Tween(T_name, "_height", elasticEaseOut, T_name._height, smallPicHeight, 2, true);
b = r_idArray[r_idArray.length-1];
newName = rightBar["R_Loader"+a];
oldName = rightBar["R_Loader"+b];
old_x = r_xyArray[b].old_x;
old_y = r_xyArray[b].old_y;
newName.imageShow();
_root.timelineTween = new mx.transitions.Tween(newName, "_y", elasticEaseOut, newName._y, R_y, 2, true);
oldName.imageOff();
}
//开始执行函数
myXML.load("xml/paper.xml");
MovieClip.prototype.imageShow = function() {
_root.timelineTween = new mx.transitions.Tween(textArea, "_y", elasticEaseOut, textArea._y, 30, 2, true);
_root.timelineTween = new mx.transitions.Tween(downit, "_y", elasticEaseOut, downit._y, 445.2, 2, true);
_root.timelineTween = new mx.transitions.Tween(this, "_x", elasticEaseOut, this._x, L_x, 2, true);
//_root.timelineTween = new mx.transitions.Tween(this, "_y", elasticEaseOut, this._y, L_y, 2, true);
_root.timelineTween = new mx.transitions.Tween(this, "_width", elasticEaseOut, this._width, bigPicWidth, 2, true);
_root.timelineTween = new mx.transitions.Tween(this, "_height", elasticEaseOut, this._height, bigPicHeight, 2, true);
};
MovieClip.prototype.imageOff = function() {
_root.timelineTween = new mx.transitions.Tween(this, "_x", elasticEaseOut, this._x, old_x, 2, true);
_root.timelineTween = new mx.transitions.Tween(this, "_y", elasticEaseOut, this._y, old_y, 2, true);
_root.timelineTween = new mx.transitions.Tween(this, "_width", elasticEaseOut, this._width, smallPicWidth, 2, true);
_root.timelineTween = new mx.transitions.Tween(this, "_height", elasticEaseOut, this._height, smallPicHeight, 2, true);
};
//=================================================================
function drawSmall() {
for (var i = 0; i<R_Array.length; i++) {
var PLoader_R = rightBar.createEmptyMovieClip("R_Loader"+i, i+200);
var PCounter_R = rightBar.createEmptyMovieClip("picCounter"+i, i+300+this.getNextHighestDepth());
PCounter_R.id = i;
PLoader_R.loadMovie(R_Array[i].imgURL);
PCounter_R.onEnterFrame = function() {
var R_Name = rightBar["R_Loader"+this.id];
if (R_Name._width>0) {
var R_Scale = Math.min(smallPicWidth/R_Name._width, smallPicHeight/R_Name._height);
R_Name._width = R_Scale*R_Name._width;
R_Name._height = R_Scale*R_Name._height;
R_Name.onPress = function() {
var tempNum = this._name.slice(8);
_global.down = R_Array[tempNum].imgURL;
textArea.contentText.text = "壁纸名称:"+R_Array[tempNum].imgText+" 壁纸大小:"+_global.siz;
Big_R(tempNum);
r_idArray.push(tempNum);
};
delete this.onEnterFrame;
}
};
}
counter = 0;
for (h_counter=1; h_counter<=Math.ceil(R_Array.length/3); h_counter++) {
for (v_counter=1; v_counter<=3; v_counter++) {
rightBar["R_Loader"+counter]._x = rightBar["R_Loader"+counter].origin_x=(12*v_counter)+(smallPicWidth*v_counter)-x_revision;
rightBar["R_Loader"+counter]._y = rightBar["R_Loader"+counter].origin_y=(2*h_counter)+(smallPicWidth*h_counter)+y_revision;
r_xyArray.push({old_x:rightBar["R_Loader"+counter].origin_x, old_y:rightBar["R_Loader"+counter].origin_y});
counter++;
if (counter>R_Array.length) {
break;
}
}
}
}paper.xml:
复制内容到剪贴板
代码:
<?xml version='1.0' encoding='UTF-8'?><data albumText='壁纸' siz='1024X768' scrollSpeed='1'><paper1 sub='1' sub_t='魔幻环保篇'><paper linkURL='pic\wall\small\101.jpg' imgURL='pic\wall\101.jpg' imgText='六月'/><paper linkURL='pic\wall\small\102.jpg' imgURL='pic\wall\102.jpg' imgText='七月'/><paper linkURL='pic\wall\small\103.jpg' imgURL='pic\wall\103.jpg' imgText='八月'/><paper linkURL='pic\wall\small\104.jpg' imgURL='pic\wall\104.jpg' imgText='九月'/><paper linkURL='pic\wall\small\105.jpg' imgURL='pic\wall\105.jpg' imgText='十月'/></paper1><paper2 sub='2' sub_t='武侠2008篇'><paper linkURL='pic\wall\small\201.jpg' imgURL='pic\wall\201.jpg' imgText='十一月'/><paper linkURL='pic\wall\small\202.jpg' imgURL='pic\wall\202.jpg' imgText='十二月'/><paper linkURL='pic\wall\small\203.jpg' imgURL='pic\wall\203.jpg' imgText='一月'/><paper linkURL='pic\wall\small\204.jpg' imgURL='pic\wall\204.jpg' imgText='二月'/><paper linkURL='pic\wall\small\205.jpg' imgURL='pic\wall\205.jpg' imgText='三月'/></paper2></data>自己去分析吧,呵呵呵
[
本帖最后由 dao28 于 2007-8-5 20:22 编辑 ]