I cant get this moving background style hittest to work correctly, its kinda working but not correctly.
I'll explain.. You can move the background using the left and right keys and move the floating dot with the up and down keys, i am wanting the background/dot to stop moving if a hittest occurs (which it does) but once it hittests then nothing will move at all..
i've attached a fla if anyone can help, its being saved using flash 8.
also here is the code and a screenshot incase you cannot open flash 8 fla's.
code:
var leftEdge:Number = 0;
var rightEdge:Number = -510;
var topEdge:Number = 20;
var bottomEdge:Number = 380;
var moveSpeed:Number = 5;
_root.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
if (_root.xmove._x > rightEdge){
if (!_root.xmove.hitTest(_root.dot._x, _root.dot._y, true)) {
_root.xmove._x -= moveSpeed;
}
}
}
if (Key.isDown(Key.LEFT)) {
if (_root.xmove._x < leftEdge){
if (!_root.xmove.hitTest(_root.dot._x, _root.dot._y, true)) {
_root.xmove._x += moveSpeed;
}
}
}
if (Key.isDown(Key.UP)) {
if (_root.dot._y > topEdge){
if (!_root.xmove.hitTest(_root.dot._x, _root.dot._y, true)) {
_root.dot._y -= moveSpeed;
}
}
}
if (Key.isDown(Key.DOWN)) {
if (_root.dot._y < bottomEdge){
if (!_root.xmove.hitTest(_root.dot._x, _root.dot._y, true)) {
_root.dot._y += moveSpeed;
}
}
}
}
Dot is the dot and xmove is the background.
thanks in advance.
Last edited by mexicanbean; 02-26-2010 at 03:20 PM.