Hello,
I got an instance I wanna move when clicking the background… and I want it to move to the place I click, Its for my volume bar. At the moment you can drag the volume instance but if you click on the background you wont go there…
This is how the code looks like now:
var music:Sound = new Sound(vSound);
// initial x position fo the dragger
mp3Player.dragger._x = mp3Player.line_mc._x+mp3Player.line_mc._width+3;
mp3Player.dragger.onPress = function() {
this.startDrag(false, mp3Player.line_mc._x, this._y, mp3Player.line_mc._width+mp3Player.line_mc._x+3, this._y);
// drag function for the volume slider
this.onEnterFrame = function() {
Volume = _root.mp3Player.dragger._x-_root.mp3Player.line_mc._x;
// set the volume variable
music.setVolume(Volume);
// set volume
};
};
mp3Player.dragger.onRelease = mp3Player.dragger.onReleaseOutside=function () {
this.stopDrag();
delete this.onEnterFrame;
};
startVolume = 30; // use the start volume variable and set it to 50
_root.mp3Player.dragger._x = _root.mp3Player.line_mc._x + startVolume; // set the dragger x position equal to the startVolume
this.music.setVolume(startVolume); // set the volume of the sound object
Dragger is the actual volume bar and line_mc is the background, This is how the player looks like now