ActionScript 3.0 :: Can't Get Keypress To Work
May 1, 2009
I'm using Flash CS3 (AS2.0) at school on a mac, but when I open the file on CS4 on my pc I can't get my keypress to work.[code]I want my animation to happen when I push "t" on the keyboard.I have the whole alphabet to go through but I'm stuck since I can't even get this first one to work!Do I have to convert it to AS3 somehow since that's how it opens in CS4 (I think)?I'm new to Flash and need to figure this out for a course project!
View 1 Replies
Similar Posts:
Aug 28, 2006
I have successfully made a keypress listener that does an action when the user presses a specific key. The only problem is that it doesn't work until the user physically clicks on the swf.
Is there a way to set the listener to detect a key press even if the user hasn't "activated" the .swf? When I refresh the webpage I'm already in the web browser so the detect should work from the start and the user shouldn't have to click on the .swf to make the keypress work.
Maybe there is no way around this but it'd be nice or if someone knows a work around?
Here's my code stripped down to the essentials:
keyListener = new Object();
keyListener.onKeyDown = function() {
x = Key.getAscii();
[Code]....
View 8 Replies
Jan 9, 2009
[code]Is there a way to check for when a key is released? Because here is the problem. It's a pause button, but what happens if you hold it down for too long? First it will check to see if the 'p' button is pressed and that the game is not currently paused. "It's not, ok, pause the game." But since it's checking this same if statement 24 times a second, say you accidentally hold it down too long and it goes through the same if statement again: "Ok, the 'p' button is pressed, but the pauseGame is false. Ok skip that and move down to the else. The 'p' button is pressed and the pausegame is true. Cool, set the game to unpaused." In less than a second it managed to pause and unpause the game because the conditions were correct both times.Is there a way to avoid this error? With a button they have the onRelease to solve this problem. How do I fix it for a keypress?
View 1 Replies
May 19, 2009
What I'd like it to do is find out what key was last pressed and then based on which key it was, go to a specific frame of guy_mc. So basically if the left key was the last key press I want it to go to frame "Left", if right key was the last, go to frame "Right," etc. I'm completely lost on this one and every tutorial I come across is based in AS2 which has much simpler methods than AS3.
Code:
//listen for guy_mc to see if all keys are up
guy_mc.addEventListener(Event.ENTER_FRAME, allKeys);
//if all keys are up...
[code]....
View 1 Replies
Jun 29, 2010
What I'm trying to do seems really simple but I can't get it. I'm trying to do something like this, but keyRelease doesn't exist I think.
on (keyRelease "<Right>") {
nextFrame();
}
I just want it to go to the next frame on the time line when the right key is RELEASED.
View 1 Replies
Apr 4, 2012
I've made a popup div that shows a video if you press a button. If you press Esc, the div is hidden again and the video is removed. (Using JWPlayer in Flash.)
If you click on the JWPlayer video, Flash gets the focus and JavaScript can't listen for keypresses on the document anymore. Is it possible to make JavaScript get the focus after you've interacted with the JWPlayer video player, so that you can still press the Esc button after for example pausing the video?
View 1 Replies
Aug 5, 2009
I was just wondering what the difference between these two is.
View 1 Replies
Aug 5, 2009
I'm working on the timeline and have movieclips on each frame. Each movieclip should play completely before moving to next frame. Once the movieclip is completed playing, I'd like to set up a keyboard event that allows for movie to go to next frame onKeyUp.This is the code I have but it's not working ... I'm getting jumbled results. I know this should be simple enough, but oh well.
stop();
import flash.events.KeyboardEvent;
var keyListener = new Object();
[code].....
View 3 Replies
Jul 20, 2009
I'm developing an application for use on a tablet PC where the user has the option to make multiple selections with a List Component. I need the ability to simulate the CTRL key being pressed since the keyboard will most likely not be available so the user can select and de-select items from the list. I will most be attaching the code to a button that will open the List component.
View 1 Replies
Aug 26, 2010
I had an old version of air which loaded an swf that runs an as2 swf using as3 The as2 swf included keypressing and regular as2 stuff. I just installed the new version of air and exported the AIR file again Keypresses don't seem to workhow to fix this?I thought about exporting to an older version of air but I have no idea how since the only option I have in CS5 is 2.0
View 1 Replies
Dec 14, 2011
I have a viewstack which implements a 'wizard' interface for doing new orders. On the last page of the wizard, there is a button, with a fake accelerator on it, by which, if they press 'o', they can start the process over again.
Below is my handler:
protected function _keyDownHandler(e:KeyboardEvent):void
{
if((e.charCode == 111)) {
[Code]....
The problem is that when the user gets back to page 1 of the wizard, the 'o' the user just typed is now entered into a datagrid filtering textbox (filter by last names starting with 'o'), which is not what is desired.
As you can see, I've made some attempts at forbidding this interaction, but it appears to be not enough, even though the model.orderNew() bit contains all the code to swap the viewstack pages around, re-setting the focus to the txtSearchFilter, etc..
It appears that e.cancelable == false, which is probably why I'm getting this behavior..but the documentation says that KEY_DOWN IS cancelable, so..
How can I keep the keypress from propagating to the form ?
View 3 Replies
Jul 8, 2009
ive started a game in as3 and everything has been going smooth. got my character running around. have an array set up with all different types of variables inside for different things like floor, walls, doors, etc etc. theres only a couple things i want to clean up before adding npc's. im having a problem with my jump function. basically, i have my keypress' set up in booleans and its working A OK. But the problem is when u hold the jump key the function keeps running over and over. I tried the obvious by adding the function to an if statement to just the keypress and not the boolean but it makes the function only run partially and leaves the character floating in the air until you hold the key down long enough for the character to land again. so basically i need the function the run all the way through and stop and wait for another keypress so even if you hold the jump key, the character will only jump once.
i think i may have to create something other than a boolean. or maybe a class with a timer that is called on the keypress. am i even close?
View 4 Replies
Sep 8, 2011
I've tried using ASCII codes but = and - don't seem to respond to this. Is there any other way to check for a keypress on these keys?
Here is my code for the function just incase it proves useful:
ActionScript Code:
function selectNum() {
selecting = true;
num = random(12)+1;
[code]....
View 1 Replies
Mar 30, 2009
So i know that the flash object needs to have focus in order for the key event to fire, but i am having an issue where i click a button in the flash window and the events stop firing.The button activates a box2d world and i don't know if that has anything to do with it. but as soon as i hit the start button, the key events no longer seem active until i click again.
View 3 Replies
Oct 31, 2009
I know this sounds really simple, but is there any way I can implement a key press to a function, I know this is wrong, but you've got an idea then:butmute.keyPress("m") = function {
View 2 Replies
May 26, 2009
I have recently made a piano in CS3 using AS2. The basic idea is that you can both click on a piano key and click on a key on your keyboard to hear the sound that particular key makes.Everything works just dandy apart from the fact that the sound doesn't seem to work at all.Below I have posted the action script (the comments are in Dutch) perhaps you'll need the FLA file as well.
Code:
stop();
//Maakt een sound object en verbind het met de piano movie clip op de stage
[code].....
View 1 Replies
Jun 29, 2010
I'm trying to do something like this, but keyRelease doesn't exist I think.
on (keyRelease "<Right>") {
nextFrame();
}
I just want it to go to the next frame on the time line when the right key is released.
View 1 Replies
Sep 19, 2010
When a key is pressed, data is sent to PHP to be stored in a MySQL database. For each key press, only one entry should be posted. it re-posts exponentially (e.g., 1st key press = one post, 2nd key press = two posts, 3rd key press = three posts; thus, totaling six posts).Initially, the event listener for key press existed alone on a single frame. When that was the case. This issue did not occur. I added an additional frame so that I could set to clear out all variables and start fresh.
so frame 4 will have :
KeyListener = new Object();
KeyListener.onKeyDown = function(){
if (Key.isDown(69)){ // if key pressed is "E"
[code]....
View 1 Replies
Nov 12, 2010
I am a high school teacher who is teaching Actionscript 3.0 for the first time. I am teaching my students how to create multiple scenes to understand actionscipt interactivity. The first scene has a button. The second scene has something happen when a key is pressed. The problem is that the second scene doesn't work. Flash doesn't even show the trace command that a key has been pressed. Keypresses work fine when done in the first scene, but when put in the second scene after a button has been pressed, it doesn't recognize the keypress event.
View 1 Replies
Jan 23, 2011
I have scoured google for every phrase combination I can think of. Right now, my ninja moves left, right, and jumps how I want him to. Unfortunatly the movement code is located under an onEnterFrame event, so it only plays the first frame of his walking/jumping animation. I found a tutorial at [URL] that looks like it has promise, but I cannot get it to work with my current setup. (Not to mention it has SERIOUS flaws itself) How can I make it so the ninja animates all the way through during his walking phase??
View 1 Replies
Mar 29, 2008
I am creating a very simple presentation in CS3, which will be projected on-screen and will have a live speaker. I would like to be able to pause the SWF at various locations along the timeline so that the speaker my discuss issues on the screen, and then presume playing it. Since don't want this control visible (such as with a button) to the audience, I would like the control either with the press of a key, such as the arrow right key, or with a remote controller. How would I encode this both with the press of a key or with a remote controller?
View 10 Replies
Nov 11, 2009
I need to create a simple presentation that displays a bunch of photos.I want to be able to hit the space bar to advance to next picture.I am able to stop the playhead at the picture, but i want to advance to next labelled frame by hitting the space bar.
View 2 Replies
Jun 21, 2010
I'm having a problem with PC applications. Notably, the keypress command no longer working when my app is fullscreen. It works just fine on Mac, but bugs out and doesnt recognize and of my KeyPress actions when fullscreen. When its not fullscreen, it works. I dont know what to do, as i need my apps to play fullscreen on both pc and mac.
View 1 Replies
Sep 3, 2010
I do a lot of multimedia presentations for events/awards/summits using flash where I have to assign numbers/letters to call certain screens (eg. a speaker screen) at any time, and I understand Adobe have disabled the keypress functions entirely when publishing out of CS5.
Is it at all possible to bypass this and allow the key presses to be enabled? Or is this pretty much a like it or lump it it doesnt work anymore issue.
The only work around I have been able to work out is to save down to CS4 and publish from that, which kind of seems a bit silly and backwards.
View 1 Replies
Apr 9, 2011
I'm making a Flash piano for a school project and I've got everything working perfectly except for the keystrokes.The piano keys are button symbols.When I click on the C button on the virtual piano, it plays a C note and presses down the button.When I press the "a" key on my keyboard, it plays a C note but doesn't press down the button.How can I get it to look like the mouse clicked it when I press "a"? This is what I have on the key right now (and bare with the simple coding; my teacher doesn't do anything harder than what's below):[code]
View 5 Replies
Apr 12, 2010
I know how to make the mouse event work. I know how to make the keypress event work. Now what I can't figure out is how to make one button respond to both keypress and/or mousevent. In other words, a button that you can click or press "enter" for it to work.
This seems really basic but on googling all I can find is basic "how to do a keypress" stuff.
View 1 Replies
May 15, 2011
When I add a keypress eventlistener to the stage, it does not fire when the focus is on an other object ... How can I listen for any keypress event regardless of the focus?
View 1 Replies
Jun 18, 2009
I'm making a drawing API for my homepage. My homepage is exclusively created in Flash AS2... But I have a problem with my brush for the drawing API... I would like to change the opacity/alpha value of the brush, with keypress LEFT and RIGHT... But i can't get it to work!
Here is my code:
ActionScript Code:
lineThickness = 0;
selectedColor = "0x000000";
[Code]....
View 0 Replies
Oct 17, 2009
I'm trying to make a movie clip play with an off-screen button that activates it by using a key. The instance name for the movie clip is "leftbuzzerlights" and the key that's supposed to play the clip is the letter "Z". Here's the code:
ActionScript Code:
on (keyPress "z") {
leftbuzzerlights.play();
[code].....
View 6 Replies
Nov 27, 2009
the CTRL button in this game is doing two things:if movieclip is visible, then turn it off.if movieclip is not visible, then turn it on.however, if i hold the CTRL button pressed, it will trigger over and over, turning the movieclip on and off on and off on and off and so on.how should i fix this problem?[URL]
View 3 Replies