ActionScript 3.0 :: Movement On Keypress Event Not Smooth?

Oct 22, 2009

I am trying to move an object on keypress. so i am doing

if(keyboardevent.keycode == keycode)
{
code to move;
}

this works perfectly fine, but when i keep the key pressed for a couple of seconds, the motion is not smooth. for the first second the object gets stuck there, and then moves smoothly. same thing happens when i change the key. basically, it is taking time to read the first key event.

why is it so? i dont want this 1 second delay. i want the object motion to be fluent, as i am making a time critical game.

View 1 Replies


Similar Posts:


How To Make Smooth Line Movement

Sep 12, 2009

I've been searching it everywhere, but couldn't find anything in the net. I want to make smooth line movement. I've tried to create motion, but line just moves, and I want it to move smoothly according to the path. What I want to achieve can be seen [URL].. that's what I did so far - made movement out of several broken lines

View 3 Replies

IDE :: Make Smooth Line Movement?

Sep 11, 2009

I've been searching it everywhere, but couldn't find anything in the net. I want to make smooth line movement. I've tried to create motion, but line just moves, and I want it to move smoothly according to the path. What I want to achieve can be seen here:

[URL]

But that's what I did so far - made movement out of several broken lines - how can I make more smooth movement?

View 5 Replies

ActionScript 3.0 :: Scrollrect Vs. Mask: Smooth Movement?

Jan 27, 2009

There are two basic ways of panning a view in Flash. One is to move the display object (and use a mask if necessary). The other is to use scrollrect. Today I noticed a small, but annoying effect of scrollrect. Scrollrect's can't have true Numeric positions-- they are automatically snapped to the nearest pixel.

When moving at very slow speeds, the effect is noticeable. In this example you can switch between two modes of panning, sprite movement with mask and scrollrect:

http://lab.wx3.com/scrolltest/ (view source enabled).

In the default mode, the circles move smoothly.

In scrollrect mode, the circles seem to stutter because the scrollrect is snapping to the nearest pixel.found a way to make a scrollrect move smoothly at slow speeds?

View 3 Replies

ActionScript 2.0 :: Advanced Random Movement - Smooth?

Sep 1, 2003

Let me explain - on my upcoming website (in a year, maybe?) i'll have some sort of cartoon character walking above my contents - and I want his charcter to be smooth and actionscripted. However his movements should be done as a curved motion path would, but random.Now random movement will either: a) get you to one point and then to the other, but making a sharp turn or b) have no coordination in movement (good for making a bee fly but not for anything else).here's what im trying to do:

transform straight lines movement (random):

to something smoother

something inside me tells me it's got something to do with cos and sin functions but I've no idea how to make that work.And I don't want to do motion path because I need to do actions that rule that out.

View 7 Replies

ActionScript 2.0 :: MovieClip Movement (Right To Left) Not Smooth

Dec 7, 2004

I have the following script in both frame 1 and 2 to let a movieclip move from right to left on the stage:
Code:
speed =-5
name._x += speed
if (name._x<-500) {
name._x = 250;
}
And the clip is indeed moving from right to left on the stage and when it reaches _x -550 it is going back to it's starting position _x 250 only the movement isn't smooth at all. What should I do to make the movement more smooth or should I use a completely different script?

View 6 Replies

ActionScript 2.0 :: Make A Smooth Movement When Click On Anywhere In Seek Bar

Aug 11, 2008

I want to make a smooth movement when i click on anywhere in my seek bar. So i come up with an tween which is below. I have a mask called tbMask which is stays beside timeBar.

ActionScript Code:

Code:
new mx.transitions.Tween(timeBar, "_xscale", mx.transitions.easing.None.easeOut, 0 , tbMask._xmouse, 2, true);

So basically this would make timebar stretch to tBmask's _xmouse which has same x (170). But it dont! It exceeds about 50% where i clicked and go back to _xmouse.

Far from this problem, the anothers are; I call this swf from my main swf. Tween function works when i try to view my main.swf but it dont work when i call player.swf from browser.

View 7 Replies

ActionScript 3.0 :: Smooth Movement Controlled By Arrow Keys

Apr 12, 2011

I used to use AS 2.0 but I've finally made the switch to 3.0. I am majoring in CS so I am familiar with basic/intermediate concepts, but I am very unfamiliar with 3.0. I have a movieclip controlled by arrow keys, however the movement is still slightly choppy. Everything is uploaded below, the code I note here is the code for movement located within the .as file.

