Light switch

Hi guys,
I’m new here and very happy to be!

I’m a beginner in Flash, nevertheless my company gave me this widget to create.
It is basically done and I’m kind of happy with it but

Click once on the button - click a second time - everything works fine until now.
Now click a third time. The lighting doesn’t go back to its original status, as wanted.
Fortunately if you click a forth time, you get what you wanted to get with the third click.

I give you an insight on the ActionScript. I coded:
[FONT=Courier New]
[FONT=Verdana][COLOR=Red]1)[/COLOR][/FONT]

on(release) {
gotoAndPlay(“10”);
}[FONT=Verdana]

for the button (not the frame) frame 1. 10 is the frame when the turn-light-down animation starts.

[/FONT][/FONT][FONT=Courier New][FONT=Verdana][COLOR=Red]2)[/COLOR][/FONT]

on(release) {
gotoAndPlay(“30”);
}[FONT=Verdana]

for the button (not the frame) in frame 30. 30 is the frame when the turn-light-up animation starts.

[/FONT][/FONT][FONT=Courier New][FONT=Verdana][COLOR=Red]3)[/COLOR][/FONT]

on(release) {
gotoAndPlay(“10”);
}[FONT=Verdana]

for the button (not the frame) in frame 50. 50 is the frame when the turn-light-up animation ends.
This third piece is intended to let the button trace the point - back in time - in which the light goes down. I wanted to create a button-activated loop with no interruptions.
So why does it take a forth click to have the light down again?

Thank you for your help,
Ray
[/FONT][/FONT]

Don’t know if I got it right, but you could create a tween with just three keyframe:

Kf 1= button that makes the animation goes dark. The tween starts and reach frame let’s say 10

Kf 10=button that makes the animation goes bright till it reach frame let’s say 19. In this final frame write the script: gotoAndStop (1)…

With my little knowledge of Actionscript, I would do like this…

Your timeline flow is wrong…

Frame 1 - lights are on - contains button to dim lights

Frame 10 - lights begin to dim - contains button to turn lights up

Frame 30 - lights are dim - contains button to turn lights up

Frame 50 - lights are on - contains button to dim lights. Try gotoAndPlay(11);

Better still use frame labels, e.g. lights_on and lights_off, instead of frame numbers and you should be able to understand/control where the playhead goes much more easily.