ActionScript 3.0 :: Keyboard Control Of Two Objects At One
Dec 2, 2010
Working on my first complex game, and I'm not sure how to best approach this problem. I've got a submarine whose motion is controlled by the four arrow keys and which launches torpedoes via the space bar. After the sub shoots, I want the torpedo to be steerable with two other keys (probably Z for left and X for right), and at the same time, have arrow keys continue to control the ship.
First question, is this possible? I'm assuming I'll have to switch focus back and forth via code.
Second, what the best approach to setting this up? Attach listeners to the stage or to each object? If I chose the former, could i avoid focus issues by detecting which key was pressed and then manipulating the appropriate object?
I have 2 scenes. In both scenes, I have a movie clip that moves via keyboard control. If the goto next scene is triggered by the movie clip in the first scene the keyboard control works in the second. However, if I use a button to move to the next scene then there isn't any control over the movieclip in that scene. I've traced the keyCode in the second scene and it is picked up but the switch statement doesn't run. I'm migrating to Actionscript 3.0 and updating something I created in 2.0. I would like to do it without writing a class.
is the following scripts correct to stop animation by pressing "Space Bar" if the animation is playing. And to play the animation again if the animation is paused. Is there any additional criteria need to be added to make it more solid.
I am creating a game where the user can control the character either by left or right keyboard buttons or by clicking on a left of right movielcip buttons. Currently, I can control the character using the keyboard but I cannot figure out how to add the MC button control. Here is my current code attached to the character_mc:
onClipEvent (enterFrame) { if (_root.background_mc._x<=-3620) { _root.background_mc._x = -3620;
[Code].....
Can I add another listener for either movieclip button (left_btn_mc, right_btn_mc) to the above code, or do I need to add the code to the each movieclip button?
What im trying to do is create 8 button in flash using as2 to control certain keys on the keyboard. When i click a button ive created in flash i want it to trigger a key eg. "a"
I'm trying to create an input field where a user types a word and if correct, the movie progresses to the next frame (I just can't don't know how). More importantly, I wondered if there was a way to substitute clicking on a button with hitting a key on the keyboard? So instead of using a "submit" button to check the field's value... the user can just hit the "enter" or "return" button and the "if" and "gotoandplay" actions will occur.
OK, so im trying to make a seemingly simple as3 project where I instantiate a movieclip from the library, and then move it using keyboard controls. I got it working fine using ye olde as2 method (all the code on the timeline of the .fla), but i cant get it to work using the as3 .as file method (if that's the right description).
I'm using the slider component to control the volume of an MP3 but also need to use the arrow keys to move a character. When you place focus on the slider component, the arrow keys move the slider rather than the character. How can I disable keyboard control of the slider altogether? Is there a way to do it temporarily.
I created a presentation in Flash. And I embedded the following keyboard control scripts so that I can pause the slide by pressing "Spacebar" and play it again by pressing "Enter".[code]I also embedded getTimer script to delay the speed of the flow so that key-point can be loaded one by one.[code]Other than the above keyboard control, I also add four buttons at the right bottom so that I can play and pause, fast forward and rewind by clicking those four buttons.
1. the 1st and 2nd slide cannot be paused by the above keyboard control command.
2. the play and pause buttons at the right bottom is not functional in the 1st and 2nd slide.URL...
I have some AS2 code for responding to keyboard input - it was great because it added friction, thrust, gravity etc... ie: it made the movements very real and added playability which is key in engaging players. On passing it into classes for OOP I don't seem to have got it right. maybe somebody knows a nice tutorial for the same.It was Emanuel Feronato's tut in AS2
RocketMainDocClass package import flash.display.MovieClip; import flash.events.*; import flash.ui.Keyboard; public class RocketMainDocClass extends MovieClip{
Can you tab into CS3 Playback components or control them with keyboard commands in a regular (non screenreader) browser like IE? If not, can you in CS4? I believe that all screen readers can control Flash playback now, correct? But I have a higher up who wants it to be keyboard controlled as well.
I have two MovieClips, and both are controlled by keyboard events. One is a globe that I want to rotate in one direction or the other. The second is a walking animation that should change direction or stand still depending on which key is pressed or if none are.
Here is the AS Code: /*var rightDown:Boolean = false; var leftDown:Boolean = false; var upDown:Boolean = false; var downDown:Boolean = false;*/ stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); [Code] .....
You can see that I've tried a few different methods, but neither has worked correctly. Using the timer came close, but then the globe kept speeding up, and I couldn't get the walking animation to default back to the standing animation. Here is the .fla [URL].
needless to say, new to as3... What I want to do is control start and stop of stage playhead with keyboard control. What I have so far is the stop control, but cant figure out the play. I have tried setting a var and boolean, but am doing something wrong =( // heres my code
how to make an keyboard event listener control a button to have it make a sound. i am making a drum kit that you will be able to play using specific key on the keyboard. i have it built and functioning with just using mouse clicks but for my end result i would like to have the keyboard and mouse be able to control it.
I have a simple flash project with a TV and a remote control. right now there are arrow buttons on the remote control that i have setup so that when you click on the button it goes to another frame. now my client wants it also setup so that when they hit the arrow buttons (up, down, etc) that it goes to a certain frame.
I recently stumbled upon a site called 'The Influence Project' which allows the user to control a infinite wall of photographs in space with the keyboard.You can check out the site here http:[URL]....
I do not know how to insert an animation stops to give the presenter time and forward or backward in a linear and PowerPoint by pressing any key. Similar to typical PPT slideshows and will insert a small clip light and animation films. "My idea is that every time they click on any key (no button) on the film, forward motion up to a certain frame and so on until the end of the presentation "
I have the follwoing code to control a Flash-based presentation but BACKSPACE and ENTER lkey are not working. I am puzzled. PD: All the rest of the keys works fine.
by default the flash slider component can be manipulated with the keyboard. Is there a way to disable this behavior so that users can only drag the slider component with their mouse?
I'm completely new to AS3/Flash programming, though I program in C/C++/C# in my job. These days I got a project idea which I think Flash would better fit than the other languages I mentioned above. I want to create an on-line automation application that can:
1. Control user mouse clicks, or eventually keyboard, pressing some keys;
2. Communicate/connect to the user's bluetooth device, establishing connections to the mobile devices attached to it - the web application in this case would act as a server.
If I plan to implement 100 objects on stage to be listen to mouse and keyboard input, is using "function" call responsive enough? How good does eventlistner work?
Is there any way to create a keyboard shortcut using a the control button plus a key button. For example, if I want to print the screen, I would press control + p.
I have flash ui built over the chromeless youtube player right now and I'm wondering if there is anyway to set certain sprites within the stage to not scale on fullscreen without having to do inverted scaling.
Edit: I use FlashDevelop as my IDE and building this purely in as3
On frame 1 from the root I've the following script:
[Code]...
For some reason all three sound objects play at 5% of the volume (the volume that was set for "WhenTextAppears"). I want to controle the volume of the 3 objects seperatly,.... I thought the code above should do the trick but it doesnt.
I have some sounds in movie clips, this is because that is the only way to be able to select SYNC Stream mode (to keep the movie in sync with the narration). Thus I don't want to use Sound Objects because they can get out of sync... Is there any way to control volume (so I can mute) without using Sound Objects?
I have a fixed amount of words. Lets say 20 words. I want each of these words to be put into symbols - so i have 20 symbols (box1...box20). Now i want the boxes to fall from the top of the screen and until they reach below the screen. But (and this is where i'm lost) I want to have them fall at different speeds AND I want to control how many boxes falls at a time. Starting out with one box and when this box is out of the screen I want to control the amount of boxes/symbols entering the screen next.
A function telling that next there should be i.e. three boxes entering and falling/floating across the screen (from just above the top of the screen untill they all have reached the bottom). And i want to be able to call a function which starts X boxes - even before the existing boxes in the scenes has dropped). It would be nice to have a function, ie. fallBox(3) , which may be called at any time.
Using AS3, I was wondering how to control one object, a ball, while another ball bounces around. I'm modifying code from "Foundation ActionScript 3.0 Animation" by Keith Peters.
I'm pretty new so I'm probably making some obvious mistakes here. First of all I thought I could refer to the balls as ball[0] and ball[1] since they are in an array called ball. Is this correct?