# Elastic movements without using tween class?

**URL:** <https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653>\
**Category:** Uncategorized\
**Created:** [April 6, 2006, 4:40pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653 "2006-04-06T16:40:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![geoken](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@geoken](https://forum.kirupa.com/u/geoken)\
**Post date:** [April 6, 2006, 4:40pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/1 "2006-04-06T16:40:20Z")

</div>

Is there any way to get an elastic motion using the traditional method in Flash 8.  
By traditional method I’m reffereng to  
x=(x\*.1)+(target\_current\_difference\*.9)  
\_x += x

The tween class is cool but I’d like to use the old way because it gives me more controll.

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 6, 2006, 4:51pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/2 "2006-04-06T16:51:30Z")

</div>

[here you go 🙂](http://www.kirupa.com/developer/actionscript/spring.htm)

---

<div class="post-metadata">

**Author:** ![geoken](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@geoken](https://forum.kirupa.com/u/geoken)\
**Post date:** [April 6, 2006, 7:35pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/3 "2006-04-06T19:35:24Z")

</div>

> [@BlueNar](#):
>
> [here you go 🙂](http://www.kirupa.com/developer/actionscript/spring.htm)

Does that work in flash 8?

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 6, 2006, 10:30pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/4 "2006-04-06T22:30:06Z")

</div>

Ah, I remember now. Yes it does, but you have to tweak the code a bit. Try searching for my other post, I gave sample. Ill try to post it when I have time.

---

<div class="post-metadata">

**Author:** ![geoken](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@geoken](https://forum.kirupa.com/u/geoken)\
**Post date:** [April 7, 2006, 2:39pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/5 "2006-04-07T14:39:04Z")

</div>

> [@BlueNar](#):
>
> Ah, I remember now. Yes it does, but you have to tweak the code a bit. Try searching for my other post, I gave sample. Ill try to post it when I have time.

Thanks for the help BlueNar. I managed to dig up the post you were reffereng to. The continueTo function helped me out alot. It didn’t totally alleviate me of the desire to make the old equation work, but it’s good enough for now.

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 7, 2006, 4:16pm UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/6 "2006-04-07T16:16:26Z")

</div>

Thats not the one I was referring to, as that still does use the Tween class. I tried doing it out of memory, lemme know if it works.  
[AS]MovieClip.prototype.move = function (centerx:Number,centery:Number,inertia:Number,k:Number):Void {  
this.vx = -this.\_x + centerx ;  
this.vy = -this.\_y + centery ;  
this.xp = this.xp \* inertia + this.vx_k ;  
this.yp = this.yp \* inertia + this.vy_k ;  
this.\_x += this.xp ;  
this.\_y += this.yp ;  
}  
//on the mc  
onClipEvent (enterFrame) {  
this.move (\_root.\_xmouse,\_root.\_ymouse,0.9,0.1) ;  
}  
onClipEvent(load) {  
this.xp = 0;  
this.yp = 0;  
}[/AS] Notice the load event. The variables xp and yp must be initiated before they can be used in the function. Otherwise they are NaN. Hope that helps! :cowboy:

---

<div class="post-metadata">

**Author:** ![geoken](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@geoken](https://forum.kirupa.com/u/geoken)\
**Post date:** [April 8, 2006, 6:03am UTC](https://forum.kirupa.com/t/elastic-movements-without-using-tween-class/184653/7 "2006-04-08T06:03:51Z")

</div>

It works perfectly, thanks alot. Also you’re advise about undeclared variables helped to.
