Home » Actionscripts library » Key Object
|
Anti Flood Protection
//anti flood protection for on key enter s = new Object(); s.onKeyDown = function() { if (Key.isDown(Key.ENTER)) { do_link(); } }; Key.addListener(s); function do_link() { // Your other actions... antiflood(); } function antiflood() { btn.enabled = false; Key.removeListener(s); var c = 0; temp = setInterval(function () { if (c++>2) { clearInterval(temp); Key.addListener(s); } }, 1000); } Posted by: andi haas | website http://www.andihaas.de |
|
1) Place a dynamic textfield on your stage, name it 'output'. 2) Add the following actionscript to an MC: onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL)) {
_root.output = "The Control key is down!";
} else {
_root.output = "Not down!";
}
}
Heres another example which might suit your needs better, you shouldn't have to alter the code. It uses the key number instead so just copy & paste it directly into your actions panel: onClipEvent (keyDown) {
if (key.getCode()==17) {
_root.output = "The Control key is down!";
} else {
_root.output = "Not down!";
}
}
Posted by: No name | website http:// |
Well, say I wanted Ctrl-F as my combo to make my name appear
onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL) and Key.getCode() == 70) {
_root.name = "Jesse";
}
}
Posted by: Jesse Stratford | website http://actionscript.org/ |
// general keyTimer for amount of time
// the key is held down for in seconds
// (this example uses the arrow down key)
onClipEvent(load) {
startTime = getTimer();
}
onClipEvent(enterFrame) {
if(Key.isDown(Key.DOWN)) {
if(!timerStarted) {
trace("restarted");
startTime = getTimer();
timerStarted = true;
}
now = getTimer();
elapsed = int((now-startTime)/1000)
trace("Counting: "+elapsed);
}
if(!Key.isDown(Key.DOWN)) {
timerStarted = false;
elapsed = 0;
startTime = 0;
}
}
// add code to your favorite dummyclip for
// testing and give it a try :)
// ef#Flash
Posted by: SHiZNiT | website http://www.m39.net |
/*Create a Movie Clip (F8)draw your object that you want to move around.
Go Back to the scene and open up the actions window for your soon to
be moving object (If your using Flash MX the action screen should be down
at the bottom. once in the action Screen type the folloring- */
onClipEvent (load) {
moveSpeed=10;
}
onClipEvent (eventFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x+=moveSpeed;
} else {
if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
if (Key.isDown(Key.Down)) {
this._y+=moveSpeed;
} else {
if (Key.isDown(Key.Up)) {
this._y-=moveSpeed;
}
}
}
}
}
Posted by: Jack S | website http://www.angelfire.com/or3/intro |

