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.
Printable View
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.
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);
ill try it out. thanks
EDIT: i got it working. thanks again