A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Gradual Sliding?

  1. #1
    Junior Member
    Join Date
    Dec 2001
    Posts
    18
    I've seen several examples of this and I am trying to reproduce it for my next flash. Let's say I have two bars that are currently surrounding each side of a button. If I Click on another button the two bars move to the specified x position but do so gradually and begin to slow down as they get closer.
    Example:

    |A| B

    Button A is the current location
    B is where I wanna go gradually

    so it slides to B when I click on B
    |A| B
    A | | B
    A |B|
    Thats what it should do but smoothly. What is the acitonscript to move them slowyl rather than going straight from Point A to Point B?

  2. #2
    ok like this:
    mc is the movieclip of the 2 lines
    targetx is a variable that = where you want the movieclip of the lines to finish on the x scale, same for targety but y scale
    frame 1
    Code:
    _root.mc._x = (_root.targetx._x - _root.mc._x)/3;
    _root.mc._y = (_root.targety._y - _root.mc._y)/3;
    frame 2
    Code:
    gotoAndPlay(1);
    these two frames should be inside a movieclip of their own so they can just loop away while the main timeline is stopped or doing whatever you want.

    I divide by 3 but you can experiment. it will affect the speed such that a lower number is faster and a higher number is slower

    to set the targetx/y variables it might be easier to put the buttons inside their own movieclips. then on the buttons inside the movieclips have the following code.
    Code:
    on (press){
     _root.targetx = this._x;
     _root.targety = this._y;
    }

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