|
-
[MX] Mouse Game
ok on my frame I have this
Code:
set (mousex, _xmouse);
set (mousey, _ymouse);
and on my object I have this
Code:
onClipEvent (enterFrame) {
if (mousex = 29.9 && mousey = 54.2) {
_root.gotoAndStop(7);
}
}
and when I test it I get this error messsage
Code:
**Error** Scene=Scene 1, layer=back, frame=5:Line 2: Left side of assignment operator must be variable or property.
if ("mousex" = 29.9 && "mousey" = 54.2) {
Total ActionScript Errors: 1 Reported Errors: 1
please help...its a game where you have to keep your mouse in a certain area(picture) and if you rollOut it goes here and if the mouse coordinates are that you go here...I got pretty much everything to work except this
-
Senior Member
maybe
I've been into as3 for some time and I not a sharp as I use to be. mousex is being call from with in a MC(or what not). I believe you need to add _root.mousex to the code.
onClipEvent (enterFrame) {
if (_root.mousex= 29.9 && _root.mousey= 54.2) {
_root.gotoAndStop(7);
}
}
CEO OF
-
-
**Error** Scene=Scene 1, layer=back, frame=5:Line 2: Left side of assignment operator must be variable or property.
if ( "mousex " = 29.9 && "mousey " = 54.2) {
Total ActionScript Errors: 1 Reported Errors: 1
Try removing the quotation marks and change the = to ==
Code:
if (mousex == 29.9 && mousey == 54.2) {
Last edited by dawsonk; 08-25-2008 at 06:29 PM.
-
-
Pumpkin Carving 2008
Try it without the flash 4 syntax:
Code:
var mousex = _xmouse; // instead of Set
var mousey = _ymouse; // instead of Set
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
ok so I have the above post and this aprt
Code:
if (mousex == 29.9 && mousey == 54.2) {
but I'm still getting errors
-
Pumpkin Carving 2008
Have you tried tracing out mousex and mousey to fully ensure your scope is correct?
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
-
the same as original. And no I havent becuase tracing pops up in the output box and I hate that
-
M.D.
 Originally Posted by kraxyk
the same as original. And no I havent becuase tracing pops up in the output box and I hate that
oh dear, looks like your flash future will be very slow and painful.
try:
Code:
mousex = _xmouse;
mousey = _ymouse;
onEnterFrame = function () {
if (mousex == 29.9 && mousey == 54.2) {
_root.gotoAndStop(7);
}
};
golden rule - DON'T USE CLIP EVENTS!
and why in the world do you need to check a decimal place for a mouse position? i'm not even sure that's possible, mouse is whole pixels, unless the object is scaled maybe.
-
I couldn't leave it as onEnterFrame...so I changed it and no errors but doesn't go to frame 7
-
M.D.
 Originally Posted by kraxyk
I couldn't leave it as onEnterFrame...so I changed it and no errors but doesn't go to frame 7
just look at the logic for a second and you'll see that its close to impossible to trigger that behavior.
the mouse's position is stored in some variables at the start of your game. These numbers are never updated. So if the user had his/her mouse at 5,15 at the start of your game, your "if statement" will never be true.
what you need to do is update the mousex and mousey variables in the onEnterFrame function. Then check these numbers in the if statement. You also need to set your numbers to "whole" numbers. The mouse can never be a decimal (unless the object containing the mouse is scaled)
Code:
//store some temporary variables
var mousex;
var mousey;
onEnterFrame = function () {
//update the mouse
mousex = _xmouse;
mousey = _ymouse;
//check the mouse's coordinates
if (mousex == 30 && mousey == 54) {
_root.gotoAndStop(7);
}
};
-
-
Now tell me whos watchin......
 Originally Posted by mr_malee
golden rule - DON'T USE CLIP EVENTS!
i should put that in my sig.
-
huh? I don't get it, I didn't I tried what the person above me said and it didn't work
-
M.D.
please post your fla, or trace out the numbers.
maybe an explanation of what you're trying to achieve can help.
-
ok can't to big. So how would I do trace?
-
Pumpkin Carving 2008
trace("xmouse: " + mousex + " | ymouse: " + mousey);
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
didn't work...no errors but didn't go to frame 7
DOWNLOAD GAME
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|