can a slider stop and continue while onPress?

  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

I searched and found one previous posting about my Q but didn't give me the right answer.

I have a slider called "but" and an element effected by the slider called "card1".

I'm moving "card1" according the the slider's output (its Y value), but "card1" is slightly changing its path as i move the slider way up or way down (outside of the stage) many times back and forth. To fix that, I'm guessing I need to limit the slider's output.

so... in order to prevent it from sliding too far I used the - delete onEnterFrame - command once the slider reached a certain point. the problem - I need to sometimes click on "but" a few times till it moves again (hence the jump to 64 in "onPress").

my question - is there a way to make the slider stop at certain point AND continue while the mouse is down?


Code: [ Select ]
function sliding() {
    this.onEnterFrame = function() {
        but._y = _ymouse;
        output = but._y-100;
        card1._x -= output/3;
        card1._y += output/4.5;
    };
}
but.onPress = function() {
    sliding();
    if (but._y == 60) {
        but._y = 64;
    }
};
but.onRelease = function() {
    delete onEnterFrame;
};
  1. function sliding() {
  2.     this.onEnterFrame = function() {
  3.         but._y = _ymouse;
  4.         output = but._y-100;
  5.         card1._x -= output/3;
  6.         card1._y += output/4.5;
  7.     };
  8. }
  9. but.onPress = function() {
  10.     sliding();
  11.     if (but._y == 60) {
  12.         but._y = 64;
  13.     }
  14. };
  15. but.onRelease = function() {
  16.     delete onEnterFrame;
  17. };
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

sorry, I ommited this part (comes inside sliding function)


Code: [ Select ]
    if (but._y<60) {
            delete onEnterFrame;
            but._y = 60;
        }

Thanks...
  1.     if (but._y<60) {
  2.             delete onEnterFrame;
  3.             but._y = 60;
  4.         }
  5. Thanks...
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

Solved!
I took a different "road" though.
Thanks anyway.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23455
  • Loc: Woodbridge VA

Post 3+ Months Ago

meAsking,

Glad you joined us at OZZU and welcome you, but if you solved the problem yourself, we always encourage posters to post the solution. People come here from Google and all over the place to find help. It would be nice to know what the answer is.
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

Hopefully this is the right solution, but as I advance with my project I ran into another problem that I am about to post...
anyway:
My initial problem was
that "card1" kept slightly changing its path as i played with the
slider and moved it back and forth, so I thought that the possible
solution would be to limit the slider's output. I realized last
night that I need to limit the movement of "card1" not the slider,
so when card1 reaches the top right corner && the slider output is
above 0 it jumps back to the bottom left, and when card1 reaches the
bottom left && output < 0, card1 jumps back to the upper right
corner, so it'll always loop this way and card1 will never be
completely off and hopefully by that it won't change its path (I
hope).
It seems like its running ok now.

Thanks again.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 10 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
 
cron
 

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