# Might be a logic problem?

**URL:** <https://forum.kirupa.com/t/might-be-a-logic-problem/225726>\
**Category:** Uncategorized\
**Created:** [May 15, 2007, 6:38am UTC](https://forum.kirupa.com/t/might-be-a-logic-problem/225726 "2007-05-15T06:38:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warheart](https://avatars.discourse-cdn.com/v4/letter/w/5f9b8f/32.png) [@Warheart](https://forum.kirupa.com/u/Warheart)\
**Post date:** [May 15, 2007, 6:38am UTC](https://forum.kirupa.com/t/might-be-a-logic-problem/225726/1 "2007-05-15T06:38:06Z")

</div>

Hello,

I have a weird sort of a problem, i’ve pretty much got an inventory MC inside another MC for the map which is sitting on the main stage. So that the inventory will stay still with the character (the map moves when you use the arrow keys not the char) instead of moving with the map, i have the inventory running a function. The function is:

```auto
function moveinv (inv) {
    if(Key.isDown(Key.RIGHT)) {
        inv._x += _global.right_speed;
    } else if(Key.isDown(Key.LEFT)) {
        inv._x -= _global.left_speed;
    } else if (Key.isDown(Key.DOWN)) {
        inv._y += _global.down_speed;
    } else if (Key.isDown(Key.UP)) {
        inv._y -= _global.up_speed;
    }
}

```

the \_global.direction\_speed is the same variable used for the maps movement. If you hit one of the blockers which is just an MC then it will run a function (in this case if you hit a blocker from the left side):

```auto
function rightblock (block) {
        bk = eval(block);
        if (_root.map2.character.hitTest(bk)==true) {
        _global.right_speed -= _global.right_speed;
    }
}

```

This stops the movement of the character which works perfectly, and it should stop the movement of the inventory cause its the same variable, however the inventory MC will jump roughly 5 pixels to for example the right if you were heading right etc. Which is the same amount as the variable for the movement speed. I can’t really see what would be causing it to do this except for maybe if theres a logic problem? Heres a link for the swf incase you didn’t understand my description. [http://tonic.matric.com.au/RPG\_main8mx.swf](http://tonic.matric.com.au/RPG_main8mx.swf) any help would be great =D

Thanks,  
Grant.
