I'm trying to aks you guys something i'm not sure fi u will understand me.
I have a map with 60 states, every state is a mc with 3 frames one for up and
the other for down state the 3'rd frame is a action
gotoAndStop(1); action. and a button inside that has the next script:
code:
on (release) {
with(this)
nextFrame();
}
on (release) {
with (this._parent.mc_1) {
gotoAndStop(1);}
with (this._parent.mc_2) {
gotoAndStop(1);}
.
.
.
with (this._parent.mc_60) {
gotoAndStop(1);}
}
this script alows only one state to be selected
and i have to put this script for every button
I could use this script
code:
on (release) {
var mcList=["mc_1",...."mc_60"];
for(var mc in mcList){
this._parent[mcList[mc]].gotoAndStop(1);
}
}
but then all the mc will go to frame 1 including the one is pressed.
I dont have any idea who to make the mcs go to frame one and the mc is pressed to go at frame 2.
If someone have any idea, i will be very happy.
Option A: (not a good option as for performance wise, for loop is not a good option);
code:
on (release) {
var mcList=["mc_1",...."mc_60"];
for(var mc in mcList){
this._parent[mcList[mc]].gotoAndStop(1);
}
this._parent.gotoAndPlay(2);
// the first lot tells all mc to reset.
// added red line tells teh caller mc to play.
}
In fact, you you have naming convention like the one you didi in an array "mc_1....60". You don;t need array to hold mc name at all.
on (release) {
for(i=1;i<=60;i++){
this._parent["mc_"+i].gotoAndStop(1);
}
this._parent.gotoAndPlay(2);
// the first lot tells all mc to reset.
// added red line tells teh caller mc to play.
}
[/AS]
Option B: (having one variable to hold clicked item name. and reset it when other mc is clicked)
code:
on (release) {
// if not the first click, reset previous clicked MC
if (_root.clickedMC!=""){
_parent[_root.clickedMC].gotoAndStop(1);
}
// play clicked mc
this.gotoAndPlay(2);
// update clickedMC variable
_root.clickedMC=this._name;
}