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




Code To Focus On Input Box (disable Keypress)?



is there a code that will disable key press all together or to focus on just the input box so that i can type with the space key (space is used to pick objects up in game not in use when this menu is open anyway).



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 09-30-2004, 09:46 PM


View Complete Forum Thread with Replies

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

Code To Focus On Input Box (disable Keypress)?
is there a code that will disable key press all together or to focus on just the input box so that i can type with the space key (space is used to pick objects up in game not in use when this menu is open anyway).

Focus On Keypress
When I use keypress listeners to control the animation and put the swf online I always have to click somewhere on the swf to activate the swf. Otherwise my keypresses aren't recognized. Is there any way in actionscript to give the swf focus so visitors won't have to click on the swf first before they can use the keyboard controls?

Problem With Focus And KeyPress
Hi,
I've two problems as follows: a movie plays until there is a text input, where a user have to enter a password. If the password is 1234, than the movie goes on. I want to focus the input box, so the cursor blinks when the movie stops, so the user knows where to type the code. I've tried with Selection.setFocus(_root.inputboks) with no luck

Other problem is that keyPress <"Enter"> is ignored. It ony will work with mouseclick..?

Here is my code from the button.

on(release, keyPress "<Enter>")
{
if(inputboks.text == "1234")
{
gotoAndPlay(18);
video_movie.gotoAndPlay(4);
}
else
{
wrongcode.text = "Wrong password...";
}
}

Regards
Luxo

Getting Text Field To Focus On Keypress
Work on a standalone flash app in Flash 8. Here is what I want to do.

When (for example) F2 is pressed, I want a dynamic text field inside a movie file to come into focus so that any keyboard input will be loaded into an array and when F3 is pressed that text will dump into the text field for display. Text is not to show UNTIL F3 is depressed, but ALL keyboard input is to be captured after F2 has been pressed.

Now I could have it fill an array and when F3 is pressed the array is pointed to the text field.

Or have the text field nonvisible and type away filling the now focused dynamic box and made visible when F3 is pressed.

Lemme ghost code what I'm trying to accomplish. Ignore the fact that this won't compile, I'm doing it in psuedo-english/code to illustrate what I'm getting at

Assume:
movie file name 'textBox'; its instance name is 'textBoxInstance'
inside movie 'textBoxInstance' is a dynamic text field, var name 'displayText'
'keyCapture' is string array to capture keyboard input

//version 1


