Solved

Need a script

Posted on 2006-11-04
8
183 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:Shareece
ID: 17874828
I am using the flashMX, could it be the reason?
0
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reduce the size of the Flash SWF file it executes 12 419
Open Source MP4 Flash Player 2 189
How to convert image files to a movie file 6 111
Actionscript in Flash 3 70
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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…

840 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