Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Activating a toggle button from ActionScript

Posted on 2006-10-25
5
Medium Priority
?
333 Views
Last Modified: 2008-03-03
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
0
Comment
Question by:steva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17807268
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
0
 

Author Comment

by:steva
ID: 17808314
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
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 17809010
ok,
you would have to write follownig code:
--------
tog.gotoAndPlay(2);
--------
0
 

Author Comment

by:steva
ID: 17809347
That works!  Why does that work and not tog.play()?
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17811002
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..
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question