ActionScript 2.0 :: Recording Key Presses Into An Array?
Jul 24, 2006less cpu consuming way to do this?
View 5 Repliesless cpu consuming way to do this?
View 5 RepliesI am creating a program where I am randomly flashing a series of words, and I would like to be able to record when someone has hit the "x", even very briefly, when looking at the word.I have inserted all of my code below, but I have difficulty with the section in bold. Everything is working except that in order for the "x" key press to be counted, it must be held down as the words actually change. Is there any way to have it record that the "x" is hit even if it very briefly? Whenever I try to use the key listener function, it does not work with my loop for displaying text.
stop();
var tempvariable = new Array();//array create variables stored in Flash to be saved for later display
var itemarray = new Array(); //This is the array to hold the Words that need to be randomly shuffled
[code]....
my intention: creating a sketchpad that records mouse movements so the drawing can be played back.
problem: _xmouse and _ymouse are not being saved in the array. i get an 'undefined' error when trying to read a position that should exist somewhere in the array.
code:
history = new Array();
history[0] = new Array();
history[0][0] = new Array();[code].....
my intention: creating a sketchpad that records mouse movements so the drawing can be played back. problem: _xmouse and _ymouse are not being saved in the array. i get an 'undefined' error when trying to read a position that should exist somewhere in the array.
[Code]....
i have build a small test app in Flash Pro 5.5 overlayed with the AIR 3 sdk.is has just 2 buttons to record and playback audio from the microphone. when i test this on my iPhone 3g - i record myself saying "1-2-3-4-5". but when i playback a half a second or so is missing from the beginning : "3-4-5-".
when i test this on the desktop all is fine is this a result of the iPhone 3g's cpu power or is it a bug or is it my code?
[Code]...
I want my site's users to be able to record videos straight from their webcams into my site. Videowhisper is one such tool which seems to work fine - [URL] But I'm looking for opinions on better / more scalable / reliable solutions. Paid solutions are fine.
View 4 RepliesI'm following a simple tutorial on making a platformer, but I ran into a problem. This is the code I'm using in a player movie clip:
onClipEvent(enterFrame) {
if(this.character.hitTest(_root.bg.ground)==false) {
this._y+=_root.gravity;
[Code]....
When I press the keys, nothing happens, but if I replace the if statement with a 1 then the code executes fine.
Actionscript Code:
// button pressesupKey = 38;downKey = 40;leftKey = 37;rightKey = 39;focusKey = 65;attack1Key = 83;attack2Key = 68;bombKey = 81;autoAttack1Key = 87;autoAttack2Key
[Code].....
Rather than affecting one variable, one key press makes all the others true as well
I have recently been working on creating a game similar to the good ol' Asteroids game. So far, I have managed to create a very simple piece of code that rotates and moves my spacecraft according to the angle it is currently at. There are two problems with it, though:
1. I can't use two buttons at once--for example, to rotate and move forward. I'm sure there must be a better way to detect key presses. What's the best way to do it in AS3?
2. The way the whole thing works looks kind of jerky and stage. Another thing is, the spacecraft is constantly at an odd angle for no apparent reason.
Here it is ("sc" is my spacecraft movieclip):
var SC_speed:Number;
var SC_rotation:Number;
var SC_radians:Number;
SC_speed = SC_rotation = 0;
function keys(event:KeyboardEvent):void{
[Code] .....
im tryin to make this control the player(head) on stage by simply turning rght now but i can't get it to work...
also all the code for keypresses can be found in the player movieclip on the actions of frame 1
I have a really strange problem. I've made a custom class that listens for keyboard events such as key presses (I use it in order to navigate in an interface). When I test my file in Flash (using 'command'+'enter') all key presses work as they should. However, when I publish the file and starts the projector (or the swf for that matter) one key ('g') isn't doing what it should!
View 2 RepliesI set up some code to record key presses and specific chords. My problem is that I only want the keys to fire once when pressed. This is especially a problem when I require the user to hold CTRL + LEFT for an action.
The user experience is that I want users to hold down CTRL to enter a mode and then press the LEFT key as many times as needed. Currently, the CTRL trace and LEFT trace fire continuously. Is there a way to do a onKeyRelease?
Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.CONTROL)) {
[Code]....
When I say two keyboard presses, I'm thinking about a situation where I would need to detect both. Not a shift this or alt that or control third. I'm talking about Down + A or 5 + T. For instance: Ryu has an overhead attack that is used when both Down + MP are pressed. If I were to create a game, with ActionScript 3.0, is there a way for me to detect that both buttons were pressed at the same time?
View 5 RepliesI am creating a dancing game:
[URL]
I need to disable the keyboard after each key is pressed, so if the user presses the UP key until the character has finihsed doing the move no other key can be pressed.
How would I go about determining the time in-between key presses in AS3? Basically, if a user is tapping the space bar to a beat, I want to be able to average the time in between 10 taps/key presses and get an output time in milliseconds.
My thought was to use an interval and after every press I would add that amount of time to an array. After 10 presses, I would take the average of all the numbers in the array and then output that number.
trying to count key presses in a 30 sec interval. if the number of keypresses is above say 20 in 30 secs they go to a new frame, otherwise they go back to the start and the count begins again. using as2 and flash cs4. very confused.... not sure if onEnterFrame is better than keyListener.
[Code]....
I simply need to use key presses to jump around on the timeline, ie. press "a" and the movie jumps to frame 355. Preferably a simple way of doing this with AS2. Please help... I will help you with Photoshop one day.
View 2 RepliesIn a mini flash game, I have a few different level select buttons, and they all attach to one "levelChange()" function, and I'm just wondering if there is an attribute that stores which button was pressed or how to determine which was pressed if not.
View 2 RepliesProject is linear slideshow.
click to go to next slide, etc.
I want the user to be able to type the [2] then [5] then [Enter] keys,for example, to jump to slide 25 from where ever they are in the linear show.
Basically, I want to create a button (Instance Name: blueSquare). Each time the button is pressed, I want actionscript to "count" each button press (the maximum is 100 presses). When the number reaches 100 presses, I would like a new button to appear next to it ( Instance Name: redCirlce).
View 2 Repliesis there a command in flash that takes multiple key presses? For example if the user presses a then b the frame will advance. Note, I dont want them to have to be held at the same time.
View 1 RepliesActionScript Code:
package
{
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
[code]....
I am trying to make a game that requires the user to input a lot of different keys in a very short amount of time.[code]...
View 2 RepliesI am making a sort of like racing game maze thing but want it so that when the user hits for example the right arrow key the movie clip moves along it's x axis and doesn't stop until another key is hit or the movieclip hits another movieclip.I was thinking about making a function that some how loops the x distance and this function is being called when ever the keyboard key is hit.
View 4 RepliesI have a button that inserts an mc on the screen every time it is pushed. So say I push it 3 times, the 3rd mc will shrink to be like 1 pixel wide when I use a key press that is in another mc, and I don't have the key press shrinking it.
View 1 RepliesI am familiar with taking in keyboard input in AS3. I was wondering if there was a way to capture and process simultaneous key presses.I don't mean when a user holds down, say, the up and left arrows at the same time and an object moves diagonally. I mean when they actually press down on the keys simultaneously, like in a video game where 2 simultaneous button presses performs a new action.Currently, I have a class that reads whenever a user presses a key and assigns it to an instance variable. Then, each frame, the class pushes the key into a storage array if the current key pressed doesn't match the last key pressed. Each key is stored for 60 frames before being dumped if it isn't processed.
View 3 RepliesI have, lets say an arrow, it points up when you press w, left when a is pressed, down when s is pressed, and right when d is pressed. This is done through animations, and simple gotoAndStop commands. Anyway, Lets say that I want it to point North-east when I press D+W. whats the easiest way I can use to get it to detect Multiple key-presses. If any more explanation is needed I can easily explain further.
View 3 Replieswant to make a game where if someone presses tab they go to a different frame. I have made many approaches to this. and btw im using AS2Here are my tries:
Code:
on(keyPress "<TAB>"){
gotoAndStop(2)
[code].....
My program beings with a frame with a "play" button on it. Once he "play" button is clicked the user is taken to the second frame to play a game. Control for the game is done via key presses. The control works well; I'm able to move the sprites and so forth. However, my problem is after the user clicks "play" and is taken to the second frame the game will not recognize key presses until the user has clicked the applet again. How do I get the game to recognize key presses automatically after the user has clicked "play"?
Here is the code I use in the second frame to listen for key presses:
I have built an application in Flash 8 (as2) it has key listeners in it which work when run from Flash 8.When I open the application in CS3 and run it from there the key listeners no longer work. On testing I found that it only registers when pressing w u d g x and the numbers.
View 0 Replies