-
[RESOLVED] Maintaining focus on textfield when mouse is active
Hi,
I am working on a chat and I would need to maintain the focus on the textfield but I keep loosing it whenever I use the mouse to move an avatar across the stage.
I'd like to add my file here or a cloud but I don't know how to post it there.
I do have Selection.setFocus at the beggining of the script, but since it's an avatar chat, every time the mouse gets clicked, the focus becomes lost. That's normal, right?
-
.
Hi Cap,
From testing here, the textfield stays in focus once clicked until click another textfield no matter what I do.
Try this for remembering which textfield was last in focus, so that when you stop dragging, or use a listener for mouse up, then set focus to the last focused textfield,
PHP Code:
var focusField:String;
dragger.onPress = function():Void
{
startDrag(this);
};
dragger.onRelease = function():Void
{
stopDrag();
Selection.setFocus(focusField);
};
textArea1.onSetFocus = function():Void
{
focusField = this._name;
trace(focusField + " is in focus");
};
textArea2.onSetFocus = function():Void
{
focusField = this._name;
trace(focusField + " is in focus");
};
1 movieclip (dragger), 2 textfields(textArea1,textArea2)
-
Hi, Fruit,
thanks, but it's not about dragging. It's moving the avatar from one coordinate to another with a click.
I have a working version modified in CS5 but I am trying to code it in 8. You know I still need to learn basic as2 before hoping to move forward...
The funny thing is I copied the exact code in each frame from CS5 to flash 8 and it doesn't maintain it there. It does in the one modified with CS5, so the user doesn't need to click on the textfield box to write each time.
I have the account in DropBox or skyDrive but I don't know how to make the files accessible to others.
-
.
Hi Cap,
you can always make a temp folder on your webspace and put the files there and link to them.
I assume you are using the Smartfox stuff with the avatar chat again.
As for the drag, just change it to a mouse listener, mouse up -> set focus to last focused textfield again.
-
Thanks, Fruit. But I don't follow. How about onEnterFrame? Is it a good option?
-
.
Hi Cap,
Using the same textArea code as above use a mouselistener to reset focus to the last focused textfield
PHP Code:
var mouseListener:Object = new Object();
mouseListener.onMouseUp = function()
{
Selection.setFocus(focusField);
trace("mouse is up");
trace(focusField + " is in focus");
};
Mouse.addListener(mouseListener);
-
Thanks, fruit. Sounds practical. Can't wait to get home and apply it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|