Need some flash help W/ ACTIONSCRIPT

Status
Not open for further replies.

charlomite

Ars Scholae Palatinae
1,201
See anything wrong with my code? The screen wrap seems to lock the object in place for some reason.
code:<HR>
Code:
// Key instructions
onClipEvent (keyDown) {
	if (Key.isDown(Key.RIGHT)) {
		horizontal += 3;
	} else if (Key.isDown(Key.LEFT)) {
		horizontal -= 3;
	} else if (Key.isDown(Key.UP)) {
		vertical -= 3;
	} else if (Key.isDown(Key.DOWN)) {
		vertical += 3;
	}
}
// perpetual motion
onClipEvent (enterFrame) {
	x = (x += horizontal);
	y = (y += vertical);
	setProperty (this, _x, x);
	setProperty (this, _y, y);
	// Screen wrap
	Bug = _root.Bug.getBounds(_root);
	Box = _root.Box.getBounds(_root);
	if (Bug.Ymax<Box.Ymin) {
		this._y = Box.Ymax;
	}
	if (Bug.Ymin>Box.Ymax) {
		this._y = Box.Ymin;
	}
	if (Bug.Xmax<Box.Xmin) {
		this._x = Box.Xmax;
	}
	if (Bug.Xmin>Box.Xmax) {
		this._x = Box.xmin;
	}
}

The motion works fine without the screen wrap :confused:


Charlo
 
Status
Not open for further replies.