6 Replies - 2796 Views - Last Post: 12 February 2014 - 02:58 PM

#1 miper27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-February 14

Problems with music and return button

Posted 12 February 2014 - 12:25 PM

Hello,

First of all, I apologise in advance because my english isnīt excellent and I am not developer, so my knowledge in AS is very limited. Iīm learning!!.. :)

My problem is that I have a project with music inside in one layer, a volume controller in another layer and one button to back to the beginning in another layer. When I test the project, the animation and the music start correctly, but when I click on the button to come back to the beginning, one music starts again and the first one continues, it doesn't stop. The music is duplicated.

I have two AS, one for the button and another one for the volume controller:


Simple AS button:

on (release){
gotoAndPlay (1);
}


Slider AS:


s = new Sound(_root);
slider_1.onPress = function() {
startDrag(this, false, 0, 0, 250, 0);
};
slider_1.onRelease = slider_1.onReleaseOutside=function () {
stopDrag();
};
onEnterFrame = function () {
xpos = (slider_1._x/groove_1._width)*100;
s.setVolume(xpos);
};



Thank you very much for your help!!

Is This A Good Question/Topic? 0
  • +

Replies To: Problems with music and return button

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 334
  • View blog
  • Posts: 1,215
  • Joined: 15-January 14

Re: Problems with music and return button

Posted 12 February 2014 - 01:36 PM

Your button to rewind should probably just rewind or seek on the existing sound. If you're only going back to the first frame then it's going to run the code again to create a sound and play it. If you want to rewind the existing sound then that's exactly what the code should do - target the existing sound and rewind it. The alternative is to add code on the first frame to remove any existing sounds before creating one.
Was This Post Helpful? 0
  • +
  • -

#3 miper27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-February 14

Re: Problems with music and return button

Posted 12 February 2014 - 01:50 PM

View PostArtificialSoldier, on 12 February 2014 - 01:36 PM, said:

Your button to rewind should probably just rewind or seek on the existing sound. If you're only going back to the first frame then it's going to run the code again to create a sound and play it. If you want to rewind the existing sound then that's exactly what the code should do - target the existing sound and rewind it. The alternative is to add code on the first frame to remove any existing sounds before creating one.


Hello,

Thank you very much for your help.

Ok, I understand you, but what code I have to add?, and can I leave the rest of the code how is in the button and the slider? . I am sorry, but I don' t know too much about coding.

Regards,

Miper27.
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 334
  • View blog
  • Posts: 1,215
  • Joined: 15-January 14

Re: Problems with music and return button

Posted 12 February 2014 - 02:26 PM

If you don't change the existing code, then it's going to do the same thing. It sounds like you can just call the play method on the sound and that will start it over from the beginning. The reference for that is here:

http://help.adobe.co...und.html#play()

You can also use the SoundMixer.stopAll method to stop all sounds:

http://help.adobe.co....html#stopAll()

Other than that, there is some general information about working with sound here:

http://help.adobe.co...90204-7d27.html
http://help.adobe.co...90204-7d26.html
http://help.adobe.co...90204-7d21.html
Was This Post Helpful? 0
  • +
  • -

#5 miper27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-February 14

Re: Problems with music and return button

Posted 12 February 2014 - 02:31 PM

View PostArtificialSoldier, on 12 February 2014 - 02:26 PM, said:

If you don't change the existing code, then it's going to do the same thing. It sounds like you can just call the play method on the sound and that will start it over from the beginning. The reference for that is here:

http://help.adobe.co...und.html#play()

You can also use the SoundMixer.stopAll method to stop all sounds:

http://help.adobe.co....html#stopAll()

Other than that, there is some general information about working with sound here:

http://help.adobe.co...90204-7d27.html
http://help.adobe.co...90204-7d26.html
http://help.adobe.co...90204-7d21.html


Hi,

Thank you for your help.. Where I can find info for action script 2 about this?. Because the code I am using is AS 2, I mean the button's code and the slider's code.

Regards.
Was This Post Helpful? 0
  • +
  • -

#6 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 334
  • View blog
  • Posts: 1,215
  • Joined: 15-January 14

Re: Problems with music and return button

Posted 12 February 2014 - 02:50 PM

The reference is here:

http://help.adobe.co..._LangRef_1.html

You can find the sound object in the table of contents under Language Reference -> Actionscript Classes -> Sound.

There's an article here also:

http://help.adobe.co...1af6-7cdfa.html
Was This Post Helpful? 0
  • +
  • -

#7 miper27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-February 14

Re: Problems with music and return button

Posted 12 February 2014 - 02:58 PM

View PostArtificialSoldier, on 12 February 2014 - 02:50 PM, said:

The reference is here:

http://help.adobe.co..._LangRef_1.html

You can find the sound object in the table of contents under Language Reference -> Actionscript Classes -> Sound.

There's an article here also:

http://help.adobe.co...1af6-7cdfa.html



Thank you very much for your help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1