# Creating a moving a platform in AS3

**URL:** <https://forum.kirupa.com/t/creating-a-moving-a-platform-in-as3/309620>\
**Category:** flash\
**Created:** [May 19, 2010, 10:26pm UTC](https://forum.kirupa.com/t/creating-a-moving-a-platform-in-as3/309620 "2010-05-19T22:26:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dadagu](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@Dadagu](https://forum.kirupa.com/u/Dadagu)\
**Post date:** [May 19, 2010, 10:26pm UTC](https://forum.kirupa.com/t/creating-a-moving-a-platform-in-as3/309620/1 "2010-05-19T22:26:41Z")

</div>

Hello,

I’m having a bit of trouble getting a platform to move between a certain path with AS3.

My code looks like this -

```auto

if (((_platform.x >= 300) && (_sp >0)) || ((_platform.x <= 50) && (_sp <0)))
{
	_sp *= -1;
}

_platform.x += _sp;

```

where \_sp is the speed at which the platform moves (currently at 7) and \_platform is the instance name of the platform.

I want it to move between the coordinates 50 and 300 along the x axis. What it does is, moves along the x axis and as soon as \_platform.x hits 300 I get this weird movement where the platform moves back and forth at this point. Any idea why it’s happening as I am switching the direction as seen in the code.
