sound slider and volume tutorial?

  • GeTSm0keD
  • Beginner
  • Beginner
  • User avatar
  • Posts: 55

Post 3+ Months Ago

im having problems makin a volume slider..
Code: [ Select ]
//----------------------------------------<Volume>
loader.scrub.left = loader.scrub._x;
loader.scrub.right = loader.scrub.left+100;
loader.scrub.top = loader.scrub._y;
loader.scrub.bottom = loader.scrub._y;
loader.scrub._x = playerSound.getVolume();


volume_txt.text = playerSound.getVolume();
loader.scrub.onPress = function() {
    this.startDrag(false, this.left, this.top, this.right, this.bottom);
    this.isDragging = true;
};
loader.scrub.onMouseMove = function() {
    if (this.isDragging) {
        volume_txt.text = this._x;
    }
};
loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
    stopDrag();
    isDragging = false;
    playerSound.setVolume(this._x);
};
//----------------------------------------<Volume>
  1. //----------------------------------------<Volume>
  2. loader.scrub.left = loader.scrub._x;
  3. loader.scrub.right = loader.scrub.left+100;
  4. loader.scrub.top = loader.scrub._y;
  5. loader.scrub.bottom = loader.scrub._y;
  6. loader.scrub._x = playerSound.getVolume();
  7. volume_txt.text = playerSound.getVolume();
  8. loader.scrub.onPress = function() {
  9.     this.startDrag(false, this.left, this.top, this.right, this.bottom);
  10.     this.isDragging = true;
  11. };
  12. loader.scrub.onMouseMove = function() {
  13.     if (this.isDragging) {
  14.         volume_txt.text = this._x;
  15.     }
  16. };
  17. loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
  18.     stopDrag();
  19.     isDragging = false;
  20.     playerSound.setVolume(this._x);
  21. };
  22. //----------------------------------------<Volume>


the volume keeps being displayed as 43 to 143
or -173 to 21 depending where I put the MC on the stage

what am i doin wrong?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

1)
converting from system coordinates to percents:
X0 .......... X........X1
0..............Px.........100

so ... the percentage:
Px = 100*(X - X0)/ (X1 - X0); (1)

2)
converting from percents to system coordinates:
0 ........ Px .........100
X0 ........X..........X1

x = X0 + Px*(X1 - X0)/ 100; (2)

in your case, you need formula (1)

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.