AS2 Slider to increase/decrease variable (locked)

78 posts

Flag Post

How do I make a slider that I can use to increase or decrease a variable by dragging it right or left? I really don’t know, all I know is that I need startDrag(); Thanks :D

 
Flag Post

http://www.kirupa.com/developer/mx/volume_slider.htm

That one is for volume, but it’s the same for any variable.

 
Flag Post

Thanks… it’s just confusing because it has all the extra volume stuff in it… Isn’t there a simple code, I’m almost certain it’s simple, can someone please show me? :D

 
Flag Post

You’re starting to sound like danny… >_>

On click, you start dragging, then release the bar and the variable increases or decreases according to it’s x coordinate.

 
Flag Post

I’m not like Danny, I’m asking for the formula. I wasnt going to just copy/pasta it in my game, I want to see how to do it very clearly. I learn like that, it has to be straightforward.

 
Flag Post

http://www.kirupa.com/developer/mx/slider.htm

That one shows how to do it without the volume and sound stuff.

 
Flag Post

Meh, I’m still not seeing it. :P

 
Flag Post

Did you actually take the time to look at it and read it and try to understand it or did you just post 5 seconds after he did? I know @$# about AS2 (AS3 is really different) and it made sense even to me. Also it looked a hell of a lot easier than it would be in AS3.

 
Flag Post

No I was reading it, I just don’t understand it. :P

 
Flag Post
Originally posted by GameBuilder15:

No I was reading it, I just don’t understand it. :P

In 5 seconds? You’re a fast reader! And it’s pretty easy to make a slider. You can do a tutorial, or just figure it out yourself. Figuring it out yourself can cause a lot of bugs though (like when I first made a slider) but just keep trying and you will eventually get it right :D

 
Flag Post

the formula for after you have the slider is rather simple: min(silder.x / silder.width, 1)

also:
    Post by Senekis93 at 2011-01-20T16:54:53-08:00
Post by GameBuilder15 at 2011-01-20T16:57:45-08:00
                  Time Difference: T00:02:51-08:00

 
Flag Post

Another hint – some of that code deals with where the slider SHOULDN’T go. A slider to control a value for a variable (whether it’s volume, difficulty, quality, particles, whatever) would be pretty useless if it slid off the bar; if it was draggable anywhere on screen.

 
Flag Post

It’s not necessary that I have a slider, it’s just that I’m making an Android game, and I think it would be annoying to keep tapping the + or – button to get the right number. However, it might be more accurate than a small slider on a small screen :P

 
Flag Post

You could just spawn a visual keypad, too, if you want them to be able to input exact, larger numbers.

 
Flag Post
Originally posted by inthrees:

You could just spawn a visual keypad, too, if you want them to be able to input exact, larger numbers.

That is a good idea, my friend ^ _ ^

 
Flag Post

DannyDaGameBuilder, give me your mail, and I’ll send you a FLA slider, without startDrag.

 
Flag Post
Originally posted by ehaugw:

DannyDaGameBuilder, give me your mail, and I’ll send you a FLA slider, without startDrag.

Um… cant you just post the formula? I’d really prefer that :P P.S. That’s not my name.

 
Flag Post
Originally posted by GameBuilder15:
Originally posted by ehaugw:

DannyDaGameBuilder, give me your mail, and I’ll send you a FLA slider, without startDrag.

Um… cant you just post the formula? I’d really prefer that :P P.S. That’s not my name.

I know, but Danny should be your title.
The code is in two parts, a button, and in the _root’s enterFrame function.

This is the button:


on(press) {
_root.MusicJustify = true;
}

So, the enterFrame function:


this.onMouseUp = function() {
MusicJustify = false;
};
if (MusicJustify ) {
placement = root.xmouse;
if (placement > 576.15) {
placement = 576.15;
}
if (placement < 352.1) {
placement = 352.1;
}
root.MusicSlider.x = placement;
}
}

 
Flag Post

Your code gives two options.

 
Flag Post
Originally posted by Senekis93:

Your code gives two options.

Sorry, I don’t get you. It works perfectly to me…

 
Flag Post

I see better, thanks. But I still don’t understand it fully. Where’s the variable that increases and decreases? Placement? I thought that was to keep the slider on the line.

P.S. Mr. Anderson is rated higher than Lead for Dead and that’s my code. So I don’t see how I’m Danny. Just because I still have a lot to learn doesn’t mean I’m a noob.

 
Flag Post
Originally posted by ehaugw:
Originally posted by Senekis93:

Your code gives two options.

Sorry, I don’t get you. It works perfectly to me…

I didn’t say it doesn’t work, I mean that your code has two (and only two) posible values for the variable: 576.15 & 352.1

The other option is better, as you can set the lenght of the line/max value for the variable and get all the possible values from it.

 
Flag Post

This seems to be more complicated than I thought. Maybe I’ll just stick with the + and – button….

 
Flag Post
Originally posted by GameBuilder15:

I see better, thanks. But I still don’t understand it fully. Where’s the variable that increases and decreases? Placement? I thought that was to keep the slider on the line.

P.S. Mr. Anderson is rated higher than Lead for Dead and that’s my code. So I don’t see how I’m Danny. Just because I still have a lot to learn doesn’t mean I’m a noob.

Ok, I’m sorry (only a bit, I feel so bad today).

Anyway, to get the output:
1. You must know Max and Min x value ( in this case 576.15 and 352.1).
2. The output will be (from 0 to 1): (Placement – minimum X) / (maximum X – minimum X)

 
Flag Post
Originally posted by GameBuilder15:

This seems to be more complicated than I thought. Maybe I’ll just stick with the + and – button….

And BTW, the rating depends something on how many friends you have, not how good the game is. I was offered a chinese sponsorship…