# \[AS2\] Character gets stuck in corners, need help

**URL:** <https://forum.kirupa.com/t/as2-character-gets-stuck-in-corners-need-help/325966>\
**Category:** programming\
**Created:** [November 14, 2011, 6:29pm UTC](https://forum.kirupa.com/t/as2-character-gets-stuck-in-corners-need-help/325966 "2011-11-14T18:29:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![revin](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@revin](https://forum.kirupa.com/u/revin)\
**Post date:** [November 14, 2011, 6:29pm UTC](https://forum.kirupa.com/t/as2-character-gets-stuck-in-corners-need-help/325966/1 "2011-11-14T18:29:52Z")

</div>

here is the link to the flash :  
[http://www.swfme.com/view/1211482](http://www.swfme.com/view/1211482) [early version]  
[http://raptor.x10.mx/index.php](http://raptor.x10.mx/index.php) [latest]

and here is my flash file: [http://www.zshare.net/download/96025525599154c2/](http://www.zshare.net/download/96025525599154c2/)

whenever you click yourself into a corner it gets stuck, i dunno how to resolve it, but otherwise the code is nearly perfect collision

in latest version player was moved to \_root.map.player but it still behaves the same way

```auto

MovieClip.prototype.movement = function() {
    var a = this;
    var b = _root.map.block;
    if (!_root.isPaused) {
        if (_root.continueanim) {
            a.mc.play();
        }
        a.spd = _root.pscale/100*5;
        _root.rescale(a, _root.pscale);
        a.xDistance = (a.posX-a._x);
        a.yDistance = (a.posY-a._y);
        a.hitX = (!b.hitTest(a._x+a.moveX, a._y, true))*(Math.abs(a.xDistance)>5);
        a.hitY = (!b.hitTest(a._x, a._y+a.moveY, true))*(Math.abs(a.yDistance)>5);
        if (Math.abs(a.xDistance)<Math.abs(a.moveX)) {
            a.moveX = a.xDistance;
            if (Math.abs(a.moveX)<=5) {
                a.moveX = 0;
            }
        }
        if (Math.abs(a.yDistance)<Math.abs(a.moveY)) {
            a.moveY = a.yDistance;
            if (Math.abs(a.moveY)<=5) {
                a.moveY = 0;
            }
        }
        if (a.hitX == 0 && a.hitY == 0 && a.onMove) {
            a.mc.gotoAndPlay("idle");
            a.onMove = false;
            
        }
        a._x += a.moveX*a.hitX;
        a._y += a.moveY*a.hitY;
    } else {
        a.mc.stop();
        _root.continueanim = true;
    }
};

```

usually if you click the character into a corner you’d get stuck if you clicked in at an angle

can anybody help me? i’d appreciate a fix maybe ^^
