Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Capturing Keystrokes On A Web Page



Old problem.

Is there a solution for a flash game loosing focus while it is embedded in a web page?

In the game we use the arrow keys to manuver a character around a room but if the user clicks outside the flash game stage the game looses focus and the arrow buttons no longer move the character unless we click back on the flash game stage within the web page.

Has anyone resolved this issue or have a work-around?

Cheers.



FlashKit > Flash Help > Flash General Help
Posted on: 01-28-2004, 08:36 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Capturing Keystrokes
I have a flash movie that captures the keystrokes but when the movie is posted, a la html embed, the user has to click on the page before the flash movie will capture the keystrokes. Does anyone know how to make the page active without clicking it first, maybe some kind of onload focus thing...

SWF Transparancy And Capturing Keystrokes
Earlier I posted this:

>>onClipEvent(mouseDown){
>>if (Key.isDown(Key.CONTROL)){
>>this.startDrag();
>>}
>>}

>>Why wouldn't this work in my browser when it works fine >>if testing? Key.isDown(Key.CONTROL) never evaluates to >>true for some reason in Explorer...

Well I found the cause it's because I'm using the generated html with the 'window mode' option set to 'transparant windowless'. My SWF consists of several objects that I want to show floating above the html backgound image.

Is it not possible to capture keypresses and have a transparant background at the same time?!???

GP

Capturing Keystrokes; Using Modifier Keys
I want to create a shortcut using "Command-R" on the mac and "Control-R" on windows. I know how to capture a single keystroke (my code is attached), but how do I capture using the modifier keys?







Attach Code

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == 82) { // the "R" key is pressed
//code runs
}
Key.addListener(keyListener);

Capturing A Page's URL As A Variable In Flash
I have a dynamically launched jsp page that has an swf. Now depending on what the session id is for that page, I want my swf to display different info.

For instance, if my url is this:
"http://mydomain.com/content/my-portfolio/secure/showcase.jsp?id=5"

Note the "id=5" at the end? I want to be able to capture that as a variable.

Now I've tried this._url, that will only give me the path of the swf itself, which isn't what I want.

I also tried:

var host:LocalConnection = new LocalConnection();
trace(host.domain());

Which only gives me the superdomain, not the full url.

Is there a way to do this within Flash? Or would I be better off reading the session id from the jsp page, using the loadVar method or something?

Any help is always appreciated.

Thanks
Chris

Help Capturing Audio/video On Web Page
This sounds like something obvious but i CANNOT find an answer anywhere, so advice very much appreciated.

