We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Need a script

Shareece
Shareece asked
on
Medium Priority
210 Views
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,
Sherry
Comment
Watch Question

Commented:
oops - sorry, myjavaserver seems to be offline... wierd!

here:

http://www.ukpegasus.co.uk/ellandrd/soundByEllandrd.html
http://www.ukpegasus.co.uk/ellandrd/ellandrd.zip

Ellandrd

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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?

Thanks!

Author

Commented:
I am using the flashMX, could it be the reason?

Commented:
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:

gotoAndPlay(1);

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:

on(release)
{
      gotoAndPlay(2);
      _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:

on(release)
{
      gotoAndPlay(1);
      _root.soundON._visible = true;
      _root.soundOFF._visible = false;
}

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

stop();

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

stop();

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! ;-)

ellandrd

Author

Commented:
Hi, I successed it :-)

My best Thanks,
Sherry

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

im glad you got it working ;-)

Sean

Author

Commented:
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

 
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.