ActionScript 3.0 :: Moving Character - Unable To Use "Key" To Identify A Pressed Key
Aug 2, 2011
So I'm new to Flash, and I've found most people make player controlled characters in Flash move through
[Code]...
Since these are ActionScript 2.0 source codes, I think ActionScript 3.0 won't let me use "Key" to identify a pressed key.
View 1 Replies
Similar Posts:
Nov 2, 2010
im currently making an "AS3 beat em up" ala streets of rage or double dragon.Currently i have my character moving and a few animations done and i am trying to figure out how to make attacks work.I have some "basic" animation for his attack, but im not sure how to get it to work correctley.What happens is, if you press control (the attack button) whilst the character is walking he just keeps moving and is stopped on the attack frame.I want the character to stop moving if the attack is pressed and once it is released start moving again.
hero.gotoAndStop('still');
var left:Boolean = false;
var right:Boolean = false;[code].......
View 2 Replies
Jul 31, 2011
I am trying to retrieve mysql data using php(products.php) and return the data in xml format to ADobe flash as3; but i am getting following error.[url]...
I have WAMP installed; which works fine as i have many other php projects working here.[code]...
View 2 Replies
Jan 13, 2004
I would like my character to move as if he was drunk I am unsure how to do that I am using the keyboard for his movement. I also have a character that moves at random I would like the drunk moving character to be able to catch this character and play a scene from within the drunk characters movie clip but I want this character to try and escape the idea is the drunk character gets points for how long he is able to hang on to this character
View 2 Replies
Dec 27, 2010
I can't use charCode, or keyCode in KeyboardEvent to find out the character pressed, because even if I change the keyboard layout, charCode and keyCode are not change (if press the same key).So, how to find the presssed character, following to the current keyboard layout?
The charCode property is the numeric value of that key in the current character set (the default character set is UTF-8, which supports ASCII).is not correct.
View 3 Replies
Aug 12, 2010
I am testing this script (in flash cs5 as2) on a simple character (a dot).The script implies that the character goes up when space bar is pressed down and that he will otherwise continue to fall due to the artificial gravity i have applied.My problem is that you can only click space bar once and make it go up and then after that it will fall and space bar wont work.the problemThis is the script.
onClipEvent (load) {
acc = 2;
time = 0;
[code]......
View 4 Replies
Sep 30, 2011
Im trying to make my character attack, the attack animation is inside the character movie clip on frame 4. But i dont understand how to do it? I want him to attack once, if SPACE is pressed. I have tried this:
[Code]...
View 1 Replies
Aug 23, 2011
The character will then be moving along a circular path. (A motion guide)ow I need to set it so that it plays the animation of moving up-left when the character is moving in the up-left direction and load the coresponding animations depending on the direction the character is moving. How do I go about doing this?
View 3 Replies
Jun 21, 2006
I want this code to move my map i.e map_mc when the keyboard keys are pressed. When I add it to the map_mc, I see no effect what do u think I am messing with.
Code:
on (keyPress "<Left>") {
currentX = this._x;
this._x = currentX - 2;
} on (keyPress "<Right>") {
currentX = this._x;
this._x = currentX + 2;
} on (keyPress "<Up>") {
currentY = this._y;
this._y = currentY - 2;
} on (keyPress "<Down>") {
currentY = this._y;
this._y = currentY + 2; }
View 3 Replies
May 12, 2010
I am trying to assign buttons my on my 'gameScreen' to move my character. though I am receiving an error msg saying: Error #1010: A term is undefined and has no properties.at Mainas()
package{
import flash.display.MovieClip;
import flash.events.MouseEvent;[code]....
View 3 Replies
Sep 12, 2004
what i am trying to do is get the background to move with the characteri checked out a few tutorials.but not enufheres the deal..i have a character that can fly...and when the character goes upward...thebackground moves down to expose sky..then eventually black space with stars...does that make sense?
View 2 Replies
Apr 15, 2002
i posted up lookin for flash tutes to make my game in flash 4 but i guess it's virtually impossible to do so..... well, now i decided to do it in flash 5. here's my concept >
it's basically a game controllling a character to move in grid filled with objects like so >
1 0 1 0 1 0 1 0 1
0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 1 0 1
where 0 (path) is passable n 1 (objects)not....
n i want d character to stand still when not moving and get to an animated frame of it moving when moved in whichever direction. i guess dat's all i need for now. please help me with this as like i've said, i kinda new to actionscripting.
View 14 Replies
Jul 26, 2011
At the first scene of the game My hero character stands still when he's idle but at the second scene he keeps walking in one spot when he's idle. What's going on? Why are the scenes messing with the hero character?
View 2 Replies
Sep 12, 2004
what i am trying to do is get the background to move with the character.i have a character that can fly...and when the character goes upward the background moves down to expose sky..then eventually black space with stars also i want the background to stop..like when the background ends.
View 2 Replies
Aug 17, 2009
i got my character to move left, right, down and up wit this code:
[Code]....
My question is, how can i block the up and down movement? I tried simply deleting some part of the script to block does movement from the user. But then the script would not work properly : s Here is the uploaded page i'm working on: link.
View 2 Replies
Apr 8, 2011
I'm brand new to flash and want to create a character with moving legs. I've created the character with legs, but don't know how to get them moving properly. Does anyone know a good tutorial?
View 2 Replies
Oct 9, 2011
I want to stop the movieclips movement when it hits a wall (another movieclip). The example below works, but after the collision the movieclip 'blocks' all movement to the left...
For now the example with the leftArrow key;
variables to check the key, if it's hitting the walls and if it's moving or not:
var leftArrow:Boolean;
var speed:int = 10;
var hitting:Boolean;
[Code]....
View 2 Replies
Jan 3, 2010
I have a character with multiple animations by way of movieclips, and I'm trying to have it move using the Key.isDown function. Now, my character is moving correctly, but when the key is released, the animation keeps playing. I tried adding a stop command at the end of the walkcycle animation, but that just causes the character to stay frozen on the last frame of the cycle.
Here is the ActionScript Code:
onClipEvent(load) {
var direction = "left";
var speed = 2;
} onClipEvent(enterFrame) {
[Code] .....
View 3 Replies
Mar 1, 2011
I need to get my character to follow an moving object. I've got an object that's moving around in different directions and I'm wondering how do I get my character to follow the movements when standing on the object ?
View 0 Replies
Jun 6, 2011
I am trying to limit the area in which the character (mcMain) can move I want to be able to keep it in an area (mcBuilding) I also have another area (inwhich the character is not supposed to get to) (mcBackground). (Also I want to be able to to make a dynamic text box that starts at 100 then decreases by 5 when the enemy (mcEnemy) hits mcBuilding and also that it gets removed)
View 1 Replies
Mar 15, 2011
I have a mc called boy and I have an instance of that mc called boy_mc. I have figured out how to make his position change on the stage, but I cannot figure out how to do some other things.
Here is the code that I have so far:
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(evt:KeyboardEvent):void{
switch(evt.keyCode) {
[Code] .....
I am trying to learn 3 things.
1. How do I make him be facing left when I push left and facing right when I push to right?
2. How to I restrict him to a certain area of the stage? I am going to have some buildings on the top and I don't want him to be able to walk past the street level. So basically I don't want him to be able to go off the stage or up some to be determined height.
3. When he walks up and touches a door on my stage, I want to jump to another place in the timeline.
View 7 Replies
Dec 13, 2009
I've been struggling with making boundaries with my game. I've managed to make boundaries, but in stead of my game character not moving across that border it just bounces back. Which is not the effect I want.
Here's my code
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
} if (Key.isDown(Key.RIGHT)) {
xspeed += power;
[Code] .....
View 3 Replies
Jan 28, 2012
I am currently working on a platformer using accelerometer to move the character and xml to load levels as so..
[as]
level.x += (e.accelerationX*40);
if (e.accelerationX > 5) {
e.accelerationX = 5;
} if (e.accelerationX * 40 < 3 && e.accelerationX * 40 > -3) {
player.gotoAndStop(1);
[Code] .....
And it is all added into one movieclip called level. My problem is when the character hits under a platform it will go up it which I don't want it too, I don't know how to fix it heres the gravity code.
View 11 Replies
Dec 3, 2011
I'm trying to create simple 2D action game, something similar to well known Fancy Pants Adventures :) I've been looking for answer for more than week and all I've found is [URL] which not answers the question. (I've found also moving on platforms that are rotated but that's not I'm looking for). I have also found great (and free!) flash game engine - CitrusEngine which I'm currently using, but, it doesn't provide moving hero along curved terrain. How to make hero moving along curved terrain like this one: [URL]. There are plenty of games like this (for ex. Fancy Pants or Robot Unicorn Attack) where main character moves along the curved terrain but I can't find answer how can I do that.
View 2 Replies
Feb 9, 2010
I have a project underway where I am making an interactive game. It is a personal character creator game and I need Actionscript 3 help with this.Something similar here:http:[url]....
I have tried already with toggling visibility and 'gotoAndStop()' to make items appear over other items when the corresponding button is pressed, for example, when the user tries out different pants/shirts on their character.
View 1 Replies
May 3, 2011
I'm having the problem that my video, which sits in a movie clip, does not stop the audio after moving to the next frame, even though the video instance is removed. Here is the code from the main timeline:
import flash.events.MouseEvent;
next1_btn.addEventListener(MouseEvent.CLICK, ongoPage2);
function ongoPage2(Event:MouseEvent):void {[code]....
View 4 Replies
Nov 16, 2004
I have a function on root:
_root.fadeBox_mc.onEnterFrame = function (){
if (fade){
this.nextFrame();[code]....
This causes a mc to fade in and out on rollover/rollout. But what I wanna make is a box that fades in when pressed on the button and fade out when pressed for the second time. But if I say
on (press){
_root.fade = true;
}
the mc fades in, but I cant do another on (press) to fade out. Is this too confusing?
View 2 Replies
Sep 24, 2010
I have a 9 frames image of a character.In other language generally i used to make character animation by looping the array consisting of different frames and drawing each frame when pressing key.What i want to do is when i press left or right key, i want to draw each frame that makes character movement and update x coordinates of frames, and it will appear as character is moving.
View 4 Replies
Nov 27, 2010
Does anyone know the regular expression to test if a single string character has both upper and lower case character?
eg. All A-Z and a-z.
View 0 Replies
Dec 6, 2010
I am struggling a bit with keys on the keyboards controlling a movieclip to happen.Ive got a person moving when pressing right and left, and a movieclip with three frames: First frame is a movieclip with the person standing still, looking bored. The second frame is the person moving right, and the third frame is the person moving left.This is the code that Ive inserted into the persons actions on scene1:
if (Key.isDown(Key.RIGHT)) {_x += speed;this.gotoAndStop(2);_xscale = +scale;}
if (Key.isDown(Key.LEFT)) {_x -= speed;this.gotoAndStop(3);_xscale = -scale;}
this code works alright accept that when the keys are not pressed it doesnt stand still, the legs are still moving, so I tried to include this code aswell:
if (!Key.isDown(KEY.RIGHT)) [code]....this makes the person standing still when not pressed but not moving the legs when turning right and left.
View 3 Replies