Actionscript 3 :: Detect A Held Key In A Flash Game?
Sep 12, 2010What is the correct way to detect held keys in a flash game For example, I want to know that the right arrow is held to move the player.
[Code]...
What is the correct way to detect held keys in a flash game For example, I want to know that the right arrow is held to move the player.
[Code]...
I'm trying to come up with a clean function that will perform a check on a 2D Array to verify if a win has occurred in a ConnectFour game. I'm trying to work through the logic but my brain is swiss cheese right now. Here's what I have for checking for a horizontal win. It seems to me like there should be a way to streamline this block to work in all possible directions.
[Code]...
I have a tile based game à la Scrabble where tiles are placed on the board.. during the game the tiles must all be touching, and there should be no groups of tiles anywhere else on the board..I can find single loose tiles and check for surrounding tiles easily enough but how would I go about checking if every tile is touching on a horizontal or vertical axis and if there are loose groups of tiles on the board ??
View 3 Replies1) add a SimpleButton to the stage and view the SWF2) then press and hold the mouse button down OUTSIDE of the button's boundaries3) then drag the cursor over the SimpleButton while still holding down the mouse button......Then the SimpleButton on the stage does not detect the mouseover and display its 'over' state. It just stays in its idle state. Why is this? And is there a way to enable the SimpleButton to display its over state while the mouse button is being held down and then the cursor brought on top of the button (as described above)?That's the abstract, and if you are at all curious (this won't elaborate on the question, but maybe help you visualize a practical scenario) what's motivating the question, it is an application I'm building. In this app, the user is able to drag video thumbnails in order to rearrange their order.
View 3 RepliesActaully I am running a cards game. While running the game in between if I change the style portrait to landscape. then how can I detect the screen size and run the game according the screen style (Portrait or Landscape).
Actaully I have written the code to detect the screen as portrait and landscape. But in between if I change the game portrait into landscape, no more it works.
i have an AIR android app which i am running on an android device ( samsung TAB ). i want the app to get laid out in landscape mode when the user starts the app holding the device in landscape ( same goes with portrait ).
but the AIR app always gets started in portrait mode irrespective of the way the device is held.
i tried the following ways use stage.deviceorientation (but when the app starts (after the applicationComplete notification ) the value is UNKNOWN) use stage resize event. (this gets triggered at start itself, a manual resize is not required - the values are based on portrait mode though - the width is 600 and height is 1024 (should have been otherway) )
i get correct values when i try changing the orientation of device, only at the startup i see problem with the required values.
I'm creating a game at the moment for my university course and it involves the player character jumping on top of boxs twice to break them as opposed to just once.What would be the most efficient/simple way of writing this in Actionscript 3.
View 1 RepliesI am thinking of developing of a game like this: [URL]... Do you have any idea - by which game engine I may develop this type of games? I am not sure whether I have to use any 3d physics engine? I think JiglibFlash may be useful, but I am not sure.
View 1 Replieshow to make a game tutorial as farmville game tutorial to teach the user to play the game. i have recently involve in make that kind of game tutorial for its user by actionscript 3
View 1 Repliesim currently making a game, and the game has some powerups, that when picked are stored. the problem is that, if i have, say, 3 shields, e press the matching button and the 3 shields are used instead of one. i found out its because i was checking the button pressing every frame, so i created a flag that checks if a button is corrently being pressed. here's the code
[Code]....
[code]for the part that says "if(???)" i am trying to get it so if the user presses key+wp(key65) it does an event. how do i do it without having to put it inside onClipEvent
View 3 Repliescrouching = false
wp = 65;
MovieClip.prototype.key38 = function() { //down
if (!this.crouching) { //if crouching is false
[code]...
for the part that says "if(???)" i am trying to get it so if the user presses key+wp(key65) it does an event. how do i do it without having to put it inside onClipEvent.
When game page loading , the flash game itself does not appear ( just white area as the holder of the flash game) untill the game almost finish downloading, then it appears .. This long waiting with just white area makes visitors leave, thinking there was nothing there.
View 1 RepliesIs it possible to make a menu display when the spacebar is held down, then, disappear once a menu option is chosen and the spacebar is released?
View 3 RepliesI want to resize an image which i have held within an array so that they can be used for thumbnails.
images show in full size i want them resized as i am using the same image for both the main image and the thumbnails to help keep the file size down. Below is the code its all working great now apart from the resizing which i have tried doing all sorts and i cant figure it out.
function loadImage(filePath:String):void
{
//for loop to load thumbnails
for(var thumbnum:int=0; thumbnum<6; thumbnum++)
[Code].....
I'm using the following parallax class, which I downloaded from fuoridalcerchio.net, but it's no longer available:[code]I created a mc container named parallaxContainer, which holds the parallax items, and defined it's class as ParallaxBox. Then, to initialize the class, I used (as per the instructions that once were posted on the site I mentioned):[code]
Right now I have just added one item for testing purposes (bg) and it works perfectly as long as I don't resize the browser window. I'm no programmer, but as far as I can tell, the class adds items to the array "theObjects" using the function addParallaxItem. The first value is the instance name of the object to add, the second is the horizontal range in pixels which the object is allowed to pan (set to 960 since my stage is 960px wide) and the third is the vertical range(which is set to 0). I can't post the link since my post count is less than 50, but the thing is if the browser window is larger than 960px, the "bg" movieclip shouldn't travel 960px to either side to reach the edge. I'm not very good at math, so I don't know how to calculate the new distance it should travel, which should be less. If someone wants to help, I can PM the link so that you can see what I mean.[code]Obviously, even though the value of the variable is updated, it's not passed to the array.
I have a small animation that I would like to be played ONLY while the space bar is being HELD down. I have tried everything, but then again, I am quite new to flash.
View 2 RepliesAm I correct in understanding that the onMouseOver event doesn't fire if the mouse button is clicked and held down prior to moving the mouse over the specified object? Would I need to code something using hitTest to see if the mouse is over the specified object regardless of whether the button is down or not?
View 1 RepliesI need to zoom in (therefore scale up) some static fields held in movieclips. They need to be BIG but when they are scaled up they lose some definition, looking a bit pixelated on the edges. Does anyone have any advice on how to keep them looking nice and smooth when they are scaled up?
View 1 RepliesI have the movieclip playing inside a variable but I can't figure out how to declare "play();" and apply it to the variable.the variable is called "player" and it contains any one of 3 movieclips.
View 3 RepliesI'm trying to create the very basics of a isometric map. My engine creates to map fine, but it's when I want to then control the movie clips.I'm adding each cell in the grid using and array:
Code:
for (var X= 0; X < Engine.Var.GridWidth; X ++)
{
[code].....
im makin a game.... and i want to be able to delay the weapon even if the button is held down... like in this...
http:[url]...
how would i go about doing that?... the only reason is cuz right now my game lags so bad if i just hold dow the button cuz so many movie clips on the screen at once...
this one has got me stumped. I want an object to move 10 pixels every time a key is pressed, and I don't want it to keep moving when the key is held down.And I want to know why it moves once, and then waits a bit before moving more. I do not see why anyone would want it to do that!!!
View 1 RepliesIn lee's xml tutorial he uses the list component and the text area component but when he tested the swf he had to select the item befour the text field was populated.
i have set the selectedIndex to 0 but the data still does not load untill an item is selected.
I have two buttons in my movie that move a movie clip up and down on my stage. the code in the buttons atm is as follows,
on (press){
if (this.pics1._y<-240) {
} else {
this.pics1._y = (this.pics1._y-10);
}
(this is just the down button)This just checks to see if the movie clip has reached its lowest position and if it hasn't it movies it down by 10px.What i would like to do it make is so when the button is clicked and held the movie clip moves down untill the button is released.(Im using Flash 8 with Actionscript 2)
I'm developing a game for my final year project at university that has a character who can move up and down on screen. The upper half of the screen is reflected in the lower half so that there are actually two characters on screen at once, each reacting exactly the same way to keyboard input.One of the mechanics involves the two avatars changing positions relative to their halves of the screen which requires a spacebar press to execute. The problem I'm having is that I don't want the characters to change positions once every frame if the spacebar is held down. I need to implement some sort of delay once the spacebar is pressed so that the characters won't swap positions for another second or so.
Code:
var plachaFlipPointY:Number = char.mc.y;
var shadowPlachaFlipPointY:Number = schar.mc.y;
[code]....
i'm trying to make a button that when held will go to the previous frame, pause for 0.042 (24fps)seconds and then loop again until the mouse is releasedso something like thisI think know the first bit of code from much forum trawling, but have been unable to find anything further.I am an almost complete newb to programming, having online done a tiny amount of vb several years ago,just wonderingtranslate this following script into as3, and also point out if it won't work.
stop();
Rewind.addEventListener(MouseEvent.MOUSE_DOWN, RewindEvent);
function RewindEvent(event:MouseEvent):void
[code]......
I have a movie clip of a character who is supposed to walk when the arrow keys are held down. The character does move in response to the keys being held down, but the walk cycle in the movie clip only plays once. (Flash file is attached.)
I used a Trace in the code to see what the issue is, and one thing that I noticed is that the function seems to run over and over. I'm wondering if that has something to do with it?
i saw that one can create apps for desktop and for hand held devices..
View 1 Replieswell i made a game and in the game there is music at the first frame and when u lose to goes back to first fram and more music plays so they are overlapping.
View 10 Replies