Solved

Need a script

Posted on 2006-11-04
8
178 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
0
Comment
Question by:Shareece
  • 4
  • 4
8 Comments
 
LVL 16

Expert Comment

by:ellandrd
ID: 17874385
0
 
LVL 16

Accepted Solution

by:
ellandrd earned 500 total points
ID: 17874390
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
0
 

Author Comment

by:Shareece
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?

Thanks!
0
 

Author Comment

by:Shareece
ID: 17874828
I am using the flashMX, could it be the reason?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 16

Expert Comment

by:ellandrd
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:

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
0
 

Author Comment

by:Shareece
ID: 17876422
Hi, I successed it :-)

My best Thanks,
Sherry
0
 
LVL 16

Expert Comment

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

im glad you got it working ;-)

Sean
0
 

Author Comment

by:Shareece
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

 
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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,…
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.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now