Flash Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignFlash Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old January 15th, 2003, 04:31 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
Question Enter key in Single Frame Movie

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!

Reply With Quote
  #2  
Old February 7th, 2003, 11:36 AM
pakcik_kantin pakcik_kantin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Kantin
Posts: 18 pakcik_kantin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old February 8th, 2003, 09:36 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
Thank you very much for your response, Pakcik. I will give it a try...

Reply With Quote
  #4  
Old February 10th, 2003, 03:17 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
Thank you so much, Pakcik. That completely solved the problem!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignFlash Development > Enter key in Single Frame Movie


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway