A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Scroll Bar Issues

  1. #1
    Member
    Join Date
    Jul 2003
    Posts
    63

    Scroll Bar Issues

    I posted this in the ActionScript forum and got no response (yet):

    I'm trying to build a scroll bar (and a scroll pane) because I was having difficulty customizing the built-in scroll bar component.

    I'm trying to make one of the arrow buttons continually move the slider as it is pressed, i.e. you hold the mouse button down and the content scrolls.

    I tried to do it like this:

    sliderBar.rightArrow.onPress = function() {
    sliderBar.rightArrow.active = true;
    while (sliderBar.rightArrow.active) {
    sliderBar.slide._x++;
    if (sliderBar.slide._x > 380) {
    sliderBar.slide._x = 380;}
    updateAfterEvent;
    }
    }

    sliderBar.rightArrow.onRelease = function() {
    sliderBar.rightArrow.active = false;

    }

    sliderBar.rightArrow.onReleaseOutside = function() {
    sliderBar.rightArrow.active = false;
    }



    I also tried

    for (count=0; count<=380; count++) {
    sliderBar.slide._x++;
    if (sliderBar.slide._x > 380) {
    sliderBar.slide._x = 380;}
    updateAfterEvent; }

    in place of the while loop, but it loops through so quickly, the slider bar just appears to jump, instead of moving smoothly.

    But the while statement hangs the movie, despite releasing the mouse buttons. Is there another way?

  2. #2
    Senior Member the_protectot's Avatar
    Join Date
    Jul 2003
    Posts
    401

    TRY...

    code:
    sliderBar.rightArrow.onPress = function() {
    sliderBar.rightArrow.active = true;
    sliderBar.rightArrow.onEnterFrame=function(){
    if(sliderBar.rightArrow.active == true && sliderBar.slide._x < 380){
    sliderBar.slide._x++;
    updateAfterEvent;
    }else{
    delete sliderBar.rightArrow.onEnterFrame;
    }
    }
    }


  3. #3
    Member
    Join Date
    Jul 2003
    Posts
    63
    You rock. Thanks.

    ... with some adjustments.

    This is the final script that seems to be working nicely (this also as the script that will scroll the movie clip that the slide bar references):

    Action Script


    sliderBar.rightArrow_mc.onPress = function() {
    sliderBar.rightArrow_mc.active = true;
    sliderBar.rightArrow_mc.onEnterFrame = function(){
    if (sliderBar.rightArrow_mc.active && sliderBar.slide._x < 390) {
    sliderBar.slide._x += 10;
    _root.projectThumbs3._x = (_root.background_mc._x - (sliderBar.slide._x * .283));
    }
    }
    }

    sliderBar.rightArrow_mc.onRelease = function() {
    sliderBar.rightArrow_mc.active = false;

    }

    sliderBar.rightArrow_mc.onReleaseOutside = function() {
    sliderBar.rightArrow_mc.active = false;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center