Actionscript 2 Play Pause sound from media controller

I'm trying to get my media controller to play and pause but everytime I click the button it play another instance of the sound. Please help complete noob!

My code is as follows:

on (click) {
      kirupaSound = new Sound(this);
      kirupaSound.attachSound("sample.mp3");
      kirupaSound.start(0, 99);
      kirupaSound.test();
Lico_wAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
blue-genieConnect With a Mentor Commented:
sorry i'm multi-tasking too much

on (release)
{
      _root.kirupaSound.start();
}
0
 
blue-genieCommented:
that's because you are creating new Sound each time.

declare your sound on the timeline

var kirupaSound:Sound = new Sound();
attach code
start .. blah

what's kirupaSound.test() ??????

then in your onClick()

call kirupaSound.stop() // start();
0
 
Lico_wAuthor Commented:
Okay so ive got the following in my timeline:

var kirupaSound:Sound = new Sound();
kirupaSound.attachSound("sample.mp3");

and this in my mediacontroller:

on (click) {
      kirupaSound.start(0, 99);}

Do I not need to put the timeline stuff in a function? If so how do I do it? I tried the above as is and it did nothing.
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
blue-genieCommented:
can you upload your file?
0
 
Lico_wAuthor Commented:
File attached as requested.
SoundPlayer1.fla
0
 
blue-genieCommented:
ok when they click the component it starts playing, but when it clicks the pause button in the component its supposed to pause and then close again. is that correct?
i'm not familiar with this component but you're going to need a bit more work than that.
you're going to have to check if the sound is currently playing, if it is, then don't trigger the start action again because the click on component is overriding the click of the pause button inside the component.

is there documentation for this component?
0
 
Lico_wAuthor Commented:
No, when I try to run it as a flash movie it does nothing! The sound doesn't play when I click play or pause.

I know that I will need an If statement etc. to check if sound is playing or not and act accordingly to pause or play further down the line but it won't play in the first place, thats my problem....

Does the sound play when you export the movie from flash then???
0
 
blue-genieCommented:
okay just change the thing to on (release) instead of click
then do your if statements.

0
 
Lico_wAuthor Commented:
No good I'm afraid still does nothing. If it's easier I can change to Actionscript 3 would there be a solution in that?
0
 
Lico_wAuthor Commented:
Thanks a lot I've now got it working ;-D

Only issue is the controller shows as paused when its playing and as streaming when it's paused. Is there an easy fix for this? My code is below:

Timeline Code:-
var isPlaying:String = "notPlaying";
var kirupaSound:Sound = new Sound();
kirupaSound.attachSound("sample.mp3");

Controller Code:
on (click)
{
      if (isPlaying <> null)
      {
            _root.kirupaSound.start(0, 99);      
            isPlaying = null;
            
      }
      else
      {
            _root.kirupaSound.stop();
            isPlaying = "notPlaying";
      }
}

Also any pointers on how to configure the volume button much appreciated.
0
 
blue-genieCommented:
as i said i need the documentation on that component, i don't know it and there doesn't seem to be any parameters to it.
0
 
Lico_wAuthor Commented:
Okay is there a simple way of doing this with the standard buttons i.e. I can have a play and stop button, but how do I make the play button change to pause once clicked - I guess I would need to navigate to a new keyframe with the pause button in, but how is that done?
0
 
blue-genieCommented:
make your buttons into movieclips NOT buttons.

create a variable such as

var isPlaying:Boolean = false;
once that hit start, set the variable to true.

if (isPlaying) {
movieclip.gotoFrameThatIsPause;
} else{
moveclip.goSomwhereElse;
}
0
 
Lico_wAuthor Commented:
that sounds a bit tricky for a complete noob like me!!!

Anyway I re-looked at my component and docs on Adobe.com and have resolved the issues, thanks for your help with this one!!!

;-)
0
 
Lico_wAuthor Commented:
Only partial completion, I still need more info on the media controller component, so any additional help would be appreciated.
0
 
blue-genieCommented:
as I said I'm not familiar with that particular component, and then you decided that you werent' going to use it anymore.
0
 
Lico_wAuthor Commented:
my comment wasn't meant to offend you!

I put it in the hope someone who DID know about that particular component would see it and pick it up....

I did look at changing the component but as I stated right at the start I am a noob to this and I didn't really understand what I needed to do with the alternative, it was to brief.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.