Code:
package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.events.Event;
[Code] .....

View 10 Replies

ActionScript 2.0 :: Movement Not Smooth - Movieclip Move From Right To Left On The Stage

Dec 7, 2004

I have the following script in both frame 1 and 2 to let a movieclip move from right to left on the stage:

[Code]...

And the clip is indeed moving from right to left on the stage and when it reaches _x -550 it is going back to it's starting position _x 250 only the movement isn't smooth at all. What should I do to make the movement more smooth or should I use a completely different script?

View 6 Replies

Keypress Event Not Working In Second Scene?

Nov 12, 2010

I am a high school teacher who is teaching Actionscript 3.0 for the first time. I am teaching my students how to create multiple scenes to understand actionscipt interactivity. The first scene has a button. The second scene has something happen when a key is pressed. The problem is that the second scene doesn't work. Flash doesn't even show the trace command that a key has been pressed. Keypresses work fine when done in the first scene, but when put in the second scene after a button has been pressed, it doesn't recognize the keypress event.

View 1 Replies

ActionScript 2.0 :: UIScrollBar Component And Keypress Event

Aug 23, 2006

I have a chat swf with one dynamic textfield that shows the typed text and one input textfield with an "ok" button. I'm using this code on the button:
Code:
on(release, keypress "enter") { //do something}

With this code after the typing, the user could just press the "enter" key to transfer the typed text to the dynamic textfield of the chat. It was everything working perfectly, the problem showed up when I added the UiScrollBar component to scroll the dynamic textfield. When I add the UiScrollBar to the library, the keypress "enter" event on the button stop working! If I delete the UiScrollBar component, keypress event start working again!

View 2 Replies

ActionScript 3.0 :: Smooth Movement From Point A To Point B?

Sep 2, 2010

i have this code i found that smoothly moves a box left or right on the screen based on using the left or right arrow keys. i want to use this smooth code but adjust it so on enterframe, the box would move from point a (say 0,120) to point b (0,240) and stop there.no keys used, just working based on entering the frame.how to modify the code below?

Actionscript Code:
import flash.display.*;import flash.events.*;import flash.ui.Keyboard;var velocity:Number = 0;var acceleration:Number = 0.2;var friction:Number = 0.90;var isRightKeyDown:Boolean =

[code].....

View 4 Replies

ActionScript 2.0 :: Smooth Resize Onclick And Animation To Be Smooth?

Feb 9, 2004

I have a movieclip that I want to be resized when a button is clicked. I want the animation to be smooth as if it had weight though. I read the tutorial on this but I need something slightly different, I would rather it where I can just refer to a function that is set in another movieclip. That way I could easily refer to it again and just set the height, width, and if possible, x, and y.

And my second question, is how to keep the border of my movieclip that is going to be resized the same thickness. I want the inside to be resized but the sides to stay the same width but move to stay on the edge.

View 8 Replies

ActionScript 2.0 :: Event Listener For MC Movement?

Aug 9, 2007

I thought I saw somewhere that you could set a listener to monitor a MovieClip's position, to see if it has been moved. Is this possible in as2? Only as3? Do I just have a loose screw?Or is there an event that triggers when a MC is dragged (not pressed, not dragged out, but dragged around)?

View 1 Replies

ActionScript 3.0 :: Movement Of A MC Demands An Event?

Apr 7, 2012

I could've moved on to the more difficult stuff: collision detecting and course plotting.I have spent over 2 hours just trying to get a MovieClip to move from A to B -- or from x,y to x,y I should say.I first thought I could just set new x, y properties for my MC, and then it would move there. No.Then, I tried using an event handler and function. This worked, but after the first "leg" of the movement, it sent me a 1063 error, and I also was concerned that the Event I used (ENTER_FRAME) was a one-time use kinda thing.{{What IS the proper Event to call, when you just want the computer to act on its own?? No mouse CLICK, no keyboard UP -- just move, doggone it!}}

Then I tried several permutations of functions and arrays, but it seems like movement of an MC demands an Event. Is this true? For a while, I fiddled around with my TweenLite commands.I currently have a Guide moving around my Grid, which is -- through TweenLite -- drawing a line.I just want this additional MC to tag along for the ride.Here's the code for the Tween; it's pretty standard:

TweenLite.to(r1Guide,.5,{x:lineStartArray[0] + lineMove1Array[0], y:lineStartArray[1] + lineMove1Array[1], delay:2.5, ease:Linear.easeNone, onUpdate:drawLine});

I tried to duplicate this and apply it to my MC. No dice. It actually shifted my whole stage or something weird.I can just add my MC as a Child to the TweenGuide, and then it will certainly tag along

View 5 Replies

ActionScript 3.0 :: MovieClip Movement Using Keyboard Event

Jul 30, 2009

I am working on a game project and i have a question about movie clip movement using keyboard event. Basically I have a character on screen and it can move on the x axis using the left and right buttons. I am making my character move by changing the x value of the character movieclip but I find very it laggy and not smooth and if I am going point by point then it's too slow. Whats the best way to make the character move so that the transition will be smooth.

View 3 Replies

ActionScript 2.0 :: Event Listener For Mouse Movement?

Jan 25, 2006

i need to code something that will restart the movie (or go the the splash screen) after the mouse hasn't moved for a certain period of time

i know i need an event listener to do this, but thats pretty much all i know.

View 5 Replies

ActionScript 3.0 :: Socket Event Triggers Movieclip Movement - Need More Frequent Rendering

May 11, 2009

I have a flash project that's implementing a simple two player game. I have added an enterFrame function to my main movie which listens for keyboard activity in order to move a cowboy gunslinger. Whenever the cowboy moves, I send a message over a socket to a server which dispatches the movement to the other connected client. This works pretty well, however, the movement messages tend to arrive in clumps which results in jumpy animation of my cowboy on my opponents screen and jumpy animation of his cowboy on my screen. To illustrate, i put a trace in my enterFrame function because I am imagining that this function will run roughly once each time my main movie renders the screen. I also put a trace statement in my function that responds to network traffic and moves the remote player's cowboy on my screen. Here's the output:

[Code]...

View 17 Replies

ActionScript 3.0 :: MovieClip Movement Triggered By Socket Event - Screen Render?

May 11, 2009

I have a flash project that's implementing a simple two player game. I have added an enterFrame function to my main movie which listens for keyboard activity in order to move a cowboy gunslinger. Whenever the cowboy moves, I send a message over a socket to a server which dispatches the movement to the other connected client. This works pretty well, however, the movement messages tend to arrive in clumps which results in jumpy animation of my cowboy on my opponents screen and jumpy animation of his cowboy on my screen. To illustrate, i put a trace in my enterFrame function because I am imagining that this function will run roughly once each time my main movie renders the screen. I also put a trace statement in my function that responds to network traffic and moves the remote player's cowboy on my screen.

Here's the output:
enter frame:4
enter frame:4
enter frame:4
client movePlayer running
client movePlayer running
client movePlayer running
[Code] .....

As you can see, I'll get several messages in a row from the remote client which instruct me to move their cowboy ('client MovePlayer running') and they will all run in a row before the screen updates. I'm guessing I should be using something like updateAfterEvent but this method is only provided by Mouse, Timer, and Keyboard events.

So a few questions:
1) Can someone recommend a good approach to force a screen render each time an incoming movePlayer event arrives over the socket? It's important to note that my function for handling these events has no visibility to the original socket data event.
2) Am I right in understanding that the enterFrame function of my main movie happens once each time my movie is rendered? Is there some more accurate event to which I could attach a trace message so that I better understand the relative frequency of the render events and the socket events?
3) Does firing an updateAfterEvent call force onEnterFrame events to happen more frequently? I'm worried about destroying performance by inadvertently firing more enterFrames which would fire more socket events which would fire more enterFrames, etc., etc.