key.isDown(F2){
while(key.isDown != F3){
keyCapture[] = crapImtypingrightnow
}
else{ //oh look I hit F3, dump that stuff into the text box!
_root["textBoxInstance"].displayText = keyCapture[];
}

ver 2

key.isDown(F2){
//text box is hidden till I hit F3
while(key.isDown != F3){
_root["textBoxInstance"].displayText.visible = nein
_root["textBoxInstance"].displayText = crapImtypingrightnow
}

else{
//oh look I hit F3, all that text I just typed that was invisible is now visible
_root["theBoxInstance"].displayText.visible = damnstraight
}

all of this will be in a function so onLoad is not going to cut it. F2 will call the function, essentiall F3 will complete and break

help me out out wise ones of flash.

tanx.

KeyPress Question + Set Selection Focus
I'm trying to emulate the old computer feel in my flash file by having the user press any key to begin. I have my movie stopped at frame 1 and want the user to go to frame 2 only when he/she presses any key. It seems fairly simple in theory, the only way I can think of accomplishing that is to code the same function for every key on the keyboard. Any suggestions? Is there any way of replacing that h with an operator that means 'any key'?

----------------------------------------------
on (keyPress "h") {
    if (keyDown == true) {
        gotoAndStop (2);
    }
}

----------------------------------------------

I'm also trying to make an input text field have focus on screen so that keypress commands waiting in the mist won't be activated.
I applied the following coding to the movie instance with the input text field inside of it.:
----------------------------------------------
onClipEvent (mouseDown) {
    Selection.setFocus(urlinputbar);
}
----------------------------------------------

Any help for either of my problems would be much appreciated. Thanks

-Cardy



Thanks

-Cardy

Disable Keypress
Hi,

Is there a way to stop keyboard input? I have a game where a user moves an object on the stage using the arrow keys. I want the object to stop moving upon collision, but I don't know how to tell flash to stop accepting keypresses. Any help?

Thanks!

Scigolf

Bug? How Can I Disable The KeyPress On My Button
I have a button with the lable "keyButton_btn"
button code:

Code:
on (keyPress "<Right>")
fRight();
}
and a frame action that should turn off the button at a certain time
frame action:

Code:
keyButton_btn.enabled = false;
the problem is that while the press, release, rollOver, etc. all are disabled -- the keyPress is NOT disabled.

is this a bug? is there a way around this, other that being on a frame without the button?

thanks for any help

-mm

Disable KeyPress Repeat
Hello and thanks for maintaining this forum,

I am still learning a lot of the basics of action scripting. I have created a piano (like many before me) I used buttons instead of MC's for each of the keys on the piano.

I used this code for each key on the keyboard (there must have been an easier way, but this is how I did it...)


Code:
//This is to assign a sound to a variable
var lowC_sound:Sound = new Sound();
lowC_sound.attachSound("C3")
lowC.onPress=function(){
lowC_sound.start(0,0);
}

//This is the key press actions to control the white keys with the keyboard keys

on (keypress "a") {
lowC_sound.start(0,0);
}
THE PROBLEM...
If you hold down the "a" key it plays the note on the piano like rapid fire. How do I get the note to play one time even if the key is held down (like a real piano, ya' know?)

Another Problem
Is it possible to move the button to its down state when keyPress is called?

Thanks for taking the time to read!

Situation: Keypress Enable/disable
How do we enable/disable keypress/keypressess dynamically.

i.e. if button "one" is pressed the keypress of button "two" is disabled and viceversa.

How Can Disable F5 When The Flash Has A Focus
hi , i have a html file with a flash, and I can't refresh a page. How can disable F5(Internet explorer) when the flash has a focus

Disable Or Lose Focus On A Movieclip
Say I have a movieclip which i code to act as a button. Upon clicking this button, a transparent movieclip appears located over the original button movieclip. The onRollOver event on the lower, button movieclip is still re-acting to the mouse.

Is it possible for set the "focus" to the transparent movie clip? I guess I could code the onRollOver event to check if the other movie clip is shown before it runs the code in its event.

How Do I Trap 'enter Keypress' After Certain Presses And Disable Further Typing In Atext Area?
my textarea needs to be restricted to 16 lines no matter what. I have used the change listener and tried getting the number of 'enter' clicks. But how do i lock the textarea such that, the user cannot type anything further, but can edit what all he has written.

I can disable the textarea but this will not allow editing. Can anyone provide me with the thing i need? Hope the idea is clear.


Regards
Roshan

Changing Input Key, Keypress In TextInput
Hi to everybody,
i have a textInput component on my flash project, and i can type into it. when i press key "Z" it shows in the textInput as is it "Z", its normal. but i want to be written "3" when i press "Z".
i can do it in Delphi, width editbox's keyPress event's Key variable..
if Key='Z' then Key='3';
and it types into editbox. it is very easy. but i couldnt do it in Flash, also i am new to Flash..

Thanx,
Good day & works...
Ori...

Changing Input Key, Keypress In TextInput
Hi to everybody,
i have a textInput component on my flash project, and i can type into it. when i press key "Z" it shows in the textInput as is it "Z", its normal. but i want to be written "3" when i press "Z".
i can do it in Delphi, width editbox's keyPress event's Key variable..
if Key='Z' then Key='3';
and it types into editbox. it is very easy. but i couldnt do it in Flash, also i am new to Flash..

This code is OK but there is something; when i press Z in the textInput. its text is "Z3". i dont want to be Z is written when i press Z.. i want only 3 is written in to textInput. when the cursor in the textInput if i press Z input text is Z3
but if the cursor is not in the textInput then if i press Z the text is only 3.. it is good. but i want it with both situation..
how i can do it? with substr? or anything else?

ThankYou


onClipEvent(load){
// Define key code constants
var A:Number = 65;
var B:Number = 66;
var C:Number = 67;
var D:Number = 68;
var E:Number = 69;
var F:Number = 70;
var G:Number = 71;
var H:Number = 72;
var I:Number = 73;
var J:Number = 74;
var K:Number = 75;
var L:Number = 76;
var M:Number = 77;
var N:Number = 78;
var O:Number = 79;
var P:Number = 80;
var Q:Number = 81;
var R:Number = 82;
var S:Number = 83;
var T:Number = 84;
var U:Number = 85;
var V:Number = 86;
var W:Number = 87;
var X:Number = 88;
var Y:Number = 89;
var Z:Number = 90;

myListener = new Object();
myListener.onKeyUp = function(){
var key:Number = Key.getCode();
if(key == Z){
_root.t.text = _root.t.text + "3";
}else if(key == A){
_root.t.text = _root.t.text + "78";
}else if(key == S){
_root.t.text = _root.t.text + "ASDF";
}
}

Key.addListener(myListener);
}

Thanx,
Good day & works...
Ori...

Input Focus
How to make input always in focus ??? help me please

Set Focus In Input Box
I want to be able to set the focus automatically in the next input text box when they click the button....can someone tell me the code for this? thanks

Set Focus In Input Box
I want to be able to set the focus automatically in the next input text box when they click the button....can someone tell me the code for this? thanks

KeyPress And OnLoad="window.focus()"
I've searched through the threads and found some very helpful information on getting the browser to focus on the swf in order for keypresses to work without having to mouse click on the movie first BUT... I still can't get it to work! I'm at witts end, right next to jump off pass...
Please, if any one with experience with this could take a moumnet or two to help or point me in the right direction to find help I would really appreciate it.

thanks in advance!

dave b

Focus On Input Text
Is it posssible to set frame action to focus on input text box?

Focus On Input Text
Is it posssible to set frame action to focus on input text box? I want user to be able to start writing inside that text box as soon as frame is loaded.

Thanks

Set Focus To A Input Field
Hi,
I just want to set focus to a input field with variable name "n" with the following script. But fail.
What's wrong about it?


Selection.setFocus( n );


pls help
thanks

denis

Focus On Input Textfield
I've made some kind of form with a couple of input textfields. Now, what I want is that the first input textfield is active from the start so users can start typing right away without having to select the first input field first. Is this possible??

How To Set Focus On A Text Input Box?
Hi ya all,

I am making a flash movie for a web page. I have a text in put box. I want it so that when I click a button it automatically sets focus on the text field and place’s the cursor in the in put box at the end of the text that is in the text box. I would normally use:

On (press){
Selection.setFocus("nickname");
Selection.setSelection(length(/:nickname), length(/:nickname));
}
with the text box name being like "/:nickname"
and with a instance name like "nickname"

witch would normally place focus on the input box and place the cursor at the end of what ever text was in the text input box. How ever I am using flash player 7 action script 2, which means I can not use the “:/nickname” as “;/” doesn’t work in action script 2. Also the “ Selection.setFocus("nickname"); ” doesn’t seam to work either. Can some one tell me what code I need to set focus on a text input box and put the cursor at the end of the text that is in the input box please?

I also tried the tab index order method

this.Name.tabIndex = 0;

But with no luck, can any one please help me????????


Hope this all make sense lol

Cheers in advance
Rabid Lemming

Input Focus Area
Hi.
I have input fields set up in their own movie clips so that when the movie clip is clicked, it goes to another frame where the background color is different.
However, when clicked, the frame changes but the input area is not focused. For some reason the input field is not being recognized as being clicked. It must have something to do with changing frames instead of just directly clicking on the field. What actionscript can I program to get this to work.

Attached is the .fla

Thank you!

Set Input Textfield Focus.
I want to set focus on input textfield in flash Mx 2004 i.e. active cursor will display in it.

in flash Mx Selection.setFocus ("my_Txt");

code working properly but it not support Mx2004

can anybody provide solution.

thanks

Setting Focus To An Input Box?
I have created this function


ActionScript Code:
function init() {
Selection.setFocus(typeText);
}

This is setting the focus to the typeText instance, however, I have two issues:

1) It is focusing on the second char within the input text field

2) Is it possible to have it so that the cursor appears, having the same effect as though someone was to click on the input text field. Reason being the backspace key won't work.

