Link to home
Start Free TrialLog in
Avatar of steva
steva

asked on

Activating a toggle button from ActionScript

I have a movie clip that consists of two frames, one frame containing an ON button and the other containing an OFF button.  The ActionScript for each frame is stop() and the ActionScript for each button instance is

      on(release) {
                play();
       }

So when you click the movie instance on the main stage, you advance to the next frame (second if coming from first, first if coming from second) and the icon changes between an ON graphic and and OFF graphic, implementing a toggle botton.  My problem is that I would like to toggle the button internally from ActionScript to an initial state depending on the value of some variable.  The movie clip instance is called tog so I tried adding

                           tog.play();

to the frame 1 code for the main timeline, but this doesn't do it. The state stays at the state for frame 1 of the tog movie clip.

Does anyone know what's going on here and how I can toggle this switch from ActionScript?

Thanks,

Steve
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

if u  r writing the following code on frame 1,

              tog.play();

then you should have the movieclip instance "tog" on first frame,

if it is not the case,
put the above code on frame, where "tog" instance is placed..

Regards
Aneesh
Avatar of steva
steva

ASKER

That's what I have.  The .fla  file is here, if someone wants to take a look at it:      http://www.4shared.com/file/4974645/d5614c82/tog.html

The movie clip is called Spkr and the instance on the main page is tog.


Steve
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of steva

ASKER

That works!  Why does that work and not tog.play()?
tog,play() says just to start play from the currentframe, but frame one also has stop action, which does not allow it to move forward..