View 9 Replies

ActionScript 2.0 :: Circular Movement To Linear Movement - Carousel To Conveyer Belt?

Jul 9, 2010

I've been playing with carousel code, and was wondering how to change it from circular animation (carousel) to left/right linear (conveyer belt) style animation, how to change the mover code and 't.angle = i * ((Math.PI*2)/numOfItems);'

[Code]....

View 1 Replies

ActionScript 2.0 :: Flowing Mc Movement Opposite Of Mouse Movement

Feb 12, 2003

I have a mc (fStrip) which looks like a piece of filmstrip with thumbnail images in it. I want this mc to move when the users mouse is positioned over it, but I only want it to move only along it's x-axis and in a direction opposite that of the mouse. And I want it to move or flow smoothly.

I've been trying to figure this out (see my lame attempt below) but without much luck.

onClipEvent (mouseMove) {
buffer=20 //movement buffer
mousePos=_root.fStrip._xmouse //store mouse position
if (mymouse!=_root.fStrip._xmouse){ //if the mouse has moved

[Code].....

View 3 Replies

ActionScript 2.0 :: Ants Movement (based On Snow Movement)?

Jun 22, 2004

I wish to get the effect of ants scuttering across the screen or up a tree, I have not decided which direction yet. I started with the tutorial code for the snow effect from kirupa, and changed it around to fit the little vector ant I created. The way I have it now looks pretty good, but the movement is a little too fluid. They obviously move in sinusoidal paths bc the code tells them to. I have about 20 copies of the main obj, and they're all a little different in size and specs (speed, transparency, etc) but what I was wondering was if there is any way I can change the code to make it a little more hectic, or erratic, not so fluid. If there is no way of doing so, it looks pretty good right now. If there is, however, I think it could look awesome. here's the code I'm using for the object.

onClipEvent (load) {
//stage
movieWidth = 850;
movieHeight = 50;

[code]....

View 5 Replies

ActionScript 3.0 :: 2D Character Movement With Camera Movement

Jun 10, 2011

how to get the camera to move with a character? At the minute he just moves off screen when i press right rather than the camera following him.

View 3 Replies

ActionScript 2.0 :: Set Movement Speed On Any Particular Movement?

Oct 2, 2002

I have a Mogli (Junglebook-like) Character that i got to move with the arrow keys on the keyboard.

I want the character to jump (so for example , he must while moving to the right of the "gamearea" , you must be able to hit a key (say for example the "control" key ) and then the character must jump ( go up ) and as soon as the key is released he must obviously come down.

And also how do one set movement speed on any particular movement.

View 12 Replies

CS3 : Retrieving The Last Keypress?

May 19, 2009

What I'd like it to do is find out what key was last pressed and then based on which key it was, go to a specific frame of guy_mc. So basically if the left key was the last key press I want it to go to frame "Left", if right key was the last, go to frame "Right," etc. I'm completely lost on this one and every tutorial I come across is based in AS2 which has much simpler methods than AS3.

Code:

//listen for guy_mc to see if all keys are up
guy_mc.addEventListener(Event.ENTER_FRAME, allKeys);
//if all keys are up...

[code]....

View 1 Replies

CS3 KeyRelease Instead Of KeyPress?

Jun 29, 2010

What I'm trying to do seems really simple but I can't get it. I'm trying to do something like this, but keyRelease doesn't exist I think.

on (keyRelease "<Right>") {
nextFrame();
}

I just want it to go to the next frame on the time line when the right key is RELEASED.

View 1 Replies

Way To Register Keypress

Apr 4, 2012

I've made a popup div that shows a video if you press a button. If you press Esc, the div is hidden again and the video is removed. (Using JWPlayer in Flash.)

If you click on the JWPlayer video, Flash gets the focus and JavaScript can't listen for keypresses on the document anymore. Is it possible to make JavaScript get the focus after you've interacted with the JWPlayer video player, so that you can still press the Esc button after for example pausing the video?

View 1 Replies

Difference Of If Key.isDown And On KeyPress?

Aug 5, 2009

I was just wondering what the difference between these two is.

View 1 Replies

ActionScript 3.0 :: Go To Next Frame On Keypress?

Aug 5, 2009

I'm working on the timeline and have movieclips on each frame. Each movieclip should play completely before moving to next frame. Once the movieclip is completed playing, I'd like to set up a keyboard event that allows for movie to go to next frame onKeyUp.This is the code I have but it's not working ... I'm getting jumbled results. I know this should be simple enough, but oh well.

stop();
import flash.events.KeyboardEvent;
var keyListener = new Object();

[code].....

View 3 Replies

ActionScript 3.0 :: Can't Get Keypress To Work

May 1, 2009

I'm using Flash CS3 (AS2.0) at school on a mac, but when I open the file on CS4 on my pc I can't get my keypress to work.[code]I want my animation to happen when I push "t" on the keyboard.I have the whole alphabet to go through but I'm stuck since I can't even get this first one to work!Do I have to convert it to AS3 somehow since that's how it opens in CS4 (I think)?I'm new to Flash and need to figure this out for a course project!

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved