A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Quick Question

  1. #1
    Senior Member
    Join Date
    Jun 2000
    Posts
    100

    Quick Question

    I am sure the answer is no but I thought I would ask.

    I am using thsi script in my movie for easing.

    onClipEvent(load)
    {
    var Targetx=Picture.Home._x;
    var Speed=.085;

    }
    onClipEvent(enterFrame)
    {
    var xDistance=Speed*Math.sqrt(Math.pow((Picture._x+Tar getx)-_parent.View._x,2));

    if((Picture._x+Targetx)>=_parent.View._x)
    {
    Picture._x-=xDistance;
    }
    else if((Picture._x+Targetx)<=_parent.View._x)
    {
    Picture._x+=xDistance;
    }

    }

    The one thing I notice is taht when my image is almost in place I get a little jerky movement. It is nto so bad but for the last two pixels or so I get a jerky movemnt that I would like to smooth out. Is there anyway to make it smoother?

    Thanks for the help.

  2. #2
    Senior Member Pporksoda's Avatar
    Join Date
    Jul 2000
    Location
    baltimore
    Posts
    174
    Try this instead:

    Code:
    onClipEvent (load) {
    	var Targetx = 300;
    	var Speed = .085;
    }
    onClipEvent (enterFrame) {
    	Picture._x += (Targetx-Picture._x)*Speed;
    }

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    100

    Not working

    I tried you code and I may have done something wrong. I replaced all of my code with yours but then when I ran my movie the movie clip just shot off my stage. I am not sure if I did something wrong or not.

    Any suggestions?

    Thanks

  4. #4
    Senior Member Pporksoda's Avatar
    Join Date
    Jul 2000
    Location
    baltimore
    Posts
    174
    My code was just a sample, and I'd set Targetx to 300. You need to modify the Targetx variable to match your desired "target x postion".

    Based on what you first posted it would probably be this.

    Code:
    onClipEvent (load) {
    	var Targetx = Picture.Home._x;
    	var Speed = .085;
    }
    onClipEvent (enterFrame) {
    	Picture._x += (Targetx-Picture._x)*Speed;
    }

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