Forum Topic: Vcam cursor

(145 views • 9 replies)

This topic is 1 page long.

<< < > >>
None

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/8/08 03:48 PM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

Well, I'm using a Vcam as my cursor for a game (AS2 if it matters) but the cursor keeps flinging offscreen. anybody know how to fix it? I've marked the edges of my flash with thick black lines.

Click my sig for a hilarious thread.

BBS Signature

None

Rathanos

Reply To Post Reply & Quote

Posted at: 6/8/08 03:50 PM

Rathanos LIGHT LEVEL 22

Sign-Up: 05/31/03

Posts: 2,107

I'd make sure not to allow the mouse to escape those boundaries with a 'if mouse X and mouse y are at that point, stop moving any further'

That's one option


None

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/8/08 03:52 PM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

Thanks Rath =) I need to work on my script.

Click my sig for a hilarious thread.

BBS Signature

None

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/8/08 04:00 PM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

Right, I've got this code

onClipEvent (mouseMove) {
	if (!_x<=0) {
		if (!_x>=550) {
			if (!_y>=0) {
				if (!_y<=400) {
					_x = _root._xmouse;
					_y = _root._ymouse;
				}
			}
		}
	}
}
onClipEvent (load) {
	Mouse.hide();
}

and my Vcam doesn't move. Have I got the >< the wrong way round or something?

Click my sig for a hilarious thread.

BBS Signature

None

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/8/08 04:02 PM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

Sorry for triple

anyway, I've fixed my last error, but now I can't get back withing the boundaries.

onClipEvent (mouseMove) {
	if (_x>=0) {
		if (_x<=550) {
			if (_y>=0) {
				if (_y<=400) {
					_x = _root._xmouse;
					_y = _root._ymouse;
				}
			}
		}
	}
}
onClipEvent (load) {
	Mouse.hide();
}

Click my sig for a hilarious thread.

BBS Signature

None

CaptainPoncho

Reply To Post Reply & Quote

Posted at: 6/8/08 06:21 PM

CaptainPoncho EVIL LEVEL 08

Sign-Up: 11/29/03

Posts: 535

At 6/8/08 04:02 PM, Wolfears2 wrote:
Sorry for triple
anyway, I've fixed my last error, but now I can't get back withing the boundaries.

onClipEvent (mouseMove) {
if (_x>=0) {
if (_x<=550) {
if (_y>=0) {
if (_y<=400) {
_x = _root._xmouse;
_y = _root._ymouse;
}
}
}
}
}
onClipEvent (load) {
Mouse.hide();
}

This isn't going to fix anything, but I'm going to point out that it's a lot easier to reduce that to...

if (_x >= 0 && _x <= 550 && _y >= 0 && _y <= 400) {
     _x = _root._xmouse;
     _y = _root._ymouse;
}

The logical && (and) operator will check for each condition until it finds 'false', so it will do the same thing your code is doing. Just a good habit to get into and will save you a lot of time and grief in the long run.


None

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/9/08 01:18 AM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

Thanks Cap'n. I already got the code working, but I'm gonna have to start doing that =P

Click my sig for a hilarious thread.

BBS Signature

None

Zerobeam

Reply To Post Reply & Quote

Posted at: 6/9/08 01:49 AM

Zerobeam NEUTRAL LEVEL 07

Sign-Up: 11/03/05

Posts: 682


Elated

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/9/08 02:11 AM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

At 6/9/08 01:49 AM, Zerobeam wrote: Would you mind sharing the code with us?

Sure, its

onClipEvent (mouseMove) {
	if (_x>=0) {
		if (_x<=550) {
			if (_y>=0) {
				if (_y<=400) {
					_x = _root._xmouse;
					_y = _root._ymouse;
				}
			}
		}
	}
	if(_x<0){
		_x=5
	} else if(_x>550){
		_x=545
	} else if(_y<0){
		_y=5
	} else if(_y>400){
		_y=395
	}
}
onClipEvent (load) {
	Mouse.hide();
}

Not put the && in yet, but it works, so I'm happy =)

Click my sig for a hilarious thread.

BBS Signature

None

Wolfears2

Reply To Post Reply & Quote

Posted at: 6/9/08 02:34 AM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 862

At 6/9/08 02:26 AM, TomsPulp wrote: make sure the reg point is in middle..

it is. It all works now, Tom.

Click my sig for a hilarious thread.

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 04:57 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!