|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I'm working on a Flash/ASP chat application and have everything working BUT the enter key. I want the enter key to submit the comment the same way clicking the button does. The movie is only a single frame long.
In one layer, I have this action script: Code:
function onChange(component) {
if (component._name == "btnGo") {
addComment()
}
if (component._name == "btnLogOff") {
getURL("leavechat.asp?isession="+isession)
}
}
function addComment() {
varComments = new LoadVars();
varComments.NewComment = myComment.Text;
loadVariablesNum("addcomment.asp?isession="+isession,0,"POST");
myComment.Text = "";
myComment.setFocus;
}
In another layer, I have: Code:
if (Key.isDown(Key.ENTER)) {
addComment();
}
The enter key submits the form maybe 75% of the time but the other 25% of the time you have to hit the enter key twice or even three times to get it to go! Any help would be appreciated! |
|
#2
|
|||
|
|||
|
That is interesting. I will try to help
Since you have a one frame single Long, how about to separate your objects and your scripts into 2 layers. One with the Object and the other one with the scripts. Just to make it portable and easy to debug. The idea is to make the addComment active when we a key is PRESSED. This i would try. First off,Make one MC with and give the instance name any name (eg:actionMC) 1. We will use the onClipEvent (load) for defining functions -The action is initiated as soon as the movie clip is instantiated and appears in the Timeline 2. Once the movieCLip is loaded (let say the clip has nothing inside so it will load fast) , we will now define the function once its loaded onClipEvent (load) { function addComment() { .... _parent.myComment.Text = ""; _parent.myComment.setFocus; } } #I use _parent, so i can recognize where the dynamic is 3. Then use onClipEvent(movieEvent) that will trigger the action -A movieEvent is a trigger event that executes actions that are assigned to a movie clip instance. Any of the following values can be specified for the movieEvent argument (from the FLASH help files) 3. Let say we use the keydown action - The action is initiated when a key is pressed. Use the Key.getCode method to retrieve information about the last key pressed. onClipEvent (keyDown) { if (Key.getCode() == Key.ENTER) { addComment(); } } 4. To avoid any duplication of action try to make variables that will define your action eg: if (Key.getCode() == Key.ENTER && _root.action="addComment") { addComment(); } if (Key.getCode() == Key.ENTER && _root.action="updateComment") { addComment(); } Hope this will help, based on what i understand. |
|
#3
|
|||
|
|||
|
Thank you very much for your response, Pakcik. I will give it a try...
|
|
#4
|
|||
|
|||
|
Thank you so much, Pakcik. That completely solved the problem!
|
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Flash Development > Enter key in Single Frame Movie |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|