![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|||||
|
Регистрация: Aug 2005
Сообщений: 9
|
Есть 3 массива:
1. ar - содержит набор кнопок- мувиков butt_0, butt_1 2. art – содержит надписи "txt_0", "txt_1" и т.д. (расположены на соответсвующей кнопке-мувике с соответствующим числовым индексом, т.е. "txt_0" на "butt_0", "txt_1" на "butt_1" и т.д.) 3. contacts – мувики (с установленной первоначально нулевой видимостью) "cont_0", "cont_1", расположены слева от соответствующей кнопки-мувика “butt_” При щелчке по кнопке-мувику "butt_" происходит установка свойства мувика “cont_“ с соответствующим числовым индексом _visible = 1, т.е. он становится видимым, а вот тот мувик cont_, что был видим до этого, становится невидимым. Как упростить код так, чтобы не нужно было прописывать каждый конкретный мувик-кнопку "butt_" и соответствующий ему мувик cont_, видимость которого нужно перевести в 1 и в 0 соответственно? Т.е. вот эту часть
if(this._name.substr(5) == 0) {
getURL(currWay + this.link, "_blank");
setProperty("cont_0",_visible,1);
for (i=1; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 1) {
getURL(currWay + this.link, "_blank");
setProperty("cont_0",_visible,0);
setProperty("cont_1",_visible,1);
for (i=2; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 2) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-16; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_2",_visible,1);
for (i=3; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 3) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-15; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_3",_visible,1);
for (i=4; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 4) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-14; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_4",_visible,1);
for (i=5; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
и т.д.
var ar:Array = new Array("butt_0","butt_1","butt_2","butt_3","butt_4","butt_5","butt_6","butt_7","butt_8","butt_9","butt_10","butt_11","butt_12","butt_13","butt_14","butt_15","butt_16","butt_17");
for (i=0; i<=ar.length; i++) {
_root["butt_"+i].onRelease = function(){
_root[_root.lastActivatedButton].gotoAndStop(1);
_root.lastActivatedButton = this._name;
this.gotoAndStop(2);
}
}
var art:Array = new Array("txt_0","txt_1","txt_2","txt_3","txt_4","txt_5","txt_6","txt_7","txt_8","txt_9","txt_10","txt_11","txt_12","txt_13","txt_14","txt_15","txt_16","txt_17");
var contacts:Array = new Array("cont_0","cont_1","cont_2","cont_3","cont_4","cont_5","cont_6","cont_7","cont_8","cont_9","cont_10","cont_11","cont_12","cont_13","cont_14","cont_15","cont_16","cont_17");
for (i=0; i<contacts.length; i++) {
setProperty(["cont_"+i],_visible,0);
}
function Over() {
this.t.background = true;
this.t.backgroundColor = 0xFFCC00;
}
function Out() {
this.t.background = false;
}
for (j=0; j<=art.length; j++) {
_root["butt_"+j].t= _root["txt_"+j];
_root["butt_"+j].onRollOver = Over;
_root["butt_"+j].onRollOut = Out;
_root["butt_"+j].onDragOut = Out;
}
// Создаем Массив "linx", содержащий URL открываемого файла
currWay = "../../../../";
var linx:Array = new Array(18);
linx[0] = "pod/21/pod21-05.swf";
linx[1] = "pod/7/pod7-06.swf";
linx[2] = "pod/7/pod7-06.swf";
linx[3] = "pod/7/pod7-06.swf";
linx[4] = "pod/7/pod7-06.swf";
linx[5] = "pod/7/pod7-06.swf";
linx[6] = "pod/7/pod7-07.swf";
linx[7] = "pod/7/pod7-07.swf";
linx[8] = "pod/7/pod7-07.swf";
linx[9] = "pod/21/pod21-05.swf";
linx[10] = "pod/7/pod7-06.swf";
linx[11] = "pod/7/pod7-06.swf";
linx[12] = "pod/7/pod7-06.swf";
linx[13] = "pod/7/pod7-06.swf";
linx[14] = "pod/7/pod7-06.swf";
linx[15] = "pod/7/pod7-07.swf";
linx[16] = "pod/7/pod7-07.swf";
linx[17] = "pod/7/pod7-07.swf";
for (i=0; i<linx.length; i++) {
_root["butt_"+i].link = linx[i];
_root["butt_"+i].onPress = function() {
// Упростить необходимо в этой части
if(this._name.substr(5) == 0) {
getURL(currWay + this.link, "_blank");
setProperty("cont_0",_visible,1);
for (i=1; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 1) {
getURL(currWay + this.link, "_blank");
setProperty("cont_0",_visible,0);
setProperty("cont_1",_visible,1);
for (i=2; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 2) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-16; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_2",_visible,1);
for (i=3; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 3) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-15; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_3",_visible,1);
for (i=4; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 4) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-14; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_4",_visible,1);
for (i=5; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 5) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-13; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_5",_visible,1);
for (i=6; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 6) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-12; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_6",_visible,1);
for (i=7; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 7) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-11; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_7",_visible,1);
for (i=8; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 8) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-10; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_8",_visible,1);
for (i=9; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 9) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-9; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_9",_visible,1);
for (i=10; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 10) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-8; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_10",_visible,1);
for (i=11; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 11) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-7; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_11",_visible,1);
for (i=12; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 12) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-6; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_12",_visible,1);
for (i=13; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 13) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-5; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_13",_visible,1);
for (i=14; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 14) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-4; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_14",_visible,1);
for (i=15; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 15) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-3; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_15",_visible,1);
for (i=16; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 16) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-2; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_16",_visible,1);
for (i=17; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
else if(this._name.substr(5) == 17) {
getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length-1; i++) {setProperty(["cont_"+i],_visible,0);}
setProperty("cont_17",_visible,1);
}
else
{getURL(currWay + this.link, "_blank");
for (i=0; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);}
}
}
}
|
|
|||||
|
Сделайте ещё один цикл, который бы выставлял что то вроде таково:
[AS2]for (var j:Number=0; j<10; j++){ if(this._name.substr(5) == j) { getURL(currWay + this.link, "_blank"); for (i=0; i<contacts.length-16; i++) {setProperty(["cont_"+i],_visible,0);} setProperty("cont_2",_visible,1); for (i=3; i<contacts.length; i++) {setProperty(["cont_"+i],_visible,0);} }[/AS2] Разбираться в коде лень, но смысл тот.
__________________
Тут мужик танцует и поёт про флэш |
![]() |
![]() |
Часовой пояс GMT +4, время: 18:28. |
|
|
« Предыдущая тема | Следующая тема » |
|
|