Thanks for your input.

Set Focus To A Input Textfield
Hello i have a "stupid" problem...
in as 2.0 i used setFocus for give focus a my textfield input.
I have this situation:

MainApplication - (document class)


LoginInterface - Sprite (child of MainApplication)

Login - Sprite (child of LoginIntefac)

ok

within Login a create 3 input textfield

customer
user
password

I want set the focus to third field password.

I try FocusManager but i have error..

how can i resolve and give focus to password textfield?

Set Focus To Input Textfield
Hello i have a "stupid" problem...
in as 2.0 i used setFocus for give focus a my textfield input.
I have this situation:

MainApplication - (document class)


LoginInterface - Sprite (child of MainApplication)

Login - Sprite (child of LoginIntefac)

ok

within Login a create 3 input textfield

customer
user
password

I want set the focus to third field password.

I try FocusManager but i have error..

how can i resolve and give focus to password textfield?

Creating Focus On Input Text
I created three inputboxes on the same movie and i want the flash to put the focus on no2 which is name(variable) when it start.
how can i do this and to keep this field blinking and ready to edit at the run time?

Set Focus And Input Text Fields
I wrote a quiz that has 20 input text fields. Is there any way to set the order of focus when someone uses the tab button?

How Can You Focus After The Last Character In Input Text?
ok

im trying to set focus to an input text field

but i do not want to "highlight" the text
cause i need the color to remain green (00ff00)

so is there a way to set focus after the last character typed in by the user?

keeping in mind that the number of characters will vary from time to time
(might be 5 or 50 characters entered)

please let me know if this does not make sense

thanks a lot and free for all that help the capn

later
-c

Set Focus And Input Text Fields
I have 6 input text boxes. I have some buttons that I would like to have insert foreign text symbols into the last textbox to have focus.

I was using the following functions on a button...

myShuffle=sharedobject.getLocal("stuff");

function myFocus() {
mylength = length(myTextbox);
Selection.setFocus("_root.myTextbox");
Selection.setSelection(mylength, mylength);
}

function accentA() {
myShuffle.data.accenteda = _root.myTextbox+"á";
_root.myTextbox = myShuffle.data.accenteda;
}
On the button I put the following code...

on (press, keyPress "1") {
_root.accentA();
}
on (release, keyPress "0") {
_root.myFocus();
}


This works fine if I only have one textbox. But I don't know how to make it work if I have several. Any help would be appreciated. Thanks.

Focus And Input Text Boxes
I have 6 input text boxes. I have some buttons that I would like to have insert foreign text symbols into the last textbox to have focus.

I'm calling the following functions from a button...

myShuffle=sharedobject.getLocal("stuff");

function myFocus() {
mylength = length(myTextbox);
Selection.setFocus("_root.myTextbox");
Selection.setSelection(mylength, mylength);
}

function accentA() {
myShuffle.data.accenteda = _root.myTextbox+"á";
_root.myTextbox = myShuffle.data.accenteda;
}

On the button I put the following code...

on (press, keyPress "1") {
_root.accentA();
}
on (release, keyPress "0") {
_root.myFocus();
}


This works fine if I only have one textbox. But I don't know how to make it work if I have several and want the symbol to be placed in the last textbox to have focus. Any help would be appreciated. Thanks.

Focus Back To Input Text Box? How
1)I have a input text box and a push button next to it.
2)after clicking on the push button, i want the control to be back in the text box

How to achieve this.

Grateful if somebody can help

Input Text Clear When Focus
Hello.
I have to input feilds. Inside the feilds (through variables) I have "username" writen. How can I clear this feild when the user focuses on the feild?
In a frame script I have:

if (selection.getFocus() == _level0.loginPageMC.userTxt) {
userTxt = "";
}

and this is not working.
Any help?
Thanks in advance.
1M.

Setting The Focus To A Input Text Box?
Hi,
I am making a simple quiz, you read the question, answer in a input text box and press go. the answer is checked and you go to the next question.

how do i set it so that on each question/answer page the users cursor is automatically in the input field. rather than having to move the mouse and click in it each time?
thx
Lev

I Can't Lost Focus Of My Input Text
Somebody help me!!
Need a way to always send back the focus to input text when mouse
is down in other area of movie...

Focus Input Text Field
Hello,

In the attached movie I've got a simple input Text Field
I need that when the movie loads I will see the blinking cursur
inside the text filed and won't have to press it in order to write.
It will be focused.

Any help is needed

Zooming Input Textfield On Focus
Hi All

I am making one form in flash in which have good number of input textfield in it.
We all know that when we click tab, cursor switches to next input textfield.

What i want is that when movie publish the first textfield should come out marginally (get zoomed) with bigger font size and focus.

After entering text if user clicks the tab first textfiled should set back to the original( like other textfiled except nextone) size with small original font size along with the text that user have entered in zoom(or bigger) input textfield and next textfield should get bigger or zoomed similiarly like the first textfield again with focus.

this goes on and on.

Please help me out in this. Please also comment about my explanation skills. Was i comprehensive? Do i know well how to put a question.

I welcome your opinion. Thanks in advance.

Regards

AsiaMG

[F8] Remove Focus On Input Text
Hi all,

I have a little issue I can't seem to figure out.

I have a file with 2 scenes.

In the first scene the user can enter their name and email.

Then they submit it and go to scene 2.

When they click to go back to scene 1, the text in the name field is selected.

Is there any way to have it not be selected?

See the attahced pic for an example.

Thanks,
Tbone

Text Input Focus Issue
Looking to see if anyone has seen this issue:

I have an empty flash movie that loads an xml file and renders it to html. The xml file has the links to any media like jpgs and other swfs. Everything works fine except if I load a swf that has text input fields. In Firefox (and Safari), it simply won't let the user get focus of these text input fields to enter data. In IE windows, it works perfectly, but not Firefox.

