ActionScript 3.0 :: Check If No Keys Are Down?
Mar 23, 2012How do I check wheter KEY_DOWN is false on every key on the keyboard? (no keys are pressed)
View 3 RepliesHow do I check wheter KEY_DOWN is false on every key on the keyboard? (no keys are pressed)
View 3 Replieswhether using a String as the key in a Dictionary results in slower lookups than using an Object, Class or Custom Object (an instance of developer defined Type)?
When using a String as a key, does the literal String have to be parsed, or does the Dictionary key point to the String Object?
How do I get the AWSD keys to work as smoothly as the arrow keys. I can put the arrow keys inside an enterFrame
[AS]onClipEvent (enterFrame) {
//move the tank
if (Key.isDown(Key.RIGHT)) {
[Code]....
If I put the AWD keys inside an enterFrame they run until I push another button
See [URL] Now there is a button called Answera, which when clicked should have a symbol (movie clip) called Check appear at the cordinated specified. Check exists in the libary (but does not have an instance name) and no where else on the stage. when I run this code I get: 1180: Call to a possibly undefined method Check. -> var rightCheck = new Check(); How is it undefinded if it exists in the libary?
View 7 RepliesThe following is my codes. This is still work in progress; so, you will see some functions with empty contents. Plus, this is my first Flex application; please bear with me. This is a quiz application that gets the questions and answers to each questions from a ColdFusion web service. There are three types of questions, True or False, Multiple Choice with single selection, and Multiple Choice with multiple selections. So, based upon the question type, the application would dynamically generate the appropriate amount of radio buttons or check boxes for the users to select. I got these working. The problem that I am having is, I am not sure how to check what the users have actually selected. In some other forums and posts on other web site, it said that I can use event.currentTarget.selectedValue to get the user selection. But when I actually do it, I got a run-time error saying, "Property selectedValue not found on mx.controls.FormItem and there is no default value." My question is, what do I need to do to capture the user selections?
[Code]...
My code doesnt detect 2 kest at once.I want to press an arrow key and spce bar. In .net the below code does do this but in flash if I hold down an arrow key and press space bar the arrow key event will stop working.[code]
View 7 Repliesin AS2 how would i use the down arrow key to make the timeline play? at the moment i have this and i presume i need to put something after that to make it play. [code]but i presume this is totaly wrong because the "stop();" doesnt stop the clip when the "if (Key.isDown(40))" bit is after it.
View 2 RepliesI have a quiz projector file in full screen. I want to prevent students from using keyboard shortcuts like alt+tab or the win key.[code]...
View 1 Repliesis it possible to set the state of keys rather than just read them in AS3? I am particularly interested in setting the state of the CAPS LOCK, NUMBER LOCK and SCROLL LOCK if possible i.e. toggling the LED state.
View 2 Repliesusing the authoring tool to test,I find I can only read certain keys via:stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
But when I test in a browser, I can indeed read all the keys. So the IDE must be intercepting certain keypresses. E.g., I can read w and d but not e.
How can I read all keys? Testing in a browser all the time is a bit inconvenient
The objective is to get the fox - by using the arrow keys - to move around on the stage and when he touches a duck the duck should disappear of the stage. The duck has a motion tween on it, to make it fly.Also if the fox touches one of the traps he should make a sound - using the redfox.wav sound in the library and disappear off the stage.I have this code on the actionscript timeline //Program to generate a set number of traps
//Declaring Variables var numOfTraps:Number; var movieWidth:Number; var movieHeight:Number; var counter:Number; //setting variables values for traps numOfTraps = 6 movieWidth = Stage.width; movieHeight = Stage.height; //Program to generate a set number of traps //Declaring Variables for (counter = 7; counter <= 13; counter++){ //Place 6 traps on the stage [code]....
I have done up a flash demo which uses the computer mouse to navigate. Now instead of using mouse, I want to use keyboard (arrow up, down, left, right) to highlight buttons and then hit "enter" key to click the button.
View 2 RepliesI 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 RepliesIs there any way to set an event if two keys are down at once in actionscript? For example:
onClipEvent(enterFrame)
{
if(Key.isDown(Key.UP))
[code].....
I'm learning Flash and Actionscript and playing around with some different features. I have an MC of a car and have coded them arrow keys to move it left and right and the up and down keys to adjust the speed. It also flips the MC horizontally based on which direction is pressed. There is a startover button that goes to the beginning of the timeline, and a back and next button.
Everything works except I have to click on the stage to get it to recognize the key presses. Once I click the stage it works fine. If I go forward and come back it won't work until I click the stage again. I THINK it was working correctly last night, but I was playing around with some of the images and code this morning and realized it wasn't working right anymore...or maybe I just didn't realize I was clicking the stage last night.
Here's my script:
Code:
stop();
btnStartOver.addEventListener(MouseEvent.CLICK, StartOver97);
function StartOver97(event:MouseEvent):void {
[Code]....
I am trying to get a keyboard input why my game is playing. So here is my code below. Thing is, only certain keys are coming up in the trace. So if I press the a key, nothing happens. If press the d key, I get the trace. Only a handful of the keys are registering... why?
Code:
function PowerUps(e:KeyboardEvent):void{
var holdout = getTimer();
var theKey:String = String.fromCharCode(e.charCode); //the key code the was pressed
[code]....
I'm building a simple app where an image displayed changes based on which image is selected in the combobox. Pick a different image in the combobox, the old one transitions out, the new one transitions in. Easy, right? So while the transition is taking place, even though I disable the combobox (.enabled = false, and I remove the Event.CHANGE listener for the combobox, I can still scroll through the combobox's options with the up/down arrow keys. I'd like to lock that ability out temporarily
View 1 Repliesin Java this: dict.keySet()
View 6 RepliesI have a file set up with a movie clip moving from side to side by itself and when it reaches the end of the stage it goes back in the opposite direction.[code]I know want to control the movie clips movement with arrow keys, just left and right so that it would stop when it reaches the edge and will only let me move it the opposite direction.I guess I'm just trying to set up a sort of template.
View 9 RepliesThere is probably a better way to do what I'm trying to do, but I simply want to make a variable change its value when I press the arrows keys. For example if I wanted to cycle through weapons, if weapon=0 then the character is holding a certain weapon, then I press the down arrow key and weapon=1 and if weapon=1 the character is holding another weapon. And if I press up weapon=0 again so he's holding the first weapon again. And say there's 8 weapons, if weapon>8 then weapon=0 again so its a cycle. I tried arrow key functions and all they worked for was making a symbol move. I think I knew how to do this stuff in gamemker pretty well but Flash is very different.
View 2 RepliesI have been using powerpoint all long for my presentations, but I'd like to move on with Flash. My question is therefore as follows: How do I use the arrow keys to go to the next frame and optionally, the left key to go to the previous frame?
View 2 RepliesI have been making a game and have recently found out about the Combo Box component, I love it and it works really well, except for one thing.You play the game using the arrow keys, and when you press the arrow keys the character moves, AND it changes the value in the Combo Box, I do not want it to affect the combo box.Please do not say use the WASD keys or another set of keys as this will not affect it, because this is not an option, they are already being used!
View 9 RepliesKey Listener I did on Flasg-8 stopped working properly after I re-published them in Flash CS3 In particular reloading the clip on pressing A still does not work, although it used to on Flash-8. The relevant bit of code is:
switch(Key.getCode())
{
case(65)://a
trace(Key.getCode());
[Code].....
variable game_swf is defined earlier and is simply a name of this clip: "game1.swf" and on pressing A it traces correctly
The fla file is saved as FLASH8 The publishing settings are AS2, Flash Player 9
The whole thing is running on PC with Windows XP
Iv created a virtual keyboard in flash using arrays and buttons i now want to assign a sound to all keys so that whenever they are pressed the sound will play, I'm guessing ill need to use a for loop or something but i really don't know how i would go around doing so.
View 2 RepliesFor some reason, the down and right keys aren't working. They work fine in other programs but in this program they fail.
paddle_ybase = paddle._yscale;paddleSpeed = 0;
onEnterFrame = function(){
if(Key.isDown(Key.UP)){paddleA._y -= 1;}if(Key.isDown(Key.DOWN)){paddeA._y += 1;}
if(Key.isDown(Key.LEFT)){paddleA._x -= 1;}if(Key.isDown(Key.RIGHT)){paddeA._x += 1;}
steam(7);paddle._rotation = paddleSpeed;
} function steam(num){for(i=0;i<num;i++) {
[Code] .....
I have been working on a project which has been giving me headaches. I want to be able to navigate through a presentation using the arrow keys - To do everything on the one timeline was going to be too complicated and messy so tried to create separate files but could not get the separate files loading -.My next problem is incorporating the two approaches - here is my code from my test files with my attempt added:
stop();
// create an array to hold the names of the frame labels
var labels:Array = new Array();
// take the name of each label in a MovieClip and put each
[code]....
I can either get the arrow key navigation to work or the previous movie to load but the left arrow key then doesn't navigate back. Although in saying this version doesn't work and I can't get it load again.
I have done up a flash demo which uses the computer mouse to navigate. Now instead of using mouse, I want to use keyboard (arrow up, down, left, right) to highlight buttons and then hit "enter" key to click the button.
View 6 Replies2 keys at once My code doesnt detect 2 kest at once.I want to press an arrow key and spce bar. In .net the below code does do this but in flash if I hold down an arrow key and press space bar the arrow key event will stop working.
[Code]...
When I first put this code in, it worked.Now it doesn't Does anyone have any ideas as to how to fix it?[code]
View 4 RepliesI'm making a website that will have some keys that bring you to various images (like a portfolio seen here: [URL] I've noticed doing this on the timeline takes up ALOT of space and makes the files very slow. how to do this while keepign file size low?
View 2 Replies