[Actionscript] Smooth Scrolling On Button Press

Discussion in 'Programming' started by timallard, Aug 15, 2008.

  1. #1
    Hello,

    Im trying to make a MC smooth scroll on button press, right now it only advances once when pressed, it doesnt stay advancing when it stays hovered.

    here is my code

    _root.leftButton_mc.onRollOver= function() {
    _root.world.grass._x = _root.world.grass._x + 25;
    _root.world.water_mc._x = _root.world.water_mc._x + 5;
    _root.world.city._x = _root.world.city._x + 2;
    _root.world.item2Button._x = _root.world.item2Button._x + 5;
    }

    I tried onPress, onMouseOver etc but can not figure this one out, also any easing code help will be greatly appreciated to make it look nice and smooth.

    Thanks!
    -Tim
     
    timallard, Aug 15, 2008 IP
  2. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #2
    SOLVED

    _root.leftButton_mc.onPress = function() {
    this.onEnterFrame = function() {
    _root.world.grass._x = _root.world.grass._x + 25;
    _root.world.water_mc._x = _root.world.water_mc._x + 5;
    _root.world.city._x = _root.world.city._x + 2;
    _root.world.item2Button._x = _root.world.item2Button._x + 5;
    }
    }

    _root.leftButton_mc.onRelease = function() {
    delete this.onEnterFrame;
    }
     
    timallard, Aug 15, 2008 IP
  3. alexme

    alexme Guest

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, I might use this myself...
     
    alexme, Aug 19, 2008 IP
  4. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #4
    I would suggest you use timer rather than implementing new onEnterFrame event handler, to save CPU usage.

    regards
     
    Vooler, Aug 19, 2008 IP