wfz
11-18-2008, 04:01 AM
I'm trying to use loop to simplify the button script below:
topic0.onRollOver = function() {
tHint.text = TopicHintList[0];
tHint._x = topic0._x;
tHint._y = 15;
topic0.gotoAndStop(2);
};
topic0.onRollOut = function() {
tHint._x = -100;
tHint._y = -1000;
topic0.gotoAndStop(1);
};
topic0.onPress = function() {
topic0.gotoAndStop(3);
};
topic0.onRelease = function() {
gotoAndPlay(TopicBeginFrameList[0]);
};
topic1.onRollOver = function() {
tHint.text = TopicHintList[1];
tHint._x = topic1._x;
tHint._y = 15;
topic1.gotoAndStop(2);
};
topic1.onRollOut = function() {
tHint._x = -100;
tHint._y = -1000;
topic1.gotoAndStop(1);
};
topic1.onPress = function() {
topic1.gotoAndStop(3);
};
topic1.onRelease = function() {
gotoAndPlay(TopicBeginFrameList[1]);
};
...
The main changes are the topic0, etc change from 0 to 1 to 2, etc.
I created one based on what I read here but it didn't work. Can you tell me what's wrong with the script below?
for (var i = 0; i<TopicBeginFrameList.length; i++) {
this["topic"+i].onRollOver = function() {
tHint.text = TopicHintList[this(i)];
tHint._x = this["topic"+i]._x;
tHint._y = 15;
this["topic"+i].gotoAndStop(2);
};
this["topic"+i].onRollOut = function() {
tHint._x = -100;
tHint._y = -1000;
this["topic"+i].gotoAndStop(1);
};
this["topic"+i].onPress = function() {
this["topic"+i].gotoAndStop(3);
};
this["topic"+i].onPress = function() {
this["topic"+i].gotoAndStop(3);
};
this["topic"+i].onRelease = function() {
gotoAndPlay(TopicBeginFrameList[this(i)]);
};
}
I really don't know how to describe (TopicBeginFrameList[0]) with loop. something like this "TopicHintList[this(i)];" ???
Thanks for the help.
topic0.onRollOver = function() {
tHint.text = TopicHintList[0];
tHint._x = topic0._x;
tHint._y = 15;
topic0.gotoAndStop(2);
};
topic0.onRollOut = function() {
tHint._x = -100;
tHint._y = -1000;
topic0.gotoAndStop(1);
};
topic0.onPress = function() {
topic0.gotoAndStop(3);
};
topic0.onRelease = function() {
gotoAndPlay(TopicBeginFrameList[0]);
};
topic1.onRollOver = function() {
tHint.text = TopicHintList[1];
tHint._x = topic1._x;
tHint._y = 15;
topic1.gotoAndStop(2);
};
topic1.onRollOut = function() {
tHint._x = -100;
tHint._y = -1000;
topic1.gotoAndStop(1);
};
topic1.onPress = function() {
topic1.gotoAndStop(3);
};
topic1.onRelease = function() {
gotoAndPlay(TopicBeginFrameList[1]);
};
...
The main changes are the topic0, etc change from 0 to 1 to 2, etc.
I created one based on what I read here but it didn't work. Can you tell me what's wrong with the script below?
for (var i = 0; i<TopicBeginFrameList.length; i++) {
this["topic"+i].onRollOver = function() {
tHint.text = TopicHintList[this(i)];
tHint._x = this["topic"+i]._x;
tHint._y = 15;
this["topic"+i].gotoAndStop(2);
};
this["topic"+i].onRollOut = function() {
tHint._x = -100;
tHint._y = -1000;
this["topic"+i].gotoAndStop(1);
};
this["topic"+i].onPress = function() {
this["topic"+i].gotoAndStop(3);
};
this["topic"+i].onPress = function() {
this["topic"+i].gotoAndStop(3);
};
this["topic"+i].onRelease = function() {
gotoAndPlay(TopicBeginFrameList[this(i)]);
};
}
I really don't know how to describe (TopicBeginFrameList[0]) with loop. something like this "TopicHintList[this(i)];" ???
Thanks for the help.