# Hummm.... tweening with actionscipt

**URL:** https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926
**Category:** Uncategorized
**Created:** [August 25, 2002, 7:18am UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926 "2002-08-25T07:18:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Afro\_Ninja](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@Afro\_Ninja](https://forum.kirupa.com/u/Afro_Ninja)
#### Post date: [August 25, 2002, 7:18am UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926/1 "2002-08-25T07:18:04Z")

</div>

Hey I’ve known about this for a while, but just today I was told it can reduce file size… this caught my eye as my current big project is getting to be a big fla… So how much can the file be reduced? And also, where do I learn this technique? I know some basic action script, if someone would point me in the way of a tutorial I’d be much appreciative.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 25, 2002, 9:12am UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926/2 "2002-08-25T09:12:08Z")

</div>

I wouldnt call it tweening,i’d call it .[asp movement](http://www.kirupaforum.com/showthread.php?s=&threadid=1157)

onClipEvent (enterFrame) {  
\_x+=10;  
}

onClipEvent (enterFrame) {  
\_y+=10;  
}

onClipEvent (enterFrame) {  
\_width+=10;  
}

onClipEvent (enterFrame) {  
\_height+=10;  
}

onClipEvent (enterFrame) {  
\_alpha-=10;  
}

onClipEvent (enterFrame) {  
\_rotation+=10;  
}

onClipEvent (enterFrame) {  
\_xscale+=10;  
}

onClipEvent (enterFrame) {  
\_yscale+=10;  
}

put each of these actions in seperate MC’s and watch the fun.[asp movement](http://www.kirupaforum.com/showthread.php?s=&threadid=1157)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 25, 2002, 5:43pm UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926/3 "2002-08-25T17:43:16Z")

</div>

Ah yes, I see how that works… then to stop it I could create a loop that ends after however many frames I need… the only problem is that you don’t know where it ends up at… that leads to a lot of trial and error and testing.

At least I think so…

hmmm how much will that really reduce filesize?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 26, 2002, 2:21am UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926/4 "2002-08-26T02:21:23Z")

</div>

no trial an error… or at least not much

something like this could help.

onClipEvent(enterFrame){  
If(\_x\<200){  
\_x++;  
}  
}

Mind you this is not optimal. There are better ways of doing this… but not many so simple.

Mostly a/s is used to move things in regular patterns, rather than from point a to b.

It will reduce your file size a lot.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 26, 2002, 3:35am UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926/5 "2002-08-26T03:35:28Z")

</div>

d’oh… sounds like I need to incorporate some…

But I shouldn’t be too worried… My file cannot be over 5MB… it’s currently 1MB published with all sound and I’m about half done.

Man I wish I had optimaze!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 27, 2002, 10:11am UTC](https://forum.kirupa.com/t/hummm-tweening-with-actionscipt/4926/6 "2002-08-27T10:11:13Z")

</div>

You can create a tweenTo function or prototype to do the job for you. Something I did based on Supra’s code:

```auto
MovieClip.prototype.tweenTo=function(x,y,speed){
   var deltax=x-this._x;
   var deltay=y-this._y;
   var distance=Math.sqrt(deltax*deltax+deltay*deltay);
   var norm=speed/distance;
   var diffx=deltax*norm;
   var diffy=deltay*norm;
   if (distance>speed){
      this._x+=diffx;
      this._y+=diffy;
   } else {
      this._x=x;
      this._y=y;
   }
}

```

You can use that with any movie clip:

```auto
onClipEvent(enterFrame){
   this.tweenTo(300,400);
}

```

pom :asian:
