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




Key Listener Trouble With DELETEKEY, BACKSPACE



Can anyone tell me why the following code detects DELETE key only AFTER another key has been pressed? Any way to get around this peculiarity?

Code:
list = new Object();
list.onKeyUp = function() {
if(Key.getCode() == Key.DELETEKEY) {
trace("The delete key was released");
}
trace("key " + Key.getCode() + " was released");
}
Key.addListener(list);



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-03-2004, 11:28 PM


View Complete Forum Thread with Replies

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

[F8] Backspace Not Invoking Listener (Key.isDown(Key.BACKSPACE))
So I wrote some script on a computer running MacOS X (with Flash CS3 if that makes any difference, though it was AS2.0 and saving as a Flash 8 file), and it worked fine.


Code:
listener.onKeyDown = function():Void {
if (Key.isDown(Key.ENTER)) {
play();
} else if (Key.isDown(Key.BACKSPACE) && count > 0) {
--count;
removeMovieClip(stack[count]);
if (count % 2 != 0) {
movebacks--;
for (i = 0; i < count; i++) {
stack[i]._x += 15;
}
}
//breaks off here and the rest works
I bring it home and try to work on it some more, running Windows XP (and Flash 8), pressing backspace doesn't invoke the listener. I can get it to work if I hold shift though (or ctrl) and hit backspace.

Funny thing is, if i make a button that fires on key press of backspace (using on (keyPress "<Backspace>") ), same thing; needs two keys to detect it.

I heard that ASnative(800, 0)(8) would do the trick, but it didn't.

How might I go about doing this?

Trouble With Listener / LoadVars Mechanism
I'm building a fairly simple dynamic photo gallery script with PHP and MySQL. The variables are loaded using loadVars, images are loaded into movie clips stacked on top of one another, and the back / next buttons change the _alpha on the stack of images to "switch" between them. This much of the script works fine - it's when I try to replace the existing images with a new set.

The way I want users to be able to toggle between projects (the images are organized by project) is by a pulldown menu component. The pulldown populates, functions and displays correctly.


PHP Code:



for (i=1; i<=imageinfo.total_projects; i++) {
    project_id = 'project'+i+'id';
    project_title = 'project'+i+'title';
    pulldown.addItem({data:imageinfo[project_id], label:imageinfo[project_title]});
}
var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object) {
    trace("Newly selected project: "+evt_obj.target.selectedItem.data);
    _root.selected_var = evt_obj.target.selectedItem.data;
    _root.gallery_pics.removeEventListener("change", cbListener);
    _root.gallery_pics.gotoAndPlay(1);
};
pulldown.addEventListener("change", cbListener);
stop();




By the way, all of this is going on in _root.gallery_pics.

The actual problem occurs when I select a new project from the pulldown. I've got trace actions in place to see what's going on, but the movie goes into an infinite loop and freaks out. The listener sends the movie back to frame 1 - this is intended to delete the existing movie clips and unset the variables... I'm not entirely sure the latter part is necessary, but I'm pretty much grabbing at straws here.


PHP Code:



for (i=this.imageinfo.total; i>0; i--) {
    this['img'+i].removeMovieClip();
    trace('Deleting img'+i);
}
delete imageinfo.total_projects;
this.imageinfo.length = 0;
delete this.imageinfo;
delete _root.gallery_pics.i;
this._alpha = 0;
delete _root.gallery_pics.picStatus;
trace('Images and variables reset');
gotoAndPlay(2);




This frame seems to go through just fine. But when the script goes to frame 2, that's when the problem occurs.


PHP Code:



stop();
// Plays the movie once images are loaded
this.onEnterFrame = function() {
    _root.gallery_pics._alpha = 0;
    percent = (_root.gallery_pics.last_image.getBytesLoaded()/_root.gallery_pics.last_image.getBytesTotal())*100;
    if (percent == 100) {
        _root.gallery_pics._alpha = 100;
        _root.gallery_pics.play();
        delete this.onEnterFrame;
    }
};
// Loads variables
imageinfo = new LoadVars();
if (_root.selected_var == undefined) {
    // No project selected, load the latest
    imageinfo.load("http://bya.localhost/scripts/flash_gallery.php");
    trace('Loading latest project');
} else {
    // Load selected project
    imageinfo.load("http://bya.localhost/scripts/flash_gallery.php?project="+_root.selected_var);
    trace('Loading project number '+_root.selected_var);
}
trace('Begin onLoad');
imageinfo.onLoad = function(success) {
    if (success) {
        trace("Variables loaded");
        _root.gallery_pics.i = imageinfo.total_photo;
        trace('Total Photos: '+imageinfo.total_photos);
        // Loop to load images
        for (counter=1; counter<=imageinfo.total_photos; counter++) {
            this.imageName = 'img'+counter;
            this.imageLoc = this[this.imageName];
            trace('Image name: '+this.imageName+', Image location: /'+this.imageLoc);
            _root.gallery_pics.createEmptyMovieClip(this.imageName, counter+100);
            with (_root.gallery_pics[this.imageName]) {
                loadMovie('http://bya.localhost/'+this.imageLoc);
                _x = 33;
                _y = 108;
            }
            if (counter == imageinfo.total_photos) {
                _root.gallery_pics.last_image = _root.gallery_pics[this.imageName];
            }
        }
        _root.gallery_pics.i = _root.gallery_pics.imageinfo.total_photos;
        _root.gallery_pics.picStatus = _root.gallery_pics.i+' of '+_root.gallery_pics.imageinfo.total_photos;
    } else {
        trace("Error loading variables");
    }
};




The output window indicates that the script starts to hang during the onLoad event. It tells me the script is causing the movie to run slowly and asks me to abort.

The only thing I could imagine is that I'm doing something wrong with loadVars that I don't know about. Like maybe I shouldn't be trying to load new variables into the same object? Maybe I'm not deleting it properly? Can anyone help?

Trouble Removing An Event Listener
code below,

www.derekyadgaroff.info to see the problem.

when i mouse off of a street i want the beacon thing to disapear. i have it set up that once i am over the street to start the mouse move event listener. when i mouse out of a street i want to remove the listener and then put the beacon off the stage. help!!

package{

import flash.display.MovieClip;
import flash.events.MouseEvent;

public class streets extends MovieClip{

private var beacon:locationBeacon;

function streets(){
//just an offset
x= -141.9;
y=-178.8;

// like a "you are here" thing, when mouse is over a street
beacon = new locationBeacon();
this.addChild(beacon);

this.addEventListener(MouseEvent.MOUSE_OVER, attachBeacon);
this.addEventListener(MouseEvent.MOUSE_OUT, removeBeacon);
}

//when we mouse over a street, add a MOUSE_MOVE listener
function attachBeacon(mouseover:MouseEvent):void{
addEventListener(MouseEvent.MOUSE_MOVE, moveBeacon);
}

//move the beacon with the mouse
function moveBeacon(mousemove:MouseEvent):void{
beacon.x= mouseX;
beacon.y= mouseY;
}

//when we are no longer over a street,
//remove the MOUSE_MOVE listener, and put beacon off stage
function removeBeacon(mouseout:MouseEvent):void{
removeEventListener(MouseEvent.MOUSE_MOVE,offsetBe acon);
}

function offsetBeacon(m:MouseEvent){
beacon.x = -100;
beacon.y= -100;
}

}//end class
}//end package

Trouble With Listener, Using Arrow Keys
please help, I'm doing a presentation and i don't like the Flash Slide Show Template option. I'm having trouble with the listener for using the keyboard. I want to use the "RIGHT" and "LEFT" arrow keys, and it works!!!. but if you are on the first frame and press "LEFT" several times lets say 4 times, once you press "RIGHT", flash jumps 4 frames at a time. the same thing if you on the last frame and press "RIGHT" several times. How can i fix this? Thx.

C


ActionScript Code:
myKey = new Object();
myKey.onKeyDown = function() {
    if (Key.isDown(Key.RIGHT) && (_currentframe < _totalframes)) {
        trace("right key");
        _root.gotoAndStop(_currentframe + 1);
        trace(_currentframe);
    }else if (Key.isDown(Key.LEFT) && (_currentframe > 1)) {
        trace("LEFT key");
        _root.gotoAndStop(_currentframe - 1);
        trace(_currentframe);
    }
   
};
Key.addListener(myKey);

Trouble Removing Event Listener Function
Hi,

I am stretching a rectangle with an enter frame event, but I sometimes would like to interrupt it before it has reached its destination. Therefore, I simply want to remove that listener, and then add a new listener that will shrink it. However I can't seem to remove a listener, except within the nested listener function, itself. Code attached (stripped down for clarity), thanks.











Attach Code

private function stretchRect(rectIn:org.moock.drawing.Rectangle){

if (rectIn.hasEventListener(Event.ENTER_FRAME)){
trace ("it has a listener");
// we get here, but this fails to work
rectIn.removeEventListener(Event.ENTER_FRAME, listener1);
rectIn.removeEventListener(Event.ENTER_FRAME, listener2);
}

if (some condition)
rectIn.addEventListener(Event.ENTER_FRAME, listener1);
else
rectIn.addEventListener(Event.ENTER_FRAME, listener2);

function listener1 (e:Event):void{
if ( ! finishedStretching ){
;// stretch the rectangle
}
else
rectIn.removeEventListener(Event.ENTER_FRAME, listener1);
}

function listener2 (e:Event):void{
if (! finishedShrinking ){
;// shrink the rectangle
}
else
rectIn.removeEventListener(Event.ENTER_FRAME, listener2);
}

Backspace Key
tried getting a backspace thing to work but it's not for some reason

if(Key.isDown(Key.BACKSPACE)) {
s1 = s1.substring( 0, s1.length-10)
}

this is the code that i tried but it's not recognizing the backspace key. any suggestions?

thanks

paul

Backspace Key
Hello!
I'm a noobie... and I am wondering how to make the backspace key on the keyboard work so that it leads to the previous frame as each "page" of the site is on a different frame on the main timeline.

I've tried all sorts of things (eg. named anchors) but no luck so far. Do named anchors work in browsers on a Mac anyway?

Is there an easy way to set this up with action script?

I would greatly appreciate any help!

Backspace Key In Netscape 6
Anyone have a good work around for the known Netscape 6 bug relating to the user hitting the backspace key when in an editable or input text box???

(currently it takes the user back in the browser history- same as hitting the browser back button instead of erasing the last character they typed)

I have figured out that if I hit the Tab key it will stop the bug.?? Somehow it resets the focus.?? Just setting the focus of the first input box does not work. Its all about the Tab key.

Any idea how to get the Tab key pressed short of asking the user to press the Tab key before starting to fill out the form I am presenting them?

Cheers,

Jeremy

Backspace Bug In IE And 2004
Here is the app in a nutshell: It is a series of forms. It is timeline-based, because I found the screens-based application method in 2004 to be problematic. As you might expect, each "form" has its own keyframe. The app uses several WebServiceConnector components, some DataHolders, and a DataSet. For input, I used the new 2004 TextInput, ComboBox, and CheckBox components. When the user completes a form and clicks "continue", the data is sent to a web service for evaluation, and then the web service's response is displayed in the next form, along with more inputs for the user.

Here is the problem: The first couple of "forms" seem to be working perfectly. But when the user gets to Step 3, and hits the backspace key, the browser intercepts the command, and the HTML page refreshes. Of course, the movie restarts, and any data input by the user is lost. *It appears to be an IE problem; the error does not seem to occur in Netscape.*

Simulate Backspace
How would I simulate a backspace with a button click. Here is some code that I have been trying to use but it is not working.


ActionScript Code:
var txt_str:String = name_mc.input_txt.text;
   txt_str.substring(0, txt_str.length - 1);
   name_mc.input_txt.text = txt_str;

this is held withing a button... but for some reason isn't working the way I thought it would

Backspace Key Not Registering.
howdy

i was trying with textfield masking and came around a problem and that problem is that the backspace key is not getting registered. not fully, if you want the backspace key to register you have to click the textfield then only it will register. this is what i am doing.

Selection.setFocus(_root.passwordIB);
passwordIB.password=true;

passwordIB is name of the textfield. on the load of the movie i am setting the focus in the password field. how to make the text field recognise the backspace key.

Backspace Key Not Registering.
howdy

i was trying with textfield masking and came around a problem and that problem is that the backspace key is not getting registered. not fully, if you want the backspace key to register you have to click the textfield then only it will register. this is what i am doing.

Selection.setFocus(_root.passwordIB);
passwordIB.password=true;

passwordIB is name of the textfield. on the load of the movie i am setting the focus in the password field. how to make the text field recognise the backspace key without clicking again in the text field.

Simulate Backspace Key
I know this has to be an easy one!

I am simulating a finger pushing numbers on a keypad, based on what the user types, with the numbers displaying in a dynamic text field (never mind why I'm not using input text!). What I want to figure out is how to make the backspace key delete the last number typed AND make sure that the length property of the text field is shortened by 1 (because an action is triggered when the text.length == 8). The trace action works. I just don't get how to delete one character at a time.

I don't know how to do it! Here's my script so far. What do I put in the backspace function?


ActionScript Code:
watchKey = new Object();
Key.addListener(watchKey);
function moveHandAround() {
    watchKey.onKeyDown = function() {
        if (lockText_txt.text.length<=7) {
            if (Key.getAscii() == 48) {
                tweenHand(161, 361);
                lockText_txt.text += "0";
            } else if (Key.getAscii() == 49) {
                tweenHand(102, 312);
                lockText_txt.text += "1";
            } else if (Key.getAscii() == 50) {
                tweenHand(160, 312);
                lockText_txt.text += "2";
            } else if (Key.getAscii() == 51) {
                tweenHand(212, 312);
                lockText_txt.text += "3";
            } else if (Key.getAscii() == 52) {
                tweenHand(102, 256);
                lockText_txt.text += "4";
            } else if (Key.getAscii() == 53) {
                tweenHand(160, 256);
                lockText_txt.text += "5";
            } else if (Key.getAscii() == 54) {
                tweenHand(212, 256);
                lockText_txt.text += "6";
            } else if (Key.getAscii() == 55) {
                tweenHand(102, 200);
                lockText_txt.text += "7";
            } else if (Key.getAscii() == 56) {
                tweenHand(160, 200);
                lockText_txt.text += "8";
            } else if (Key.getAscii() == 57) {
                tweenHand(212, 200);
                lockText_txt.text += "9";
            } else if (Key.isDown(Key.BACKSPACE)) {
                trace("delete the last character");
                lockText_txt.text.length--;
            }
        }
    };
}

Backspace Button
I have a text field which allows to type any word. How to create button for backspace if the word had been typed
wrongly ?

Looking for code for the button.

TQ

Disable Backspace Key
I'm trying to figure out how to disable the backspace key on an input form. Or, I need to figure out why I can't type into an input field after I've backspaced(erased) all the characters?

Backspace Key Won't Detect...
If I put in some code like this...


Code:
this.onKeyDown = function():Void {
trace (Key.getCode());
}
Key.addListener(this);
...it doesn't detect anything when I press the backspace key, or the enter key. What is wrong? How do I detect these???

Backspace = Rewind
Code:
this.onEnterFrame = function(){
if(rewind == true){
prevFrame();
}
}
this.onKeyDown(Backspace) = function(){
rewind = true;
}

Code:
stop();
rewind = false;
this would be on the places I want it to stop.

I'm trying to work something out like this. This would be in the root playline.

Can't quite figure out what's wrong something with the onKeyDown doesn't work.

Backspace Key Won't Detect...
If I put in some code like this...


Code:
this.onKeyDown = function():Void {
trace (Key.getCode());
}
Key.addListener(this);
...it doesn't detect anything when I press the backspace key, or the enter key. What is wrong? How do I detect these???

Backspace Key Bug In MX 2004
Here is the app in a nutshell: It is a series of forms. It is timeline-based, because I found the screens-based application method in 2004 to be problematic. As you might expect, each "form" has its own keyframe. The app uses several WebServiceConnector components, some DataHolders, and a DataSet. For input, I used the new 2004 TextInput, ComboBox, and CheckBox components. When the user completes a form and clicks "continue", the data is sent to a web service for evaluation, and then the web service's response is displayed in the next form, along with more inputs for the user.

Here is the problem: The first couple of "forms" seem to be working perfectly. But when the user gets to Step 3, and hits the backspace key, the browser intercepts the command, and the HTML page refreshes. Of course, the movie restarts, and any data input by the user is lost. *It appears to be an IE problem; the error does not seem to occur in Netscape.*

Any ideas??

Get GetCode() For Backspace
hello,

the script below gives me the key codes for alot of keys except the backspace or delete key which are the ones I want.

Does anyone know how to get any of these codes?


ActionScript Code:
keyListner = new Object();
userInput = new Array();
keyListner.onKeyDown = function() {
    var lastKey = Key.getCode();
    trace("lastKey pressed "+lastKey);
}
Key.addListener(keyListner);

How To Deal With The BACKSPACE Key
I was wondering about how to be able to prevent a user efficiently from quitting a Flash movie by pressing the BACKSPACE key.

The problem occurs due to the fact that I open up a Flash movie and position the cursor into a textfield, so that the user can enter something. It happens that the user mistypes his name for example and that he then presses BACKSPACE in order to remove the last typed letter. In that case it can happen that the browser reacts (it doesn't happen always, but IE6 shows these problems often) and goes back to the previous page...

Does anyone know a way how to prevent this?

Artimidor

Backspace Key And Named Anchors
I'm trying to use named anchors in my site to make navigation better for the user. My problem is this:
I have a number of text boxes that the user is required to fill in. When they are typing if they hit the backspace key to delete a character (which most users will do) then the movie is moved as if they had pressed back. This is because backspace is the shortcut key for back.

Does anyone know a way of fixing this?

Creating A Backspace Button
This is a more specific post from one I posted previously....

I need to create a "back space" function for a variable. For example:

Variable = WORDS

I needa button that acts as a backspace which will have the following effect on the variable each time it is pressed:

Variable = WORD
Variable = WOR
Variable = WO
etc.

Any ideas?

[F8] Backspace For Dynamic Text ?
im makeing a dynamic input field
my code looks like this

Code:
on(keyPress "a") {
box.text += "a";
}
on(keyPress "b") {
box.text += "b";
}
on(keyPress "c") {
box.text += "c";
}
ect...

and i need a backspace code so it will delet the last thing typed
any ideas or is it hopless?

i attached the file im working on

thanks

Input Text Backspace
I've built a couple of forms in the last couple of weeks and some users (using IE 6.0) have told me that they can't use the backspace key in the input text fields. I tested it on my own system in FireFox, IE 6.0, and in the stand alone flash player and can't reproduce the problem. It's pretty tough for me to solve a problem I can't re-create so I was wondering if anybody else had run into this problem.

I really appreciate any help on this one.

Thanks,

--carriker

[CS3] Disable DELETE/BACKSPACE Key
Hello,
is there any way that I can disable the default DELETE and BACKSPACE key action in a textfield, if a certain condition applies?

Something like (pseudo code)....

onevent (keyboard)
{
if (key is backspace || key is delete)
{
if (condition) stopDefaultAction;
else allowDelete;
}
}

[CS3] Disable DELETE/BACKSPACE Key
Hello,
is there any way that I can disable the default DELETE and BACKSPACE key action in a textfield, if a certain condition applies?

Something like (pseudo code)....

onevent (keyboard)
{
if (key is backspace || key is delete)
{
if (condition) stopDefaultAction;
else allowDelete;
}
}

[shared Object] [listener] Attach Listener To SO?
Hi everyone,

I'm trying to build a simple sound control panel for voice-overs in an e-learning project.

I want to use one button to control whether or not users want sound played throughout the lesson.

Right now I'm using that button to write an SO that each audio file reads before playing anything. My problem now is if a user wanted to hear the audio after he or she has already entered the page. If a user clicks the audio-on button, it's simply changing the SO, not to be read until the next page and swf loads.

My initial thought was I could attach a listener to the SO, allowing Flash to interpret a change from OFF to ON and then start up the necessary sound files.

Would this work? I've searched and haven't found documentation for attaching listeners to SOs.

THANKS

KeyPress Not Working For Enter, Backspace, Tab
Hi all,
I'm trying to capture certain keypresses and this is working for any alphabets/numbers that I press, but not for Enter, Backspace, Tab etc. However, if I click the mouse once and then press enter the event is detected. Any idea how I can being to detect enter, backspace without having to click my mouse even once.

I am running the file in the Authoring Environment.

Here's my code

_root.onEnterFrame = function(){
trace(Key.getCode());
}

Any help with this would be greatly appreciated!!!

Thanks,
Diablo

Problem With BackSpace And Named Anchors
Can any body help me I have set named anchors thoughout my flash movie but i have a feed back form on one scene which has text input boxes. but if the users presses the backspace button on the keyboard to delete text in the text input boxes the movie jumps to the last named anchor.

Backspace Key In Text Input Boxes
My application is using the MX 04 TexInput component and the "conventional" text input boxes. When the cursor is inside the component or text box, and the user hits the Backspace key, the browser refreshes! Needless to say, this can have disastrous consequences for any app built in MX 04.

Does anyone know of a fix for this?

Please help!!!

Creating A BACKSPACE For Clickable Keyboard
Thanks in advance for helping out,

Heres my current problem, right now im making a clickable keyboard that pops up on the screen, you can either type or click the letter
you want to go in next, the best part is you dont need to click the field for it to allow you to start typing.

however heres the code im using...

---------------
on (release, keyPress "a") {
savename = savename add "A";
}
on (keyPress "A") {
savename = savename add "A";
}
---------------

this code adds the letter a to the end of the text field... pretty simple

this makes the letter that pops up in the "savename" textbox capital nomatter what which is also awesome.

heres the fun part...

i managed to code the clear all button to erase everything in the box at once... but how to i backspace only the LAST KEY HIT??

i tried these...

----------------
on (release, keyPress "Backspace") {
savename = savename subtract last

on (release, keyPress "Backspace") {
savename = savename sub
----------------

but none of these are working... i cant get anything to work for a backspace...

any ideas?

for a faster reply you can also message me on AIM with the username IIXclintII

any help is much thanked.




-Clint Remley-

Backspace In Phone Number Textfield
I have a text field that when numbers are entered they format to look like a standard telephone number (XXX)XXX-XXXX using the following code.

_root.txt2.onChanged = function() {
var phonevar = this.text;
if (txt2.length == 3) {
var temp = "("+this.text+")";
this.text = temp;
Selection.setSelection(txt2.length+1, txt2.length+1);
} else if (txt2.length == 8) {
this.text += "-";
Selection.setSelection(txt2.length+1, txt2.length+1);
}
}

I'm having a problem when the user goes to backspace.. once they get to where the dash or parenthesis is inserted it won't let them delete anymore of the text.

Can anyone help me with this problem?

[F8] Backspace In Flash 8 Virtual Keyboard
Hi, I have created a simple virtual keyboard which includes Shift, spacebar and enter function. I just can't see the backspace to work.

My textbox is dynamicaly and has the var "display".
I tried for example

Code:
btn_bspace.onRelease = function () {
display = display - a;
};


But the a did not dissapear, strangely the code display = display + a does add an a. Is there another way to remove a singel character?

I was thinking of remembering the last character in a SOL. For example:

Code:
btn_a.onRelease = function () {
if (shift.data.name == undefined){
character.clear();
AddDigit("a");
character.data.name = "a";
character.flush();
} else {
character.clear();
AddDigit("A");
character.data.name = "A";
character.flush();
}
};



For those interested in seeing the source, I have attached the fla in a zip (125kb)

If someone likes the idea of a virtual keyboard and has an idea of how to solve the backspace issue, it is much appreaciated if you could help me out with this.

The purpose of the (non comercial) virtual keyboard is to prevent keyloggers from loging key strokes. There are java script keyboards but than the source is readable for key loggers and they will be able to read the names of the buttons pressed.

Kind regards,
Sebas.

Backspace Form Input Without Keyboard?
I need to allow backspace functionality in a form that's run on a kiosk so there's no keyboard - inputs are entered via touchscreen. Adding characters and clearing the field alltogether is already there, but I can't figure out how to backspace to remove one character at a time

here's a snipet of what's going on:
BUTTON "M":
on(release) {
inputone = inputone + "M" ;
timer.gotoAndPlay(1);
}

CLEAR:
on(release) {
inputone = "" ;
timer.gotoAndPlay(1);
}

inputone is the variable that is sent to the database

Any advice would be greatly appreciated.

Backspace And Delete Keys Not Working
Hi...

I have a input textfield in which sometimes, the 'backspace' and 'delete' keys are not working. Please tell me why this is happening?

Thanx a lot...

Backspace In Phone Number Textfield
I have a text field that when numbers are entered they format to look like a standard telephone number (XXX)XXX-XXXX using the following code.

_root.txt2.onChanged = function() {
var phonevar = this.text;
if (txt2.length == 3) {
var temp = "("+this.text+")";
this.text = temp;
Selection.setSelection(txt2.length+1, txt2.length+1);
} else if (txt2.length == 8) {
this.text += "-";
Selection.setSelection(txt2.length+1, txt2.length+1);
}
}

I'm having a problem when the user goes to backspace.. once they get to where the dash or parenthesis is inserted it won't let them delete anymore of the text.

Can anyone help me with this problem?

[HELP] SetFocus And Delete/Backspace Problem
The following code works as expected. It sets focus to the TextField, erases the contents and allows me to type immediately.


Code:
var someListener:Object = new Object();
someListener.onSetFocus = function(oldFocus, newFocus) {
entry_txt.text = "";
};
Selection.addListener(someListener);
Selection.setFocus("entry_txt");
The problem arises when I hit the Delete/Backspace key. Pressing the Delete key does nothing. The Delete key will begin to work if I click on the field.

Interestingly, holding Shift+Delete does work but is unintuitive.

Has anyone experienced this problem and come up with a solution? Thanks!

Problem With Shif And Backspace On Keyboard
Hi Guys,

My boss want I draw a keyboard on the screen and the users need click letter by letter to write soething... until this everything is ok... my problem are :

1. When the user press the button Shift on the "screen keyboard" the system need understand that the next alphanumeric character need be capital !

2. How to make the system understand the backspace on this screen keyboard ?

My code is very simple:

I have a textfield called message and them I do :

When the user click in a letter or numbver I only do this :

on (release) {
message = message + "letter";
}

Is Ther Any Reason This Shouldn't Workd....<Backspace>....
hey i'm trying to use the keypress <Backspace> on a button so that when you press it you go to the previous frame...the actionscript is fine...i tried the exact same script just substituting say a letter key or enter and it works but with the <Backspace> button it just doesn't do anything....any ideas...

*also on a side note...does anyone know how i can keep all the characters typed inside of an input box i create on cap locks...thanks

james

Imitating Backspace In Flash Input Field
Hi Guys, Heres a Question for ya. How do ya imitate a backspace in an imput text. Say like u make a virtual keybaurd using the mouse.. how do u imitate a backspace if u create an error.. eg.

button g
input + "g"

buton j
nput + "j"

how do u erase a letter in the text field.

Thanks If ne one could solve that.. much appreciate it

Disable Backspace When In Input Text Fields
Im trying to find a way to disable the keyboard backspace button from going back a page in the site but allowing it to function as a character delete when needed for typing in an input text field of a form.
Strangely this problem only occurs for about a minute after the page is opened....after that it then works correctly. You can see what I mean by accessing the site's contact page
www.safetybusiness.co.uk

I have found two different sets of code to disable the Backspace completely, but this then means it doesn't work at all when wanting to delete in the text field.

Method 1:

<script type="text/javascript">

if (typeof window.event != 'undefined')
document.onkeydown = function()
{
if (event.srcElement.tagName.toUpperCase() != 'INPUT')
return (event.keyCode != 8);
}
else
document.onkeypress = function(e)
{
if (e.target.nodeName.toUpperCase() != 'INPUT')
return (e.keyCode != 8);
}

</script>


Method 2:

<script>
function checkShortcut()
{
if(event.keyCode==8 || event.keyCode==13)
{
return false;
}
}
</script>
<body onkeydown="return checkShortcut()">

Anyone know how I can overcome this?

Safely Switching Focus During Backspace Key Down Event?
I have a simple form that I'm building. It has a variable length list
of entries, and I'm using a TextInput for each entry.

Because the list is variable in length, I'm allowing the user to
delete elements from the list. One of the ways they can do this is to
press the backspace key when the cursor is in an empty TextInput. I
am handing KeyboardEvent.KEY_DOWN and checking for the backspace key,
to accomplish this.

The problem I am having is that after I remove the deleted TextInput,
I want to leave the focus in the TextInput above. I can do this using
'setFocus', and that works fine, however it seems that the backspace
is still processing, and so after the focus is set, the content of the
TextInput is delete which I don't want.

To get around this, I've created a one-shot timer with a 0ms delay
which changes the focus after the KeyDown event has completed.

My workaround is successful, but feels very heavy handed. Is there a
better way to achieve the same effect?

Any advice would be greatly appreciated.

-Robin

Named Anchors & Problem With Backspace In Text Boxes
I am encountering a problem when using named anchors with dynamic text fields. My flash movie is set up in sections with named anchors, and one of the sections is a contact form with text fields for the user to enter information. When the user uses the backspace (to delete what was typed), instead of deleting the previous letter, it instead takes the user to another section. Is there any way around this?

Loading Backspace And Enter Key Into Input Text Field
im working on a file where i am loading key strokes into an input text field. forinstance when you tpye an "a" it loads an a into the input text field. here is the code that im using.

on (keyPress "a") {
textfield += "a";
}


the problem im having is that the i cant use this code to simulate the backspace key to remove text from the input box, and i can use the enter key to drop down a line. is there a way that i can get these two buttons to work in this input box? please help.

thanks

Backspace Sends To Previous Page In An Input Textfiled
Hi All,
I have a strange behavior with a flash 8 game that seems only to happen on Explorer6.

When hitting the 'Backspace' key to edit a text entered in a flash input textfield, users are redirected to previous html page !

- users do NOT accidentally click outside the flash before hitting backspace, the focus is on the flash texfield
- I even catched the backspace in the html page with javascript and bloqued it (backspace is inefficient when focus is on the browser) but the problem still occurs !
- the problem does not seem to be linked to the flash named anchor problem

any idea to fix this ?

thanks 1000 times in advance

Pressing [backspace] Forces Browser To Previous Page
I have a Flash 7 widget with two text input fields and a 'submit' button.

While typing text into an input field, if I press [backspace] the browser is forced to the previous page in history. It should merely delete one character in the text I've entered. This only happens in IE6; Firefox and IE7 do not have this behavior.

Any ideas?

Input Text Boxes - Can't Backspace/delete Using SetFocus()?
Helluo all,

This is rather strange and annoying, and hopefully someone will know what's going on.

I have an input text box called answer on my stage. On the first frame of my movie, I use Selection.setFocus("_root.answer"); so that people don't have to click in the box to start typing.

This is all fine. Tentative w00t.

Then I noticed that the backspace and delete keys don't seem to have any effect. The arrow keys work, the shift key works. The only way for backspace and delete to have any effect is to use the shift + arrow keys to select text, then backspace/delete them.

Has anyone come across this problem? More importantly, does anyone have a fix, or a better, working way to give an input text box the focus?

Thanks in advance!

Mouse Listener And Key Listener Problem..
Hi;

I used key listeners to detect the block in my crossword application but I have a focusing problem going on. I've tried everything but still couldn't find a solution. By the way I used a code that uses mouse listener to highlight the area I want to use but it sometimes craches the flash player. My .fla file is included in the message. Please help before I go mad.

.fla file :http://rapidshare.de/files/26952935/...2006_.zip.html

Thanks...

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