Need a script

Posted on 2006-11-04
Medium Priority
Last Modified: 2010-04-03
Hello, I have two buttons: soundOFF and soundON.

What I need to do is that The movie should stay on the first frame where the button soundOFF is and a background sound is been played.

Once the user clicks on this button, the sound should stop and soundON  button should appear. And once the soundON is been clicked, the sound should start again and the button soundOFF should appear.  I think I should place this two buttons in different frames and use goto frame script somehow. Just last time I had to use flash, it was the version 3 and there werer no ASs ...

Would be greatful for any help,
Question by:Shareece
  • 4
  • 4
LVL 16

Accepted Solution

ellandrd earned 2000 total points
ID: 17874390
oops - sorry, myjavaserver seems to be offline... wierd!




Author Comment

ID: 17874791
Hello and thanks for the files, that's exactly what I need! Just I can't open the .fla file, get a runtime error message and flash ends immediately :(
I try and try, but don't success it. Would you please kindly write me the script?

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 17874828
I am using the flashMX, could it be the reason?
LVL 16

Expert Comment

ID: 17875860
could be - im on flash 8.

maybe if you can follow my step by step guide - you can recreate my example??

1) create new flash document.
2) insert your sound in the library.
3) create new symbol MC ( MC = MovieClip) and name it "sounds".
4) open this MC up by double clicking on it from the library.
5) create 2 layers - 1 for the sound file and 1 for some actionscript.
6) on the first layer, drag your sound file on the stage.  extend this to say, keyframe 6.  in second layer on keyframe 6 press F6 to create blank keyframe.
7) while this blank keyframe is highlighted, open the "actions - frame" panel and add this actionscript code:


Note:  this will make the sound file loop continuously...

8) go back to main scene and create 3 layers: 1 for "sounds" movieclip, 1 for actionscript and 1 for buttons.
9) in the sounds layer, highlight/select keyframe 2 and drag your "sounds" movieclip from the library onto the stage
10) select the rectangle tool and create a button of your size.  select the text tool and give is a label like Sound Off.  Highlight both the text lablel and rectangle object and right-click and convert to symbol, selecting button and naming it "soundOFF".  
11) on the buttons layer, on keyframe 1, drag your button "soundOFF" onto the stage.
12) click on the button object on the stage and open the "actions - frame" again t add some actionscript code:

      _root.soundOFF._visible = true;
      _root.soundON._visible = false;

13) select the rectangle tool again and create another button giving it another label - called Sound On.  Again, like before, highlight both the label and rectangle and right-click and select convert to symbol, selecting button and nameing it "soundON"
14) on the buttons layer again, select keyframe 2 and drag your soundON button onto the stage covering soundOFF button.  e.g they overlap = 1 is hidden by the other
15) highlight "soundON" button and open "actions - frame" and add this actionscript code:

      _root.soundON._visible = true;
      _root.soundOFF._visible = false;

16) in the actionscripts layer - (3rd layer), in keyframe 1, add this code:


17) in the same layer again, select keyframe 2,and add this code again:


thats it!  test your movie.  you should get the "Sound On" button displaying first and when you click on it, it should run the "sounds" MC that plays your sound file over and over again.  notice when you click Sound On, the button is hidden and Sound Off button is how visible.  click Sound Off and the sound stops playing...

if you have followed this and still cant get it working, please tell me.  i'd also try again to open the .fla i send you.

Good luck! ;-)


Author Comment

ID: 17876422
Hi, I successed it :-)

My best Thanks,
LVL 16

Expert Comment

ID: 17876696
ah great - was my step my step guide any help?  was it easy to follow?

im glad you got it working ;-)


Author Comment

ID: 17876922
Yep, really great, your guide was my only help. I am very happy!

Your instructions are marvellous, detailed and easy to understand. You see, even me sucessed to make such complicated movie.
Do you want to see it? It's on the test server: http://eport.at/cs/html/index.html - It is almost ready to go online, there is just a little problem
with the flash movie and that is the white background that apears at the beginning, although I set the background color to one of the stage colors.
This is not good:(

Thank you again very much Sean,
My regards, sherry


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

615 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