# Character movement screen wrapping \[renamed\]

**URL:** https://forum.kirupa.com/t/character-movement-screen-wrapping-renamed/331467
**Category:** flash
**Created:** [August 7, 2013, 1:53pm UTC](https://forum.kirupa.com/t/character-movement-screen-wrapping-renamed/331467 "2013-08-07T13:53:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Mark1989](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Mark1989](https://forum.kirupa.com/u/Mark1989)
#### Post date: [August 7, 2013, 1:53pm UTC](https://forum.kirupa.com/t/character-movement-screen-wrapping-renamed/331467/1 "2013-08-07T13:53:39Z")

</div>

I’m trying to make it so that once the test screen is opened my enemy pic will move across the stage and wrap back to the beginning until the screen is closed. Any help would be appreciated as I don’t even know where to begin.

Current code:

import flash.events.Event;

var bg:background = new background  
addChild (bg);

var pp: PlayerPic = new PlayerPic  
addChild (pp);  
pp.x= 125  
pp.y= 550  
pp.height = 40  
pp.width = 50

var ep:EnemyPic = new EnemyPic  
addChild (ep);  
ep.x= 55  
ep.y= 50  
ep.height= 40  
ep.width= 50

stage.addEventListener(KeyboardEvent.KEY\_DOWN, arrowMove)

function arrowMove(event:KeyboardEvent):

void

{  
if (event.keyCode == Keyboard.LEFT)  
{  
pp.x -= 5;  
if (pp.x \< 0)  
{  
pp.x = 0;  
}  
}  
if (event.keyCode == Keyboard.RIGHT)  
{  
pp.x += 5;  
if (pp.x \> 250)  
{  
pp.x = 250;  
}  
}  
if (event.keyCode == Keyboard.UP)  
{  
pp.y -= 5;  
if (pp.y \< 0)  
{  
pp.y = 0;  
}  
}  
if (event.keyCode == Keyboard.DOWN)  
{  
pp.y += 5;  
if (pp.y \> 550)  
{  
pp.y = 550;  
}  
}

}
