dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Mouse control with different frames

  1. #1
    Member
    Join Date
    Jul 2005
    Posts
    63

    [F8] Mouse control with different frames

    i am modifying an avoiding game script that i got from frozen haddock,and there's a feature that i'd like to add, but can't figure out how to do. in the game, the "hero" is controlled by the mouse using

    this._x = _root._xmouse

    and

    this._y = _root._ymouse

    what i would like to do is have the "hero" go to different frame inside of it's own movie clip (if the mouse is moved left, then the character faces left, etc.)...i know that, if i were to use keyboard controls, i would add those controls onto the key listener, but i'm not sure about how to proceed when using the mouse to control....can anyone steer me in the right direction?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe you can adapt this to what you are trying to do...

    Code:
    stop();
    function checkFace() {
    	if (hero.oldX == _xmouse) {
    		hero.gotoAndStop("facecenter");
    		clearInterval(hero.intID);
    	}
    }
    hero.onMouseMove = function() {
    	clearInterval(this.intID);
    	if (this.oldX < _xmouse) {
    		hero.gotoAndStop("faceright");
    	} else if (this.oldX > _xmouse) {
    		hero.gotoAndStop("faceleft");
    	}
    	this.oldX = _xmouse;
    	this.intID = setInterval(checkFace, 1000);
    };
    Mouse.addListener(hero);
    hero.oldX = _xmouse;
    hero.startDrag(true);
    checkFace();
    Last edited by dawsonk; 10-20-2008 at 02:15 PM.

  3. #3
    Member
    Join Date
    Jul 2005
    Posts
    63
    thanks! I'm plugging that into my script right now

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