0$房天下问答|FLASH代码解释一下,谢谢$https://m.fang.com/ask/ask_1185546.html$https://static.soufunimg.com/common_m/m_public/201511/images/asksharedefault.png
packc/pages/ask/detail/detail?askid=1185546
-
FLASH代码解释一下,谢谢
mainLink = new Array();_global.subLink = new Array();myXML = new XML();myXML.load("../images/swf/link.xml");myXML.ignoreWhite = true;myXML.onLoad = function (temp){ for (i = 1; i <= numOfMenu; i++) { mainLink[i] = this.childNodes[i - 1].attributes.value; subLink[i] = new Array(); if (this.childNodes[i - 1].hasChildNodes()) { for (k = 1; k <= 10; k++) { subLink[i][k] = this.childNodes[i - 1].childNodes[k - 1].attributes.value; } // end of for } // end if } // end of for};frame = new Array();frame[1] = "_self";frame[2] = "_self";frame[3] = "_self";frame[4] = "_self";frame[5] = "_self";frame[6] = "_self";numOfMenu = 6;defaultX = 100;max = 160;min = 95;_global.active = pageNum;_global.subActive = subNum;_global.over = active;for (i = 1; i <= numOfMenu; i++){ this[i].defaultX = this[i]._x; this[i].bg.onRollOver = function () { _global.over = this._parent._name; }; this[i].bg.onRollOut = this[i].bg.onDragOut = function () { _global.over = active; }; this[i].bg.onRelease = function () { getURL(mainLink[this._parent._name], "_self"); }; this[i].onEnterFrame = function () { if (over == this._name) { this.swapDepths(1); this.nextFrame(); } else { this.prevFrame(); } // end else if if (over) { if (this._name == over) { if (this._name == 5) { this.bg.targetX = 200; } else { this.bg.targetX = max; } // end else if } else { this.bg.targetX = min; } // end else if } else if (this._name == 5) { this.bg.targetX = 130; } else { this.bg.targetX = defaultX; } // end else if this.bg._width = this.bg._width + (this.bg.targetX - this.bg._width) / 4; if (this._name != 1) { this._x = this._parent[this._name - 1].bg._width + this._parent[this._name - 1]._x; } // end if };} // end of for------------------------------sub.useHandCursor = 0;sub.onRollOver = function (){ _global.over = this._parent._name;};sub.onRollOut = sub.onDragOut = function (){ _global.over = 0;};
更多
共1个回答
-
-
-
dragon8901
丨Lv 4
mainLink = new Array();//定义一级链接地址数组_global.subLink = new Array();//定义二级链接地址数组myXML = new XML();myXML.load("../images/swf/link.xml");//加载外部xml文件myXML.ignoreWhite = true;//在分析过程中,将放弃仅包含空白的文本节点myXML.onLoad = function (temp)//加载成功后{//以下是解析xml文件,分别存储到一级和二级链接地址的数组中for (i = 1; i <= numOfMenu; i++){mainLink[i] = this.childNodes[i - 1].attributes.value;//一级链接地址赋值给mainLink数组subLink[i] = new Array();if (this.childNodes[i - 1].hasChildNodes())//如果表示一级链接地址的节点还有子节点{for (k = 1; k <= 10; k++){subLink[i][k] = this.childNodes[i - 1].childNodes[k - 1].attributes.value;//二级链接地址赋值给subLink数组} // end of for} // end if} // end of for};frame = new Array();frame[1] = "_self";frame[2] = "_self";frame[3] = "_self";frame[4] = "_self";frame[5] = "_self";frame[6] = "_self";//_self表示链接到本页numOfMenu = 6;//一级菜单项的数量defaultX = 100;//默认x坐标max = 160;//最大值min = 95;//最小值_global.active = pageNum;//表示一级菜单中被激活的项_global.subActive = subNum;//表示二级菜单中被激活的项_global.over = active;//表示鼠标是否滑过某个菜单项,初始值为active,表示离开状态。for (i = 1; i <= numOfMenu; i++){//一级菜单项影片剪辑被以1,2,3,4,5,6来命名,this[1]表示当前时间轴上实例名为1的影片剪辑,其他同理。this[i].defaultX = this[i]._x;this[i].bg.onRollOver = function (){_global.over = this._parent._name;};//鼠标滑过i的bg,over变量赋值为bg的父影片剪辑的名字,即i.this[i].bg.onRollOut = this[i].bg.onDragOut = function (){_global.over = active;};//鼠标离开i的bg,over变量赋值为active的值,即表示离开.this[i].bg.onRelease = function (){getURL(mainLink[this._parent._name], "_self");};//鼠标单击某个一级菜单项,则在本页面链接到相应的地址this[i].onEnterFrame = function (){//每经过一帧,每个一级菜单项影片剪辑都要执行下面的函数if (over == this._name)//如果over变量的值为当前影片剪辑的名字{this.swapDepths(1);//当前影片剪辑交换深度到1层级this.nextFrame();//当前影片剪辑后播一帧}else{this.prevFrame();//当前影片剪辑前播一帧,为了保证效果是平滑过渡的,而不是突然变化} // end else ifif (over)//如果over变量不为0,即鼠标滑过某个菜单项{if (this._name == over){if (this._name == 5){this.bg.targetX = 200;}else{this.bg.targetX = max;} // end else if}else{this.bg.targetX = min;} // end else if}else if (this._name == 5){this.bg.targetX = 130;}else{this.bg.targetX = defaultX;} // end else ifthis.bg._width = this.bg._width + (this.bg.targetX - this.bg._width) / 4;//这是著名的缓冲公式,产生弹性变化效果if (this._name != 1){this._x = this._parent[this._name - 1].bg._width + this._parent[this._name - 1]._x;} // end if};} // end of for------------------------------sub.useHandCursor = 0;//对于sub影片剪辑,鼠标指针禁用手形效果sub.onRollOver = function (){_global.over = this._parent._name;};//鼠标滑过sub影片剪辑,over变量记录其副影片剪辑的实例名sub.onRollOut = sub.onDragOut = function (){_global.over = 0;};//鼠标离开sub影片剪辑,over变量置为0
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。

关注成功