If I load the swf with the text input fields by itself (as opposed to this xml setup), it works fine everywhere.

Anyone know of a fix for this? Btw, I'm working in Flash CS3 and AS3.

Input Text Focus Functionality
I have an input text box set to variable 'memail'. The text box has no instance name (not sure if that makes any difference).

When the visitor arrives on the 'page' the input box displays the text "please enter your email address".

When someone clicks on the textbox (i.e. sets focus to it) I want that text to clear, I guess by changing the variable:


Code:
memail = "";
My question is how do I detect that focus has been set to the text field. I guess I'm looking for something along the lines of:


Code:
on (setFocusToTextField){
memail = "";
}
Can anyone please help?

Kill Focus On Input Text?
so there must be a way - I've tried
Selection.setFocus(null) with no avail - anyone know how to stop that dreaded blinking cursor once you've clicked in the box?

ie:

I want to type in some text, submit it, but then, the cursor no longer blinks in that box. (which i assume would mean the focus is killed)

any ideas?


much appreciated as always!

Setting Focus To An Input Text
How do you set focus to an input text (like dynamic and static text, just inpu text)?

Lost Focus On Input TextField
I have this problem I'm unable to solve and I've been pulling my hair out. I'm creating an 'input' textField and I don't want to initially add any text into it so I set my_txt.text = ""; The problem is that if the textField is given no content I can also not select it to add content but if I add some blank spaces I am able to select the textField and type in some text. If you cut and past and run the script below you will see what I mean. Run it as is and then change my_txt.text = " ";

(I've got the Font linked in the Library. It works if there is text int he field)

Something else that might be related: When I set the font, colour or size of the input field, the type in some text, then change the formatting (colour, font), then select right at the end of the input box and type some more text it picks up the previous format settings so I have two different fonts in the textbox.


this.createTextField("my_txt", 1, 10, 10, 100, 40);
my_txt.border = true;
my_txt.multiline = false;
my_txt.wordWrap = false;
my_txt.autoSize = false;
//
my_txt.selectable = true;
my_txt.type = "input";
//
// set format
this.myTextFormat = new TextFormat();
this.myTextFormat.size = 12;
this.myTextFormat.bold = true;
this.myTextFormat.align = "left";
this.myTextFormat.font = "Arial";
this.myTextFormat.color = "0x000000";
// set text
my_txt.text = "";
// embed font
my_txt.embedFonts = true;
// apply formatting
my_txt.setTextFormat(this.myTextFormat);

How To Maintain Focus In Input Text Box?
I am a complete newbie with Flash MX, ActionScript, and everything in between. So here's my situation.

I want to make it so the user has to type in a password to move forward with the Flash presentation. When he presses OK, it takes him to further into the presentation (i.e. Frame 20).

On my login screen, I have a couple of layers that are animated. Thus, I need these animations to keep looping. So what did I do? At the end of the animation, I put in code to GotoAndPlay(1).

Now here's the problem... When someone's trying to type in the password, when it loops (Gotoandplay), the input box loses focus. To remedy this situation, for frame 1, I put in the code: Selection.setFocus("txtPassword").

What happens? Everytime it sets focus, everything gets highlighted in the input text field.

As you can imagine, it is a headache for anyone who is trying to type in the password because every few seconds, the whole thing gets highlighted and he accidently types over it.

Any suggestions?





























Edited: 12/03/2006 at 10:03:42 AM by AirDynamicAir

Input Field Stealing Focus
I have a problem with a project that I can't show, and I wasn't able to duplicate it in a simple example, so I understand if it's too vague to answer. But here goes...

What might cause a text input field to continually steal back focus? I have an input field that, once it has been clicked on, when you click anywhere else, it loses focus until you release the mouse, and it takes the focus back. Actually multiple input fields are behaving this way.

The biggest problem that it is causing is that when I click on a button, it works like it should, but then on button release, then button acts as if I am no longer hovering over the button, because the text field has stolen the focus.

Any Ideas? sorry I can't post the file

Focus Input Text Field
I'm trying to set up an email form within a flash movie. I want to have example text in teh input fields, but don't want the text to have to be deleted when someone clicks inside of the text field. I just need the text to disappear and the box to be emptied out.

Is there a way to do this in flash?

On Keypress + Variable Key Code
is there anyway of using the on(keypress "x") but instead of x having a variable.

I am trying to create 5 buttons that do exact the same thing but i want each one of them to be selected with a different key. So there has to be a variable that at the creation of each button will take a different value showing witch key to expect to be pressed.

Thx in advance

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