Reputation: 43
A question about actionscript 2. I have two arrays - one for buttons, and the other one for movie clips that are triggered by the buttons:
var def:Array = [mc1, mc2, mc3];
var defBtn:Array = [btn1, btn2, btn3];
So I got the movie clips triggered by the respective buttons - any called movie clip is visible and plays its timeline.
for(i=0; i<def.length; i++) {
defBtn[i].iv = i;
def[i].iv = i;
defBtn[i].onRelease = function() {
for( i=0; i<defBtn.length; i++ ) {
def[this.iv]._visible = true;
def[this.iv].play();
}
};
};
However any called movie clip stays visible all the time. I want all movie clips from the array to be invisible except the one called by respective button.
Have no idea how to do this because I NEED to use onRelease (not onRollOut) to make the movie clips dissappear after they animate for a little bit.
I would appreciate help with this AS code please! Thanks
Upvotes: 1
Views: 293
Reputation: 2554
It's been many years since I've had to write AS2 code, but I'll give it a try...
On each button, set the following code, changing the index value to be respective to the button's index in the array:
on(release){
showClip(0); // change value here as needed
}
On the same timeline the buttons and movieclips exist, you'll need this code:
var def:Array = [mc1, mc2, mc3];
var defBtn:Array = [btn1, btn2, btn3];
function showClip(clipToShow:Number) {
// hide all clips
for( i = 0; i < def.length; i++ ) {
def[i]._visible = false;
def[i].stop();
}
// only show clip after all clips have been hidden
def[clipToShow]._visible = false;
def[clipToShow].stop();
};
Unfortunately, I don't have a way to compile AS2 code on my machine because I have Adobe CC 2015, which no longer supports AS2; otherwise, I would have tested this code for you. Hope this works for you though. Let me know otherwise.
Upvotes: 2