A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: changing weapons with the mouse wheel?

  1. #1
    Senior Member
    Join Date
    Aug 2005
    Posts
    225

    changing weapons with the mouse wheel?

    i noticed that it heli-attack 3 you can change weapons using the mousewheel but i cant find any tutorials on it and im not sure how .onMouseWheel works.

  2. #2
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Why not learn how to use onMouseWheel? As far as I know, its the only way to take input from a scroll wheel. There is plenty of doccumentation in the help files.

    I did something like what you want but it also uses the keyboard and moves an indicator on and off the screen. It probbably wont work for you but it may help you.
    Code:
    var oMouseListener:Object = new Object ();
    oMouseListener.onMouseWheel = function (delta) {
    	if (delta < 0) {
    		if (nCurrentWeapon < 2) {
    			nCurrentWeapon += 1;
    		}
    	} else {
    		if (nCurrentWeapon > 0) {
    			nCurrentWeapon -= 1;
    		}
    	}
    	nBarTicker = nBarTimeOut;
    };
    oMouseListener.onMouseDown = function () {
    	if (nDelay < 1) {
    		if (nCurrentWeapon == 0) {
    			_root["Shell" + aWeaponLevels[0]].duplicateMovieClip (("SInstance" + nDepth), nDepth);
    			oCoord.x = _root.gun.ShellPoint._x;
    			oCoord.y = _root.gun.ShellPoint._y;
    			_root.gun.localToGlobal (oCoord);
    			_root["SInstance" + nDepth]._x = oCoord.x;
    			_root["SInstance" + nDepth]._y = oCoord.y;
    			_root["SInstance" + nDepth]._rotation = _root.gun._rotation;
    			nDepth++;
    			nDelay = 12;
    		} else if (nCurrentWeapon == 2) {
    			_root["Plasma" + aWeaponLevels[2]].duplicateMovieClip (("PInstance" + nDepth), nDepth);
    			oCoord.x = _root.gun.PlasmaPoint._x;
    			oCoord.y = _root.gun.PlasmaPoint._y;
    			_root.gun.localToGlobal (oCoord);
    			_root["PInstance" + nDepth]._x = oCoord.x;
    			_root["PInstance" + nDepth]._y = oCoord.y;
    			_root["PInstance" + nDepth]._rotation = _root.gun._rotation;
    			nDepth++;
    			nDelay = 5;
    		}
    	}
    };
    Mouse.addListener (oMouseListener);
    var oKeyListener:Object = new Object ();
    oKeyListener.onKeyDown = function () {
    	if (Key.getCode () == 49) {
    		nCurrentWeapon = 0;
    		nBarTicker = nBarTimeOut;
    	} else if (Key.getCode () == 50) {
    		nCurrentWeapon = 1;
    		nBarTicker = nBarTimeOut;
    	} else if (Key.getCode () == 51) {
    		nCurrentWeapon = 2;
    		nBarTicker = nBarTimeOut;
    	}
    };
    Key.addListener (oKeyListener);
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  3. #3
    Senior Member
    Join Date
    Aug 2005
    Posts
    225
    ill try it out. thanks

    EDIT: i got it working. thanks again
    Last edited by helpmeplz; 07-04-2006 at 07:01 PM.

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