I simply wish to have a web page an on that web page i want to have a button saying "capture audio". On click this, the user could speak into his microphone and *somehow* what he says ends up on my central server (as some usable format). Imagine a web page with a "leave me a message" option which i could play back later to find out what people said (this isn't what i am trying to do, just a sample).

Can someone point me in the right direction - articles, sample and so on.

thanks,
steven

Help With Keystrokes Please
I am working on an application that uses TABs to go from field to field. I would like to make this happen with ENTER or TAB... Does anyone know how to make Flash TAB when it you press ENTER.

Thanks in advance for your assistance...

Collisions Using Keystrokes
Can someone give me the Script to let me create a movie clip collision detector? It all sounds easy, but I want the 2 movie clips to collide when they are moved using keystrokes.

Sending Keystrokes To VB
My flash movie is in a VB 'container' and I need to pass Alt-G to the VB application in order to click a particular button in the VB application.

Has anyone any ideas?

Multiple Keystrokes
Heya, guys.

I'm making a flash movie that requires users to enter in a three didget code, and I'd like to do it in one frame using scripts.

Basically, I've searched for the keystroke reading scripts, and have found only ones that wait for one specific button before proceeding. However, what I need is for, perhaps three buttons which must be activated in the correct order so that the flash movie may continue.

For instance, a user sits at the start of the flash movie, and if he knows the three-digit code, he can press the three numbers, say, 2 4 6 in that order, and the flash movie will gotoandplay the next frame, and hence the rest of the movie.

Is this possible? I'm guessing that I'll have to declare a variable and have the buttons which catch the keystrokes add to it, and a loop that checks if the number is == 3 (if it counts sequentially) ad when it does equal 3, it goes to the next frame.
Howver, I don't know enough about the scripting side to know where to declare this variable, and even if I did; how on earch to I stop people from typing in the numbers 1 through 0 three times until they unlock the code by default??

Fortunately, I need no on-screen evidence of the correct keystrokes.

Is it feasable to capture all of the numerical keys but have only the correct three, in the correct order actually operate the movie?

Should I just use three frames and hope that people don't realise that the animations are being reset every time they press the correct button?

What would you do in this situation? All help and advice (especially code!) is greatly appreciated.

Thanks.
--Rico_Stallion

Help Counting Keystrokes Per Second
ok i am trying to make a game that needs the user to press a button as quickly as possible, i would like to give then a speed or how many times they pressed the button in a minute. any suggestions

Detecting Keystrokes Please Help
Just another quick ActionScript question from a newbie!

In my project, I have a list of options, each assigned a letter. I prompt the user to hit a corresponding letter to continue to the desired pages, which are specified in the timeline with a labeled anchor frames.

I was hoping someone could help me out with the coding for detecting specific keystrokes. I need it to end with gotoAndStop("nextpage") for each letter. Maybe just show me how to do the code for the first two letters and I'll take it from there!

I've been messing around with AS, but I haven't been able to get this to work!

I appreciate your help!

Keith

Retricting Keystrokes.
How can i restrict my HTML forms to stop characters like:

:!@;.,`"'[{,etc,etc

Sorry I just realised i posted this in the wrong section. Can someone move this to Scripting and Backend please?

Not Sharing Keystrokes
I'm loading a swf that has keyboard eventlistener. However I want the base swf to capture the keystrokes rather than the loaded swf capturing them. Is there a way to 'get in first' and capture the keystrokes before the loaded swf does, or at the very least 'share' reading the keystrokes with the loaded swf?

Raising Keystrokes
Hi Friend,
Is there any way to generate keystroke dynamically ? (as we do in vb using "sendKey()"), let me explain my requirement, i have to generate the keystroke automatically based on some events,
eg if User presses downarrow, i want to generate a "tab" key to make the next (tabindex) TextField to receive focus, i beleive u can understand what i'm comming to ask.

your help is much appreciated.

regards
Venkatesh.M

Capture Keystrokes
Anyone know how to go about capturing keystroke combinations such as CTRL + Key and ALT + Key? I know how to capture single keys but how would you capture these combinations?

Thanks in advance.

Disabling Keystrokes
I am creating a hangman type game. I have a textbox in which the guess is inputted to. How can disable the numbic and symbol keys so that they cannot be inputted to the box?

thank you

Disabling Keystrokes
I am creating a hangman type game. I have a textbox in which the guess is inputted to. How can i disable the numeric and symbol keys so that they cannot be inputted to the box?

thank you

Record The Number Of Keystrokes?
I need to be able to record the number of keystrokes.
Example:

Once the user has pressed and released any 6 keys or any 3 keys etc. move to another scene or label.

Please help,
Thanks in advance!!
Christian

Saving/ Showing Keystrokes
i have a graphic of a keypad.. either the user types on their keypad or they click the individual keys in the gui... in both cases, the associated key blinks and the text appears in the dynamic text box... the field is checked against an file to see if whats in the field is listed... if yes, an mc plays elsewhere in the scene, if not, a different one plays and the field clears...

question... how do i get each key (button) to write an associated stroke to a dynamic text box? eg: the user clicks/types the letter R, that R comes up in the box.

theres more but i think ill stop here...


YT
TCSP

Using Keystrokes To Navagate A Movie?
I'm trying to make keyboard controls for a flash movie, so when someone presses the down button it'll skip to frame 600, for instance. I've tried a couple things that don't work, so I'm looking for help on this one.
Thanks

Is There A Tute On Keystrokes And Txtboxes?
Hi, I'm having a real problem understanding how to get this to work.
I have 2 textboxes input_txt and display_txt.
The text I want is "The cat", when text is entered (input_txtx) it it shown "as is" in the display_txt (eg *t? c@#). If kid wrote The cat we go to next frame, if not new frame shows the dispay text now in the input_txt to be edited until correct.
thanks,
ja


onClipEvent (keyDown) {
trace(String.fromCharCode(Key.getAscii()));
};
//the corresponding letter output when you press a keystroke except function keystrokes.

input_txt = 'The cat';
display_txt = '';

input_txt.addEventListener(TextEvent.TEXT_INPUT,on TextEntered);
function onTextEntered(event:TextEvent):void {

}

input_txt.addEventListener(Event.CHANGE,onChange);
function onChange(event:Event):void {

display_txt.text= event.target.text;

}



keyListener = new Object();
keyListener.onKeyDown = function() {
if(display_txt == "The cat"){
gotoAndStop(3);
}else if(display_txt != "*?????? c?t")// shows what the kid put in {
gotoAndStop(4);
input_txt = display_txt;
}

};
Key.addListener(keyListener);
Selection.setFocus("input_txt");
stop();

Triggering Animations With Keystrokes
Ok so im trying to make a small program on flash where the user presses a letter a-z and an animation pops up on the stage in a random position does its animation then disappears

So i can do the rest will someone tell me how to do it for 'A'

The moviclip i want to animate is called 'A' i want the user to press A on the keyboard so that movieclip 'A' appears in a random position and animates.

Can someone please help
Cheers

Detecting Keystrokes From Within A Class
Hello again. I seem to be permently on here at the moment. Trying to do advanced things thats the trouble. I have started to try and program "properly" in flash which means using classes. i have a class file and this is imported into an fla file. in the fla file i create some objects from this class. 1 thing the class does is it has a movieclip inside it (which is passed in the constructor)and this movieclip is assigned onpress and onrelease methods. but i also want the movieclip to do something when the space bar is pressed. i have tried to implement this by adding the movieclip as a listener to the Key class. but the strange thing is it will only then do 1 line of my code in the onKeyDown function of the movieclip. it won't do a function if i put that inside the onKeyDown function. my code is below. shape is the movieclip. before now i have detected keystrokes by using onClipEvent (enterFrame) but this has to be on the movieclip itself (i think) and i am trying to get around duplicating code. any help would b much appreciated.

trigger2160







Attach Code

shape.onKeyDown = function() {
keyDownShape();
};
Key.addListener(shape);

Registering Keystrokes Remotly
Hi. My friend has designed an application in java using sockets enabling keypesses to registered when paired with a mobile phone via bluetooth. The only problem is the game is pretty crappy. i was wondering if there was a way to register these keystrokes in a flash application using the existing socket codes, and if so, where i could find a tutorial or actionscript snippet?

Document Key Keystrokes Not Being Picked Up
Hey,

I have a little application running and I want the Page Up and Down Buttons to do something when pressed. For some reason though, when I am testing the movie and I press the buttons nothing will happen. I can't even trace anything...

It seems to be the case with all of the "Document Keys" (Home, End, Delete, PgUp, PgDown), but not with any of the others... anybody have any ideas on why this would happen?

Thanks,

--D

Keystrokes Keypress Key Down. THEY DONT WORK
ARGH! Has anyone figured out how to get around the issue of having to click on the screen to get flash to register keystrokes? In the flashplayer app. clicking on the screen is not required, but it seems the browsers force you to click on the flash movie before any keystrokes are registered.

The old WDDG (brown site) used a keystroke "hit space to skip intro" and you didnt have to click on the screen. Hey James Baker!!! How did you do it???

/ tom ajello
Modem Media

BTW : Im launching a HUGE site in one week. Keep your eyes pealed!!!!

/ t

How Do I Detect Multiple Simultanious Keystrokes
Does anyone know if it is possible to detect multiple simultanious keystrokes?

For example:

I want to detect if someone is holding down the following keys all at the same time:
B A D

This would be give the user access to an area without a password.



Thank you for any help, in advance.

Keystrokes Bring Movie To A Halt?
I have a movie - big movie - lots of scenes and menus to navigate around it - published an an exe

Now the customer says that when they press Control and Enter whilst it's playing it brings the movie to a halt and then it jumps around randomly from scene to scene. Testing I just get it to stop and start a few times.

My initial response was why on earth would you want to press control and enter anyway - but they seem to think any user could do this!!!!
Has anyone run into similar problems? Is there a way to disable keystrokes whilst this is running - so long as the user can use a mouse then thats all they would need? I can only find info on disabling keystrokes whilst in test mode, but this would have to work once published and out in the big wide world.

I would be really grateful for feedback - even if it's only to say I can't do anything to help the problem!

Changing Movie Clips On Keystrokes
Hello,
Does anyone know how to change a movie clip to another movie clip, once that a directional button is clicked. In other words how to change a movie clip from a previous one that is being controlled. I know it has something to do with the IF function, but how can you change the current Movie Clip to a specified one. This would be really helpful thanks!



He lives in a distant mind...

Loading Multiple Movies With Keystrokes
I have a movie with a blank mc on the stage. I have it set up so that when you press the RIGHT keyboard key it loads another movie in that mc. Here's the code for that:

Code:
stop();
this.onKeyDown = function() {
if (Key.getCode() == Key.RIGHT) {
loadMovie("ball.swf", blank_mc);
} else if (Key.getCode() == Key.LEFT) {
gotoAndPlay(2);
}
};
Key.addListener(this);
If I have more than one movie, how do I code it so that when I press the RIGHT key again it loads another movie as well as goes back when I press the LEFT?

Changing Movie Clips On Keystrokes
Hello,
Does anyone know how to change a movie clip to another movie clip, once that a directional button is clicked. In other words how to change a movie clip from a previous one that is being controlled. I know it has something to do with the IF function, but how can you change the current Movie Clip to a specified one. This would be really helpful thanks!



He lives in a distant mind...

Monster Game Needs To Be Able To Reuse Keystrokes(I Think)
Hello. Right I have game that I'm making called Happy Monster Island. So far it works great a title screen comes up with a flashing press start message you hit space then a menu appears with options you hit A and the game starts then you start hitting X and you can skip through all these bubbles.
Everything works the way its supposed to(there's even a cool FF7 noise when you skip the text bleep bleep it goes!) but I've come to a point where the user has to make a choice to go one way or the other and I can't do that. Because all the keystrokes actually do is advance the main timeline one frame. Theres a movie clip on each frame which is sometimes just a picture. Previously I had been trying to jump to a certain frame and play but I had problems so I had the temporary solution of apply code to the whole thing to make these keys go next frame. So here's my code anyway. I can't use buttons because I'm porting it onto a system without a cursor(hopefully)
keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==32){
nextFrame();
}
}
Key.addListener(keyListener);

keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==65){
nextFrame();
}
}
Key.addListener(keyListener);

keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==88){
nextFrame();
MyEffect_sound.start(0,0);
}
}
Key.addListener(keyListener);

So I don't even know what my problem is to be honest but if I could have extra functions for the same keys in order or have actionscript only affect one frame or something I could have enough interactivity to get by.

How To Create A Moving Background According To User Keystrokes?
i'm totally a noob at actionscript. i just finished the GTA tutorial ( http://www.flashkit.com/tutorials/Ga...-878/index.php )and i would like to be able to create a background environment that changes along with the car movie clip, according to the speed and direction the user presses.

i've tried doing it myself for a while now, and rather than get frustrated and put it aside, i figured i would seek some help.

the script i'm using is identical to the tutorial.
.
thanks in advance

My Monster Hunting Game Needs To Be Able To Reuse Keystrokes(I Think)
Hello. Right I have game that I'm making called Happy Monster Island. So far it works great a title screen comes up with a flashing press start message you hit space then a menu appears with options you hit A and the game starts then you start hitting X and you can skip through all these bubbles.
Everything works the way its supposed to(there's even a cool FF7 noise when you skip the text bleep bleep it goes!) but I've come to a point where the user has to make a choice to go one way or the other and I can't do that. Because all the keystrokes actually do is advance the main timeline one frame. Theres a movie clip on each frame which is sometimes just a picture. Previously I had been trying to jump to a certain frame and play but I had problems so I had the temporary solution of apply code to the whole thing to make these keys go next frame. So here's my code anyway. I can't use buttons because I'm porting it onto a system without a cursor(hopefully)
keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==32){
nextFrame();
}
}
Key.addListener(keyListener);

keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==65){
nextFrame();
}
}
Key.addListener(keyListener);

keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==88){
nextFrame();
MyEffect_sound.start(0,0);
}
}
Key.addListener(keyListener);

So I don't even know what my problem is to be honest but if I could have extra functions for the same keys in order or have actionscript only affect one frame or something I could have enough interactivity to get by.

Windows Vista / IE7 Missing Keystrokes In Flash
Hi,
I've had vista for while now and have a few online forms that while I'm typing it randomly drops keys. I've tried researching the issue, but I'm not coming up with alot of hits.
I don't have this problem in any other app except VIsta/IE7/Flash combo.

Thanks,
Mark

My Monster Hunting Game Needs To Be Able To Reuse Keystrokes(I Think)
Hello. Right I have game that I'm making called Happy Monster Island. So far it works great a title screen comes up with a flashing press start message you hit space then a menu appears with options you hit A and the game starts then you start hitting X and you can skip through all these bubbles.
Everything works the way its supposed to(there's even a cool FF7 noise when you skip the text bleep bleep it goes!) but I've come to a point where the user has to make a choice to go one way or the other and I can't do that. Because all the keystrokes actually do is advance the main timeline one frame. Theres a movie clip on each frame which is sometimes just a picture. Previously I had been trying to jump to a certain frame and play but I had problems so I had the temporary solution of apply code to the whole thing to make these keys go next frame. So here's my code anyway. I can't use buttons because I'm porting it onto a system without a cursor(hopefully)
keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==32){
nextFrame();
}
}
Key.addListener(keyListener);

keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==65){
nextFrame();
}
}
Key.addListener(keyListener);

keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==88){
nextFrame();
MyEffect_sound.start(0,0);
}
}
Key.addListener(keyListener);

So I don't even know what my problem is to be honest but if I could have extra functions for the same keys in order or have actionscript only affect one frame or something I could have enough interactivity to get by.






























Edited: 02/23/2007 at 05:01:29 AM by Nicodemus36Q

Key Capturing
Does anyone know how I can detect from the user a specific key press and a mouse click TOGETHER. IE:

if(Key.isDown(Key.SHIFT)&&(mousedown.isDown){
do something;
}

The mouse trapping is the part that is confussing me:
mousedown.isDown ?

Capturing F10
I am trying to capture f10 using

keyListener.onKeyDown = function() {
if (Key.getCode()==121) {
//it's a f10
_root.vFILTER=10;
_root.txtFILTER.text="10";
}
}

but f10 is the only function key that fails. It seems it is used to access
menus. From searching around it seems it is not possible but many of these
posts are quite old. Could anyone clarify if this is possible.

Many thanks

Capturing Key Press
while it's easy in Flash 5, what is the best way to capture key presses in 4? I am trying to capture the Ctrl, Alt and Tab keys.

Thanks

Capturing _x _y Variables
on the root time line i have a big movie clip which contains 4 further movie clips. also on the root time line are four buttons, each corresponds to one of the small movie clips.

when pressed the other three movie clips are made invisible, the selected small movie clip is scaled to 200%, and is centred. this changes the _x _y position of the big movie clip

before zooming in, the big movie clip can be scrolled left right up down so how do i capture the _x and _y value of the big movie clip the second the zoom in and centre button is pressed, then use that captured _x _y variable in order to send the big movie clip back to the place from which it was called?

put another way, if someone scrolls the big movie clip to the right hand edge of their screen, when they select and centre onto on of the smaller clips, how do i make another button send the big clip back to the right hand side of the screen?

many thanks in advance

Capturing The Escape Key
Hello all,

Here's a really simple question (I guess) - I am really new to MX and am experiencing troubles to switch from flash 5...

Well, what used to be easy as a song has now turned (for me) into the dark pitchs of horror : I want to prevent any use of the ESCAPE key.

I am *clueless* on where to go from that : do I have to create a "listener" ? Where should I put it ??

Thanx for any help, and sorry for the low-level of my question (darn, to say I thought it would be easy to switch to MX!) ;)

Anik =:)

Capturing Keypresses
Does anyone know how to capture keypresses??? in a message window of some kind???

Keystroke Capturing
onClipEvent(mouseDown){
if (Key.isDown(Key.CONTROL)){
this.startDrag();
}
}

Why doesn't this work in my browser when it works fine when previewing? Key.isDown(Key.CONTROL) never evaluates to true for some reason in Explorer...

This is in Flash MX

Cheers,

GP
gp@1lg.com

Capturing Tab And Shift-tab?
Is this possible in flash mx?

I tried capturing 'tab' with a button and 'shift+tab' with a movie clip.

I've tried putting this code in a button:

[HTML]on(keyPress "<Tab>")
{
trace("HI");
}[/HTML]

But it looks like shift+tab activates the trace instead. (Anyone know why?)

I also tried this for the shift+tab movieclip:

Code:
onClipEvent (keyUp) {
if (Key.isDown(Key.TAB) && Key.isDown(SHIFT)) {
//(Shift+TAB)
trace('testing');
}
}


Unfortunately the code above does nothing.

Capturing CTRL+S?
I am trying to capture ctrl+s for saving in my swf.... but i cant seem to capture any other kepresses when CTRL is being pressed, therefore i cant detect ctrl+s.... I can detect s+ctrl but not vice versa.... any ideas?

Capturing Flash And SWF - Please Help
Is there a program that would allow me to capture the footage of me playing a flash game? Would that be a screen capture program or is there an easier way? I've tried using Fraps but it doesn't seem to work with Flash players. Thanks in advance!

Capturing Variable Name?
Hi,
I'm passing a variabe to a function and want to know the name of the variable being passed to the function. Say something like this:

Code:
var blinky:Array = new Array("bar1", "bar2");

function foo(thisVar:Array) {
//trace the name of thisVar (should output 'blinky')
}

foo(blinky);
How would I go about making the trace statement?

Any help appreciated.

Capturing Two Or More Keypresses
Hi! I have a code that captures keypresses. It works ok if only one key is pressed but I need to capture multiple keypresses. Like ctrl + shift.

I tried using a AND (&&) statement on the if then else statement but it doesn't work. Here's my code:

PHP Code:



_root.createEmptyMovieClip("mc1", 1);
with(_root.mc1)
{
    someListener = new Object();
    someListener.onKeyDown = function () 
    {
        if(Key.isDown(Key.UP)) 
        {
            trace("up");
        } 
        else if (Key.isDown(Key.DOWN)) 
        {
            trace("down");
        }
        else if (Key.isDown(Key.CONTROL) && Key.isDown(Key.UP))
        {
            trace("Up and Down");
        }
    }
    Key.addListener(someListener);





I would greatly appreciate some help on this. Thanks in advance.

Capturing A Duplicate MC
Does anyone know if its possible to identify which "duplicated movie clip" someone has clicked on?

In other words, if 100 movieclips are duplicated and named individually as
"mc"+i (where i=1 to 100) and someone clicks on a specific mc, how do you capture which one it was?

It's really frustrating me now, and I'm getting to the stage where I think it may not be possible.

Can someone let me know, before I waste another 6 hours.

Cheers

Copyright © 2005-08 www.BigResource.com, All rights reserved