ActionScript 2.0 :: Key Movement - Moving Object With WASD
Mar 24, 2005
I am looking for the AS for moving an abject with WASD. I had it working with Key.Left, Key.Right, Key.Up, and Key.Down but I want to change them to WASD.
Code:
if (Key.isDown(Key.LEFT)) {
this._x+=moveSpeed;
} else if (Key.isDown(Key.RIGHT)) {
this._x-=moveSpeed;
} if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}}
View 12 Replies
Similar Posts:
Jun 26, 2009
I have made a class file player and another class file landscape. The player class file has methods that allow the player to move. Where would I put code to make the landscape move with the player? Would the code go into the player class file or the document class file? I don't know how I could link the landscape movement with the player movement
player.as class file
Code:
//the package
package actionscript{
import flash.display.*;
import flash.events.*;
import flash.media.*;
[Code] .....
View 2 Replies
Oct 11, 2004
i need a movement script that makes an object move to where i want it to then stop. i cant seem to find a script for this anywhere.
View 4 Replies
Jun 8, 2005
how do i stop the movement of an object moving from left to right. I want to be able to place it anywhere id like.
View 2 Replies
Aug 9, 2011
I'd like to control a mc movement on_x direction (or _y) when the mouse mouves horizontaly (or verticaly). So when I mouve the mouse to the right the mc mouves to the lefht and it mouves to the right when the mouse moves to the lefht. It's for a window effect.
View 8 Replies
Feb 15, 2010
I would like to create something similar to this: and only need a few things to complete it.What is missing is to make the whole flash movie (the white area, including the watches and cursor) move from left to right and right to left depending on the movement of the cursor (round circle) .. Panning effect I have attached the file i am working on..maybe that makes it easier to understand
View 5 Replies
Nov 29, 2010
I was wondering if it was possible to move a MClip from a defined "point A" to a defined "point B" (precisely), but this with a "snake or bubble" movement (or something like that).
View 8 Replies
Feb 15, 2011
I'm trying to let my ship move with WASD.I've got it to work with the arrow keys, no problem.It seems to be the problem that my event isn't triggered when i press W, A, S or D. Because,when i place a trace(event.keyCode), it doesn't trace anything.I'm using this within a class.Here's my (part of the) code:
Code:
public function ship() {
stage.addEventListener(KeyboardEvent.KEY_DOWN, keysDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keysUp);[code]..
In the code above, the W key doesn't work. But the left, right and down arrow keys work fine.If i change those to the corresponding key values of a, s and d.It doesn't work anymore.
View 4 Replies
Dec 2, 2009
I found this AS2 tutorial online but I'd like to achieve this in AS3. I tried transcribing but the setProperty is throwing me off.
[Code]...
View 7 Replies
Jan 3, 2010
I am about to make a gallery where all the pictures are ligned up, in a vertical row collum.I wan to make the Movieclip move in the opposite direction of my mouse movement
View 2 Replies
Jun 17, 2010
I have a challenge in a flash movie with TabIndex that involves some pretty comprehensive keyboard functionality and have solved the problem but the client is not madly happy with the solution. Problem is I don't know whether there is another way of solving it.
I've built a app the allows the user to upload a picture and manipulate it using marker placement. You can either drag the markers with the mouse or using tabIndex can tab through them then, once highlighted, you can move each marker up, down, left and right using the WASD keys.
I thought this was a nice solution since gamers are familiar with WASD to move directionally, however the client wants to use the arrow keys for this function. The problem resides in the fact that within the tabindex the arrow keys act in the same way as the tab, in that they tab forward or back through the index.
Client suggest tabbing to marker, clicking ENTER to disable tabbing, using the arrows to move the marker, then clicking ENTER again to re-enable the tabbing, move to the next marker, click ENTER to disable... etc etc.
View 0 Replies
Jan 8, 2011
how i can stop the movement of one object when one other object is over one third object
View 1 Replies
Feb 23, 2012
I am trying to do a apply a tween for the width property on a MovieClip Object but every time it changes the width and the position too, and I don't want that. I want to change the width going to one side without changing the x and y of the object.
I tried both of thes and they gave the same result.
var c:Tween = new Tween(left, "scaleX", Strong.easeOut, 1, 1.5,20,true);
var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);
I think it is applying the transformation according to a center of the movie clip. but I don't know how it can be changed.
View 2 Replies
Apr 13, 2011
Im working on a small project and it involves a guy which you move with the arrow keys. The arrow keys add to his x, y velocities and his position is updated accordingly. How can i get this man to grab onto an object and spin around it (like when you grab pole and letting your momentum swing you around) . I can make him grab the object but I dont know how to modify his x,y speeds to simulate the arc.
View 4 Replies
Oct 13, 2010
my title explains what im need but im using flash cs4 and heres what i have so far:
var centerX:Number;
var centerY:Number;
var centerZ:Number;
[Code].....
ok so RBall is my first moving object and my orbiting object will be called orbit
View 9 Replies
Jul 13, 2004
I have 10 images in 10 frames ( 1 image per frame ). So I'm trying to make the frame to go to the next one when the mouse is moved to the right, and make the frame to go to the prev one when the mouse is moved to the left.
View 14 Replies
Apr 14, 2011
i want to create a keyboard-controlled "wasd" game with proper hitdetection,doing this tilebased is no feat and is pretty straightforward.But say i want to do this in the fashion for a game like WoW, and things quickly starts getting trickier.How would i resolve something like this with AS3? One possible solution would be to implement Box2D, but since I'm planning to make a rich 3d-game, the question is whether 2d collision-detection will be sufficient. What options are there for collision-detection in AS3 if the aim is to create a game with similar mechanics to WoW?
View 1 Replies
Oct 9, 2009
I made a code which is supposed to move an object (Character) to the location of a button (1). I tested it, and it won't work.[code]I've attached the code directly to the button, but I just can't figure out what is wrong. Does anyone know?
View 21 Replies
Mar 16, 2011
I have an object who's movement I want to limit to a small rectangle on the stage.
View 6 Replies
Jul 27, 2006
well I have this frame as a movieclip called field. And inside it, there's another mc that is moved by the cursor keys called box. Now I have created another movie clip called boxclone. I want boxclone to make the same movement as the box in the field. I know it has something to do with localToGlobal but I don't know how to setup the code correctly...
View 3 Replies
Feb 5, 2010
I've made a sort of sliding menu in Flash (CS4) which is basically a movie clip that has a function assigned to it that if the cursor goes over a button it starts moving in a direction.
Code:
_root.right.onRollOver = function() {
goRight = true;
};
[Code]....
Now, I don't want that "content" object to slide all the way out of the screen. How can I make it stop at certain position, say x=770? Or is there any better way?
View 3 Replies
Nov 17, 2010
So I have so parts of actionscript which I am figuring out on how to make them one. What I am wanting to do is move an object to the right and fadeout. Here is my code to animate right 10 pixels, this works perfectly.
[Code]....
View 2 Replies
Jun 13, 2011
Trying to use an enterFrame event in conjunction with two functions that combined I want to move my object (a square) from the right to the left side of the screen and rotate it AROUND THE CENTER.When I use the following functions individually, they both work fine:
Actionscript Code:
//Centering function function rotCenter (ob:*, angleDegrees:Number, ptRotationPoint:Point) { var m:Matrix=ob.transform.matrix; m.tx -=
[code].....
View 1 Replies
Apr 20, 2009
I am trying to get an object to track my mouse on press and i am using a tween. However, the nature of the tween is such that the time taken for the object would move would always be constant despite the distance.
I would like to make the object travel at a constant speed regardless of the distance. Is it correct for me to use a tween? If not what should I be using?The code for my tween is as follows.
map_mc.tracker_mc._x = map_mc._xmouse;map_mc.tracker_mc._y = map_mc._ymouse;startx = map_mc.crosshair_mc._x;endx = map_mc.tracker_mc._x;starty = map_mc.crosshair_mc._y;endy = map_mc.tracker_mc._y;
trackTweenx = new Tween(map_mc.crosshair_mc, "_x", Regular.easeIn, startx, endx, spd, true);trackTweeny = new Tween(map_mc.crosshair_mc, "_y", Regular.easeIn, starty, endy, spd, true);
map_mc.tracker_mc is the mouse cursor that would appear when onPress while the map_mc.crosshair_mc is the object that would track my cursor's movements.
View 1 Replies
Jan 23, 2009
I have an object that is being moved along it's x axis a certain amount each time an button is pressed. I want to be able to restrict the movement of that object along it's x axis so that it can not go past a certain point.
View 2 Replies
Jan 18, 2010
Let's say you have a room, and a little circle representing the player. Let's say also that you decide to draw a shape overlapping the room, set alpha to 0%, and use hitTestPoint() between this shape and the player to create the movement boundary. In short, as long as the player's centerpoint is overlapping the invisible shape, he/she is free to move around.Now, I decided to make things more complicated and add an obstacle to the room - a table in the center. One would think that cutting a rectangle out of the middle of the invisible shape would prevent the player from being able to move there. No dice, the player passes right through the hole in the middle of the invisible shape. The problem, as I see it, is that when the shape is converted to a symbol for use in actionscript, the entire volume of the movie clip is used for collision detection, not just the shape's volume. No matter what options and settings I play with, I can't get the hole in the shape to stay cut-out when I convert the whole thing to a symbol.
Now, I know I could probably add an extra shape to represent the obstacle, and add extra collision detection into my actionscript. However, given that there will be a large number of rooms in the game, and a variable number of obstacles in each room, this is not an elegant solution. The most elegant solution would be to figure out a way to map the playable area in a room with a single movie clip (/graphic).So, I turn to you fine folk. Can anyone tell me how to convert a shape to any kind of symbol, and preserve features like holes within the shape (as in, not have them glazed over as part of the symbol's body
View 5 Replies
Apr 4, 2005
I hope that this topic hasn't been discussed ad nauseum; I searched the forums for similar discussion threads to no avail. I completed the Flash MX object movement tutorial found at [URL].I then wanted to add a second instance of the beetle symbol to the stage and assign it both a new instance name and a different set of keyboard keys that would control its movement.
When I test the movie, I am able to control each symbol instance with its assigned keys. (The instances move and rotate as they should.) However, when the first instance rotates and moves to the right, the second instance "slides" with it. That is, the second instance's assigned keys have not been pressed and it doesn't rotate, but it moves right in unison with the other instance.
View 6 Replies
May 21, 2009
making a game, and in html, on press arrow key up or down, moves the object and the screen
View 2 Replies
Jun 24, 2009
make snap object on the mouse movement. As, I have made the code but getting issue on removing from snapping. I have attached the file. you can look in the [URL]
View 1 Replies
Apr 4, 2005
I searched the forums for similar discussion threads to no avail.I completed the Flash MX object movement tutorial found atI then wanted to add a second instance of the beetle symbol to the stage and assign it both a new instance name and a different set of keyboard keys that would control its movement.When I test the movie, I am able to control each symbol instance with its assigned keys. (The instances move and rotate as they should.) However, when the first instance rotates and moves to the right, the second instance "slides" with it. That is, the second instance's assigned keys have not been pressed and it doesn't rotate, but it moves right in unison with the other instance.
View 6 Replies