Interaction With The Key Board: Moving Something With Arrow Keys
How can you program in flash so that you can use the arrow keys to control where an object moves (like a game). If you can help me, please give me an explaination of what you are doing because I am not ery good a flash. My flash version is Flash MX 2004.
Thanx everybody!
FlashKit > Flash Help > Flash General Help
Posted on: 06-23-2005, 04:49 AM
View Complete Forum Thread with Replies
Sponsored Links:
Moving MCs With Arrow Keys- Help
Hello, this is my first post in this forum.
I am asking how to move MCs with arrow keys, I have seen many different codes and they don't seem to work. I think my prolbem is I am entering (enterFRAME) wrong.
If you could, show an example of what code I would do if it was on frame 1
There may be a previous post, please link me there if there is.
View Replies !
View Related
Moving Around With Arrow Keys
i was trying to move an object around with the arrow keys in flash.
with this code
ActionScript Code:
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
this._y -= 5;
}
if (Key.isDown(Key.DOWN)) {
this._y += 5;
}
if (Key.isDown(Key.RIGHT)) {
this._x += 5;
}
if (Key.isDown(Key.LEFT)) {
this._x -= 5;
}
}
But it won't work, and i got the error "1087: Syntax error: extra characters found after end of program.
View Replies !
View Related
Moving MC Smoothly With Arrow Keys
I am building a small race game. I have a vehicle that moves left and right to avoid oncoming objects.
My problems is when I hold the left or right arrow key down to move the car, the MC moves one space, stops, then continues to move left or right.
How do I get the car clip to move smoothly without the initial jerk?
thanks!!
View Replies !
View Related
Focus Moving With The Arrow Keys
I am developing a pure AS3 project, and I am trying to implement keyboard navigation for a listbox. However, I have found that focus moves to the next tabEnabled element when I press the up or down arrow key. Why is this happening and is there any way to prevent it or stop it?
Thanks!
View Replies !
View Related
Moving Multiple Mc's With Arrow Keys
I used the "Movement Using Keyboard Keys" by Kirupa. I have it working, but I want to move multiple mc's at the same time when I press an arrow key. Only the mc on my lowest level will move. How do I get all of them to move? Thank you for any help.
View Replies !
View Related
Moving Multiple Mc's With Arrow Keys
I used the "Movement Using Keyboard Keys" by Kirupa. I have it working, but I want to move multiple mc's at the same time when I press an arrow key. Only the mc on my lowest level will move. How do I get all of them to move? Thank you for any help.
View Replies !
View Related
Moving Sprite With Arrow Keys, Simultaneous Directions
Hi everyone.
I'm trying to create a small arcade style game, you control a small ship, shoot at incoming targets, try to dogde their shots, etc. I'm working on the ship's movement right now, using the arrow keys to control it. Getting it to move one direction at a time is easy, but sometimes I need to move it diagonally, otherwise I think gameplay will suffer considerably.
I have tried several things but I never seem to be able to tell Flash that two keys are being pressed simultaneously. Can anyone tell me how I might achieve this?
Thank you.
View Replies !
View Related
Arrow Keys?
Could someone tell me how to move an object around on the screen with the arrow keys. A step by step would me much appreciated.
and could someone tell me how to use the keyboard keys for buttons
View Replies !
View Related
Arrow Keys
OK folks. Here is a link to what I'm about to explain:
OK I have this page setup so that when you press the left and right arrow keys you will cycle through the pictures. It's working fine, the only problem is my boss noticed that you have to click somewhere on the flash animation in order to use the arrow keys when it first starts. I know this is probably a browser issue but is there any way that I can work this out so that you don't have to click on the animation first?
-= greendog =-
View Replies !
View Related
[F8] Using Arrow Keys
When you are using:
on (keyPress "<Left>") {
this._x -= 10;
}
on (keyPress "<Right>") {
this._x += 10;
}
on (keyPress "<Up>") {
this._y -= 10;
}
on (keyPress "<Down>") {
this._y += 10;
}
to make some thing move with the arrow keys, how can you make it so that it is smoot and slows down in stead of stopping fast (for racing game)
And on more thing How can i be able to use a,s,d and w to make a movie clip move (2 players)
Thanks in advance.
View Replies !
View Related
[F8] Arrow Keys
hi i got this startDrag code
Code:
square_mc.onEnterFrame=function(){
startStopInterval(true);
startDrag(this,true,30,32,211,259);
for(var i:Number = 1; i<=4; i++){
if (this.hitTest(this._root["bar"+i+"_mc"]))
this.stopDrag();
}
}
this basically allows the mouse to be drag in the document
just wondering, can i convert this code so that arrow keys can be used?
If so, how can i limit like here so they wont go off document.
Thanks
View Replies !
View Related
Arrow Keys
Im making a game that involves moving the character with the arrow keys. I want to know the code to make him be able to move move at a set speed on the X and Y axis.
Thank you
View Replies !
View Related
Arrow Keys
I've got a movie clip that contains an animated character.
In the first frame of the movie clip I have the character facing forward. In the second frame of the movie clip I have the same character turning profile.
On the main timeline I have an instance of this movie clip with an instance name of Freddy_mc.
The objective being that when the user presses the left arrow key the Freddy_mc jumps to its next frame showing the animated character in profile.
All of this I have accomplished with the following code on my actions layer in my main timeline (and this much works fine):
var xv = 15;
Freddy_mc.onEnterFrame = function ():Void {
if (Key.isDown(Key.LEFT) {
this._x -= xv;
this.nextFrame();
}
As I said, this much works fine.
My problem/question is this: when the left arrow key is released I want the Freddy_mc to revert back to its frame one so that the character is once again facing front.
The obvious thought might be Key.isUp - except there is no such method of the Key class. Nor a Key.release.
Any thoughts would be appreciated.
View Replies !
View Related
Plane With The Arrow Keys
okay,
I want to make my plane face down and move down when i push the down key, may plane face up and go up when i push the up key and so on.
So far it moves but does not change direction.
How do you do this?
View Replies !
View Related
Combobox Bug When Using Arrow Keys
Hi,
I was wondering if anyone encountered a bug using a combobox(flash MX).
When I use a combobox in a form, it works fine with the mouse; showing all labels etc. However when I use the arrow keys to make a selection instead of using the mouse I sometimes get an empty value if I press the up key several times as soon as I enter the combobox. When I than post the form, the combobox value is thus Null.
Anyone dealt with this before, and perhaps knows a work-around to avoid this?
cheers
Patrick
View Replies !
View Related
Arrow Keys Input
I want to call the specific key on keyboard to control a specific action on screen.
e.g . when i press down the "down arrow key", i want my movie go to the nextFrame();
what should i do?
View Replies !
View Related
Trap Arrow Keys
I have a movie clip controlled by user ARROW key input. At one point, I want to disable the arrow keys for a few frames so that the user can't move. How do I stop the arrow key functionality? Or, do I simply swap the mc for a graphic for those frames?
Thanks all.
View Replies !
View Related
Free The Arrow Keys;-)
Hi,
I would like to have your point of view and benefit from your experience about this;-)
I have to realize an interface that would be "keyboard only" you would navigate it with arrow keys and select with space bar for instance.
When this menu appears, the user, using the arrow keys, navigate freely through the "buttons" (I suppose that it would rather be MobieClip?).
For instance, starting from "ON", one should be able to go right and highlight "OFF"...or go down and highlight "Option1"
The movieclip would react like a button, with different states for "highlighted", "on" or "off".
(I join this picture so that you can see better what's to be achieved:
In this picture "On" & "Option2" are selected, "Off" is unselected but with an "highlighted" state, "Option1" & "Option3" are unselected)
What's your feeling about that? What would be the best way to handle this?
Thanks very much by advance for taking of your time ;-)
View Replies !
View Related
Scroll Box With Arrow Keys?
Hello,
I'm needing to make a text box / scroll bar that works with Up and Down arrow keys rather than the typical mouse drag. It seems like that'd be easy enough, but honestly I'm stumped. Anyone have any advice or possibly a tutorial or sample file? By the way, it needs to be in AS2.
Thanks!
Jason
View Replies !
View Related
Arrow Keys And Focus
I created a slider in AS2 that I was converting to AS3. Basically it's a long bar with a handle that you can slide to different points to select different values.
In the AS2 version in addition to using your mouse, you can tab to the handle and use your right and left arrow keys to move it to the proper position. Using your arrow keys will usually shift focus to the next object, so I used Selection.setFocus() to keep the focus on the handle.
So, in the AS3 version I was trying to do the same thing. I've tried things like:
stage.focus=handle, this.stage.focus=this.handle, stage.focus=e.target (e.target is the same as handle in this case).
No matter what I try, pressing the right arrow will shift focus to anything to the right of the handle, and pressing left will shift focus to anything to the left of the handle.
What am I missing here?
View Replies !
View Related
Arrow Keys For Navigation
ok i'm making a game and i need help for navigation with the arrow keys. all i want is to use the right and left arrow keys to go to the next frame and last frame, repectivley. please help :s this is what i used but it didint work :
ActionScript Code:
on (Key.isDown(Key.RIGHT)){
gotoAndPlay(2);
}
View Replies !
View Related
Major Help With Arrow Keys
ok...i know NOTHING about actionscripting. See i have this movie clip. (made with sprites) and its moving in one direction, constantly. exactly what do I do to make it so that when someone presses the up arrow key, the clips direction (meaning the character for the movie clip is facing up) goes up and so forth. Where do I put the action script...and how can i make it so that it can face the direction its moving??
please please help me...Ive been trying to find an answer to this question all day
View Replies !
View Related
Free The Arrow Keys;-)
Hi,
I would like to have your point of view and benefit from your experience about this;-)
I have to realize an interface that would be "keyboard only" you would navigate it with arrow keys and select with space bar for instance.
When this menu appears, the user, using the arrow keys, navigate freely through the "buttons" (I suppose that it would rather be MobieClip?).
For instance, starting from "ON", one should be able to go right and highlight "OFF"...or go down and highlight "Option1"
The movieclip would react like a button, with different states for "highlighted", "on" or "off".
(I join this picture so that you can see better what's to be achieved:
In this picture "On" & "Option2" are selected, "Off" is unselected but with an "highlighted" state, "Option1" & "Option3" are unselected)
What's your feeling about that? What would be the best way to handle this?
Thanks very much by advance for taking of your time ;-)
View Replies !
View Related
Navigate XML With Arrow Keys?
Hi all --
I have a dynamic XML-driven drop down menu I modified from Kirupa. It works great, except I'd like to be able to step through the nodes with the arrow keys (the site is a portfolio for a friend of mine). I can't find any info on how to go about this. See it working without arrow keys at http://www.culturedesign.com/projects/hochstrasser/
AS (Kirupa):
Code:
// generates a list of menu items (effectively one menu) given the inputted parameters. This makes the main menu as well as any of the submenus
GenerateMenu = function(container, name, x, y, depth, node_xml) {
// variable declarations
var curr_node;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name, depth);
// for all items or XML nodes (items and menus) within this, node_xml passed for this menu
for (var i=0; i<node_xml.childNodes.length; i++) {
// movieclip for each menu item
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
curr_item._x = x;
curr_item._y = y + i*curr_item._height;
curr_item.trackAsMenu = true;
// item properties assigned from XML
curr_node = node_xml.childNodes[i];
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
curr_item.client = curr_node.attributes.client;
curr_item.project = curr_node.attributes.project;
curr_item.body = curr_node.attributes.body;
curr_item.image = curr_node.attributes.image;
// item submenu behavior for rollover event
if (node_xml.childNodes[i].nodeName == "menu"){
// open a submenu
curr_item.node_xml = curr_node;
curr_item.onRollOver = curr_item.onDragOver = function(){
var x = this._x + this._width + 1;
var y = this._y;
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
// show a hover color
var col = new Color(this.background);
col.setRGB(0x1a1c09);
};
} else { // nodeName == "item"
curr_item.arrow._visible = false;
// close existing submenu
curr_item.onRollOver = curr_item.onDragOver = function(){
curr_menu.submenu_mc.removeMovieClip();
// show a hover color
var col = new Color(this.background);
col.setRGB(0x1a1c09);
};
}
curr_item.onRollOut = curr_item.onDragOut = function(){
// restore color
var col = new Color(this.background);
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
// any item, menu opening or not can have actions
curr_item.onRelease = function() {
Actions[this.action](this.image);
Actions[this.action](this.variables);
_root.nav_mc.client.text = this.client;
_root.nav_mc.project.text = this.project;
_root.nav_mc.body.text = this.body;
CloseSubmenus();
_root.nav_mc._visible = false
_root.invisible_btn._visible = true;
};
} // end for loop
};
// create the main menu, this will be constantly visible
CreateMainMenu = function(x, y, depth, menu_xml){
// generate a menu list
GenerateMenu(this, "mainmenu_mc", x, y, depth, menu_xml.firstChild);
// close only submenus if visible durring a mouseup, this main menu (mainmenu_mc) will remain
mainmenu_mc.onMouseUp = function(){
if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
CloseSubmenus();
}
};
};
// closes all submenus by removing the submenu_mc in the main menu (if it exists)
CloseSubmenus = function(){
mainmenu_mc.submenu_mc.removeMovieClip();
};
// This actions object handles methods for actions defined by the XML called when a menu item is pressed
Actions = Object();
Actions.gotoURL = function(urlVar) {
getURL(urlVar, "_blank");
};
Actions.message = function(msg) {
message_txt.text = msg;
};
Actions.newMenu = function(menuxml) {
menu_xml.load(menuxml);
};
// image loader
Actions.loadImage = function(img) {
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);
function onLoadInit() {
};
loader.loadClip(img, _root.image_mc);
};
// load XML, when done, run CreateMainMenu to interpret it
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
// create main menu after successful loading of XML
if (ok) {
CreateMainMenu(10, 10, 0, this);
message_txt.text = "message area";
} else {
message_txt.text = "error: XML not successfully loaded";
}
};
// load first XML menu
menu_xml.load("hochstrasser.xml");
***
XML sample (I'd like to jump from ITEM to ITEM and populate with those attributes):
Code:
<menu name="POP">
<item name="Box"
client="SANTA CRUZ"
project="POP"
body="Bindings packaging design for the seasons 2005/06 and 2006/07."
action="loadImage"
image="images/sc_box.png"/>
<item name="Sticker"
client="SANTA CRUZ"
project="POP"
body="Board explanation sticker and warranty information."
action="loadImage"
image="images/sc_brdsticker.png"/>
<item name="Buttons"
client="SANTA CRUZ"
project="POP"
body="Giveaway buttons."
action="loadImage"
image="images/sc_buttons.png"/>
</menu>
Mac OS X, Flash 8 Pro, AS 2, Flash Player 8/9
View Replies !
View Related
Navigation Bar Using The Arrow Keys
OK, I have to make a interface much like the ones you see on your television when you press the 'red button'.
I have a selection of 5 buttons on my main page, each leading to other pages. Now, I need to be able to select these buttons and click on them without using the mouse. So in other works, I need to navigate them using the Arrow Keys and then use the Enter button the select it and go to the next page.
I was wondering what would be the best way to do this. I'm having a problem finding a tutorial for it. I did find away to do this but I can't remember how I did it and the .fla file which I saved on Flash MX on a MAC, will not open on Flash MX on my PC!
Thanks in advance peeps! I really need help with this asap
View Replies !
View Related
Disable Arrow Keys
Hi,
I hope someone can help me out... I'm building an app in Flash8 which used the arrow keys to position movieclips. On the right side of the screen I placed a few components like radiobuttons and comboboxes. When one of these is clicked on (received focus) it starts responding to the arrow keys. I've tried removing focus, but can't get that to work. What I really would like to do is remove the listeners from the components...
Can anybody please help me out? Thanks in advance.
Rick.
View Replies !
View Related
Easing With Arrow Keys
Hey there..
I can't seem to figure this out, I'm trying to make easing movement using the arrow keys..!?
Here's what I'm working with:
ActionScript Code:
speed = 20;MC.onEnterFrame = function() { if (Key.isDown(Key.UP)) { rotrad = MC._rotation/57; ymove = speed*Math.sin(rotrad); xmove = speed*Math.cos(rotrad); _x += xmove; _y += ymove; }
Any help would be awesome
View Replies !
View Related
Free The Arrow Keys;-)
Hi,
I would like to have your point of view and benefit from your experience about this;-)
I have to realize an interface that would be "keyboard only" you would navigate it with arrow keys and select with space bar for instance.
When this menu appears, the user, using the arrow keys, navigate freely through the "buttons" (I suppose that it would rather be MobieClip?).
For instance, starting from "ON", one should be able to go right and highlight "OFF"...or go down and highlight "Option1"
The movieclip would react like a button, with different states for "highlighted", "on" or "off".
(I join this picture so that you can see better what's to be achieved:
In this picture "On" & "Option2" are selected, "Off" is unselected but with an "highlighted" state, "Option1" & "Option3" are unselected)
What's your feeling about that? What would be the best way to handle this?
Thanks very much by advance for taking of your time ;-)
View Replies !
View Related
Navigate XML With Arrow Keys
Hi All --
I've successfully downloaded and modified the XML Based Drop Down Menu from Kirupa (thanks a TON for breaking it down so well in the tutorial).
The only thing I wish it did was allow me to step through each node by using the left and right arrow keys. Has anyone tried modify the existing Drop Down Menu script to do that? Everything I've seen about XML looks like I'll have to write crazy loops that I just don't get...
Any help would be appreciated. Thanks!
Me: OS X, Flash 8 Pro, AS 2.0, Flash Player 8
View Replies !
View Related
[AS2] Using Arrow Keys For Selection [HELP PLS]
I'm in need of some help.
I am trying to create a four button system that is controlled using either your mouse or arrow keys.
I need to create a Key Listener to allow the highlighting and selecting of each button . The arrow keys allow you to select button when you reach the last button it returns to the first button, and the enter key allows you to select the button.
I just can't figure this out....any help would be appreciated!
View Replies !
View Related
Easing With Arrow Keys
Hey there..
I can't seem to figure this out, I'm trying to make easing movement using the arrow keys..!?
Here's what I'm working with:
ActionScript Code:
speed = 20;MC.onEnterFrame = function() { if (Key.isDown(Key.UP)) { rotrad = MC._rotation/57; ymove = speed*Math.sin(rotrad); xmove = speed*Math.cos(rotrad); _x += xmove; _y += ymove; }
Any help would be awesome
View Replies !
View Related
Free The Arrow Keys;-)
Hi,
I would like to have your point of view and benefit from your experience about this;-)
I have to realize an interface that would be "keyboard only" you would navigate it with arrow keys and select with space bar for instance.
When this menu appears, the user, using the arrow keys, navigate freely through the "buttons" (I suppose that it would rather be MobieClip?).
For instance, starting from "ON", one should be able to go right and highlight "OFF"...or go down and highlight "Option1"
The movieclip would react like a button, with different states for "highlighted", "on" or "off".
(I join this picture so that you can see better what's to be achieved:
In this picture "On" & "Option2" are selected, "Off" is unselected but with an "highlighted" state, "Option1" & "Option3" are unselected)
What's your feeling about that? What would be the best way to handle this?
Thanks very much by advance for taking of your time ;-)
View Replies !
View Related
Free The Arrow Keys;-)
Hi,
I would like to have your point of view and benefit from your experience about this;-)
I have to realize an interface that would be "keyboard only" you would navigate it with arrow keys and select with space bar for instance.
When this menu appears, the user, using the arrow keys, navigate freely through the "buttons" (I suppose that it would rather be MobieClip?).
For instance, starting from "ON", one should be able to go right and highlight "OFF"...or go down and highlight "Option1"
The movieclip would react like a button, with different states for "highlighted", "on" or "off".
(I join this picture so that you can see better what's to be achieved:
In this picture "On" & "Option2" are selected, "Off" is unselected but with an "highlighted" state, "Option1" & "Option3" are unselected)
What's your feeling about that? What would be the best way to handle this?
Thanks very much by advance for taking of your time ;-)
View Replies !
View Related
[mx] Switching Keys On Key Board
i was wondering if anyone knows a way to change what letter is typed when a key is pressed. for instance if the "b" is pressed on the keyboard it will put a q in a text box. i just want to have the keys on the keyboard type different letters when they are pressed. please let me know what you think.
View Replies !
View Related
Move A Mask With The Arrow Keys?
OK, I want to be able to move the background of a mask using the arrow keys (or perhaps the mouse?) I have a background and a circle in the centre of the stage. The background shows through the centre of the circle. And out side the circle is just a black fill. Now all i want to do is be able to move the background using the arrow keys so you see the background moving through the circle. Can someone please help me ASAP. Thanx in advance for your help
View Replies !
View Related
Adding Arrow Keys Control
I've been trying to work out how to get this script to work with mouseMove AND Key.isDown control:
Code:
onClipEvent(load){
scrollIN = _root.range._y-_root.range._height
scrollOUT = _root.range._y
lowestScale = 180
highestScale = 12000
_y = scrollIN + (scrollOUT - scrollIN)/1
scaleFactor = Math.pow(highestScale/lowestScale,1/(scrollOUT-scrollIN))
function SetScale(){
_root.scale = _root.map._xscale = _root.map._yscale = lowestScale * Math.pow(scaleFactor,(scrollOUT-_y))
}
SetScale()
}
onClipEvent(mouseMove){
if (dragging){
_y = Math.min(Math.max(_parent._ymouse,scrollIN),scrollOUT)
SetScale()
updateAfterEvent();
}
}
The mouseMove is working fine on my slider, but I am having no luck getting it to work with Arrow Keys.
I've been trying something like this:
Code:
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this._ymouse -= scrollIN;
}
if (Key.isDown(Key.RIGHT)) {
this._ymouse += scrollOUT;
}
}
As you can see, I have it all wrong.
Any mathematicians or actionScripters able to point me on the right path?
Thanks.
Note
I'm trying to get this to be Flash5 compatible, but it isn't mandatory.
View Replies !
View Related
Arrow Keys To Next/prev Frame
Please can anyone tell me how to make a Flash movie so that the keyboard arrow keys may be used to goto the next/prev frame and the up/down arrow keys may be used to goto the first/last frames.
Obviously I could add this actionscript to next/prev buttons in the movie but I'd just like to include a keyboard option as well as the mouse one.
View Replies !
View Related
Arrow Keys To Joystick Control
Hi all, does anyone know if it is possible to substitute arrow key commands for a joystick?
I have a game that will be (hopefully, if possible!) used on a exhibition stand and people will play it using a joystick. Is that possible?
Has anyone seen any good tutorials or anything that will get me started???
Diggz
View Replies !
View Related
Using Arrow Keys To Move An Object
I use the left arrow to make my helcipter move to the left. I would like it to react emediatly when pressing the left key but there goes half a second before it moves. Just like when moving the curser in word. DOes anyone know how to fix this?
The code I use:
on (keyPress "<Left>") {
helicopter_mov._x = helicopter_mov._x - 5
}
Hope we have a genius among us
View Replies !
View Related
Move A Movieclip With Arrow Keys
I wanna
move a movieclip over the screen by using the arrow keys on my keyboard.
as longer you press one key, the more power it should have.
when hitting the edges it should bounce back.
how can I do that?
hope someone can help me
View Replies !
View Related
|