Hello there,
I’ve created the following code that opens and closes ‘doors’. The problem I’m having now is how to repeat this code for each set of doors there are 8 of them). I presume I could use a for loop to do this however I am confused how I achieve this.
screen_1 is the button used to open and close the doors (door_left_1 and door_right_1) using onPress and onRollout. I need this script to repeat this for each set of doors.
The only solution I’ve come up with so far is repeating the below 8 times, sure there is a more efficient way to do it!
Cheers
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];
[COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR].*;
[COLOR=#000000]var[/COLOR] xpos_left:[COLOR=#0000FF]Number[/COLOR] = door_left_[COLOR=#000080]1[/COLOR].[COLOR=#0000FF]x[/COLOR];
[COLOR=#000000]var[/COLOR] xpos_right:[COLOR=#0000FF]Number[/COLOR] = door_right[COLOR=#000080]1[/COLOR].[COLOR=#0000FF]x[/COLOR];
[COLOR=#000000]var[/COLOR] [COLOR=#0000FF]down[/COLOR]:[COLOR=#0000FF]Boolean[/COLOR] = [COLOR=#000000]false[/COLOR];
open_em = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]down[/COLOR] = [COLOR=#000000]true[/COLOR];
[COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]door_left[COLOR=#000080]1[/COLOR], [COLOR=#FF0000]"x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos_left, xpos_left-[COLOR=#000080]48[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000000]true[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]door_right[COLOR=#000080]1[/COLOR], [COLOR=#FF0000]"x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos_right, xpos_right+[COLOR=#000080]48[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000000]true[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR];
close_em = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]door_left[COLOR=#000080]1[/COLOR], [COLOR=#FF0000]"x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos_left-[COLOR=#000080]48[/COLOR], xpos_left, [COLOR=#000080]1[/COLOR].[COLOR=#000080]5[/COLOR], [COLOR=#000000]true[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]door_right[COLOR=#000080]1[/COLOR], [COLOR=#FF0000]"x"[/COLOR], Bounce.[COLOR=#000080]easeOut[/COLOR], xpos_right+[COLOR=#000080]48[/COLOR], xpos_right, [COLOR=#000080]1[/COLOR].[COLOR=#000080]5[/COLOR], [COLOR=#000000]true[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000FF]down[/COLOR] = [COLOR=#000000]false[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];
screen[COLOR=#000080]1[/COLOR].[COLOR=#0000FF]onPress[/COLOR] = [COLOR=#000000]function[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
open_em COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR];
screen_[COLOR=#000080]1[/COLOR].[COLOR=#0000FF]onRollOut[/COLOR] = [COLOR=#000000]function[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
close_em COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR];
[/LEFT]
[/FONT]