# Movement with actionscript

**URL:** <https://forum.kirupa.com/t/movement-with-actionscript/23862>\
**Category:** flash\
**Created:** [June 23, 2003, 3:05pm UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862 "2003-06-23T15:05:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![flurofunk](https://avatars.discourse-cdn.com/v4/letter/f/91b2a8/32.png) [@flurofunk](https://forum.kirupa.com/u/flurofunk)\
**Post date:** [June 23, 2003, 3:05pm UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/1 "2003-06-23T15:05:53Z")

</div>

Hi I’m a actionscriptin newbie and I’m tryin to create movement using actionscript (in a banner) I have read the tutorial on this site but it doesn’t quite help me enough!!  
basically here’s a link to the fla of what I originally did using motion tweening but it’s a huge filesize!! With actionscript i can make it smaller - can’t I?!

[http://intranet.mykindaplace.com/playroom/playroom\_banner1.fla](http://intranet.mykindaplace.com/playroom/playroom_banner1.fla)

I’ve got the first image to move from one position to the next but I don’t know how to carry on the movement…if I type in more co-ordinates it just twitches!!? this is what I’ve done so far!  
onClipEvent (load) {  
loop = 0;  
this.\_x = 280;  
this.\_y = 160;  
}  
onClipEvent (enterFrame) {  
if (this.\_x\>180) {  
this.\_x += -3;  
this.\_y += -2;  
(stop);  
} else if (this.\_x\<280) {  
this.\_x += 3;  
this.\_y += 2;  
}  
}

I’d b so chuffed if anyone can help me as my work expect it done by tuesday?! :-\ thx in advance!!  
See attached .fla for what I’m tryin to do!!

---

<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:** [June 24, 2003, 2:48am UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/2 "2003-06-24T02:48:59Z")

</div>

ok mate i have done a complet new code for you  
it works hope you know how to use it…simple to understand:) 🙂

---

<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:** [June 25, 2003, 9:34am UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/3 "2003-06-25T09:34:15Z")

</div>

Hey Zen, wow u made it look so simple! I had an idea moveTo was a 'way ’ of doing it but couldn’t work out how!!  
I’ve pulled urs apart and got it to fade as well now!  
Thx alot - am workin on it today - then off on holiday 2moro - at least I’ll b able to relax while I’m away! cheers mate! 🙂

---

<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:** [June 25, 2003, 10:30am UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/4 "2003-06-25T10:30:02Z")

</div>

I’m usin the code but am wondering how to make it move smoothly…currently it divides the distance it has to trave  
l by say 5 so it starts off fast and slows down, is there a way to make it travel at the same speed from one x,y co-ordinate to the next?  
the code is like this currently;  
onClipEvent (enterFrame) {  
this.\_x += (\_root.endX-this.\_x)/5;  
// can change speed by dividing the 5;  
this.\_y += (\_root.endY-this.\_y)/5;  
}

see wot i mean… ?!hey n thx again for ur help - anyone?! =)

---

<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:** [June 25, 2003, 11:24am UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/5 "2003-06-25T11:24:19Z")

</div>

If you need smoother animation, up the framerate.

---

<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:** [June 26, 2003, 7:48am UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/6 "2003-06-26T07:48:18Z")

</div>

constant frame rate eh…  
oh ok  
onClipEvent (enterFrame) {  
if(this.\_x!=\_root.endX)  
{ if(this.\_x\<\_root.endX)  
this.\_x++;  
if(this.\_x\>\_root.endX)  
this.\_x–;  
}

if(this.\_y!=root.endY)  
{  
if(this.\_y\<\_root.endY)  
this.\_y++;  
if(this.\_y\>\_root.endY)  
this.\_y–;  
}  
}

haven tested the code just writting for fun hope it works

---

<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:** [June 27, 2003, 6:21am UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/7 "2003-06-27T06:21:54Z")

</div>

You can also use setInterval to get smoother motion or fading without having to adjust your framerate. Check out my (I’m retrotron there) longer explanation of moving something with setInterval here:  
[http://flashkit.com/board/showthread.php?threadid=459515](http://flashkit.com/board/showthread.php?threadid=459515)  
I posted some examples of fading with onEnterFrame() and setInterval() on [actionscript.org](http://actionscript.org), but the site’s down for the moment, so I’ll have to post that link later (I know, I know, everybody hates links :)).

---

<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:** [June 27, 2003, 6:58pm UTC](https://forum.kirupa.com/t/movement-with-actionscript/23862/8 "2003-06-27T18:58:57Z")

</div>

This link should take you to the examples of fading with actionscript I mentioned:

> **[ActionScript.org Forums - Powered by vBulletin](http://www.actionscript.org/forums/index.php)**
>
> ActionScript.org Forums
