A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: [MX] Mouse Game

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Posts
    394

    Angry [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

  2. #2
    Senior Member zervell's Avatar
    Join Date
    May 2004
    Posts
    259

    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

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    still got the same error

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    **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.

  5. #5
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    still got the same error

  6. #6
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    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

  7. #7
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    ok so I have the above post and this aprt
    Code:
    if (mousex == 29.9 && mousey == 54.2) {
    but I'm still getting errors

  8. #8
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    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

  9. #9
    :
    Join Date
    Dec 2002
    Posts
    3,518
    What are the errors now?

  10. #10
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    the same as original. And no I havent becuase tracing pops up in the output box and I hate that

  11. #11
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    Quote 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.
    lather yourself up with soap - soap arcade

  12. #12
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    I couldn't leave it as onEnterFrame...so I changed it and no errors but doesn't go to frame 7

  13. #13
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    Quote 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);
    	}
    };
    lather yourself up with soap - soap arcade

  14. #14
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    well still didn't work

  15. #15
    Now tell me whos watchin...... samvillian's Avatar
    Join Date
    Feb 2007
    Location
    Where do you live?
    Posts
    539
    Quote Originally Posted by mr_malee
    golden rule - DON'T USE CLIP EVENTS!
    i should put that in my sig.
    If the only tool you have is a hammer, you tend to see every problem as a nail.

    Xbox 360 Modding Controller PS3 Mod Paint Spray LED Case

  16. #16
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    huh? I don't get it, I didn't I tried what the person above me said and it didn't work

  17. #17
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    please post your fla, or trace out the numbers.

    maybe an explanation of what you're trying to achieve can help.
    lather yourself up with soap - soap arcade

  18. #18
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    ok can't to big. So how would I do trace?

  19. #19
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    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

  20. #20
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center