ActionScript 2.0 :: Moving MovieClip To X Direction

Apr 29, 2009

I'm moving a movie clip using actionscript (as2) instead of a motion tween (because I want to save file size). I have this code on the first frame of the main timeline ("stone" is the movieclip instance name) and it tells the movie clip how many pixels to move in the x direction:
Code:
xTargetstone = 600;

I have this code on the movie clip itself ("stone" is the mc instance name) to handle the actual moving of the movie clip:
Code:
onClipEvent (enterFrame) {
xstone = getProperty(_root.stone, _x);
movestone = _root.xTargetstone - xstone;
setProperty(_root.stone, _x, xstone + (movestone/5));
}

The movement works fine, but the issue is that it starts out fast and then slows down over time (even though that amount of time is small). The result is that the movie clip seems to wiggle and vibrate before it stops. Is there a way for me to change the code so that it doesn't wiggle and vibrate? perhaps something with the math I'm just not totally understanding? I would like a nice consistent motion from start to finish, while being able to set the time it takes to move etc.

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Moving Movieclip In Opposite Direction Of Mouse Movement?

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

ActionScript 3.0 :: Rotate Slowly Based On The Direction Hes Moving?

Nov 13, 2010

currently I have a movieclip that follows my mouse cursor simply using

char.x = mouseX
char.y = mouseY

the movie clip is always upright, how do i add rotation so the char will rotate slowly based on the direction hes moving?

View 2 Replies

Creating A Background Which Moves In The Direction That Cursor Is Moving?

Sep 8, 2009

so i have a project where i will be making a website. I will be using flash to make it interactive and visually appealing. I found a website with a really cool entrance page,please view it he mouse moves, the background looks like its moving.

View 3 Replies

ActionScript 3.0 :: HitTestPoint To Change Direction Of Moving Object

Jan 5, 2011

I'm having a problem changing the direction of a movieclip using hitTestPoint. I have some balls on the screen that only move left, right, up and down. and pending the way they are moving they have to change direction. if they're moving right they have to change to up. left to down, up to right and down to left. I tried the following code for getting a ball moving moving right to change to up. note: movingDir is just a string i use to keep track of how the ball is moving and is defined initially in another class. here is a snippet from the ball class:

[Code]...

View 8 Replies

Flash :: Moving Layers In X & Y Direction With Depth By Mouse

Aug 30, 2011

Could you take a look at this site , it's official web site of Coraline animated movie , is there any related article or tutorial to do such navigation technique [URL] If not i will try to explain , layers of movieclips are ordered in z direction when you move your mouse in x & y they move based on depth like semi 3d side walk games

View 1 Replies

Actionscript 3.0 :: HitTestPoint To Change Direction Of Moving Object?

Jan 5, 2011

I'm having a problem changing the direction of a movieclip using hitTestPoint. I have some balls on the screen that only move left, right, up and down. and pending the way they are moving they have to change direction. if they're moving right they have to change to up. left to down, up to right and down to left. I tried the following code for getting a ball moving moving right to change to up.

note: movingDir is just a string i use to keep track of how the ball is moving and is defined initially in another class.

here is a snippet from the ball class:

Code: Select allthis._movingDir = "right";
this._speedR = 5;
this.x += this._speedR; 

[Code]....

View 1 Replies

ActionScript 2.0 :: Constantly Moving Forward In The Direction It Faces?

Sep 3, 2009

I have recently been developing a sailing game and my boat turns with the arrow keys. On the turn i would like to keep the boat constantly moving forward in the direction it faces. What is the simplest way to do this?

(When i rotate the boat to the right/left, i want the boat to move that direction)

View 2 Replies

ActionScript 2.0 :: OnEnterFrame - Moving Object On Stage And Change Direction

Mar 22, 2006

I'm trying to set up a script which would force an object to move through the stage until a particular point and than change direction. I wrote something like that:

onClipEvent (enterFrame) {
moveUp = function () {
this._y -= 1;
if (this._y<-30) {
this.onEnterFrame = moveDown;
}};
moveDown = function () {
this._y += 1;
if (this._y>600) {
this.onEnterFrame = moveUp;
}};
this.onEnterFrame = moveUp;
}

But it doesn't work. the object moves only one direction and does not change it.

View 1 Replies

ActionScript 2.0 :: [flash 5] Random Motion - Object To Flip Horizontally Depending On The Direction It Is Moving

May 9, 2006

i'm using the an actionscript for random movement that i found here... [URL] but my problem is that i need the object to flip horizontally depending on the direction it is moving... the object that is moving around is a bug, and i need it to face left if it's moving left or face right if it's moving right.

View 1 Replies

ActionScript 2.0 :: Calculate The Direction And Speed A Circle Has After Colliding With A Static (non-moving) Circle?

Mar 8, 2005

I'm developing a game atm, and I need some help on the mathematics/coding of colliding circles (and their change in x/y speed). What i need to know is how to calculate the direction and speed a circle has after colliding with a static (non-moving) circle. I know how to detect a collision between the two, but I'm not sure about the maths I need to give the circle the right speed and direction after the collision

If i do know how far away the two circle-points (in the middle of each) are to each other (in both x and y coords) would it be easy for me to find the new speed and direction of the large circle in the example above? I know that I somehow should use the angles to pretend the circle hits a flat "wall" (as it only hits one point), and then calculate the new speed/direction. My only problem is that I'm not sure how to decide the angle of this flat "wall" and how x and y speeds should change when colliding with a wall that is angled. Does anyone here have any insight, links or tips on how I can du this?

View 6 Replies

ActionScript 3.0 :: How Does One "detect" If The Object Is Currently Moving To Its Own Left Or Right Direction

Sep 29, 2010

using trig, when moving an object based on its current rotation, how does one "detect" if the object is currently moving to its own left or right direction? example: right side up: left moves the car to its left, which is left. upside down(180 rotation): left moves it the car to its left, which is right. based on movement alone, how can i say its moving to its own oriented left or its right?

[Code]....

View 7 Replies

ActionScript 2.0 :: Scrolls Continuously In A Direction Until The Direction Of The Mouse Is Changed?

Feb 24, 2009

i have a scroller developed in as2. it basically scrolls continuously in a direction until the direction of the mouse is changed. the images of course loop in the continuous scroll. now the problem is that for 10-15 photos its ok. but when i feed it with 180 photos, it seems to show only 11. why would this be? any restriction on flash ??

View 1 Replies

ActionScript 1/2 :: Detect A Movieclip's += Direction?

Apr 21, 2011

I want to know how if a movieclip is going += ._y or -=._y

View 1 Replies

ActionScript 3.0 :: Changing Direction Of A Movieclip Using Enter_Frame?

Jan 3, 2011

Would some wonderful person be willing to take a look at this code and tell me what I'm doing wrong?

I'm trying to use ENTER_FRAME method to get a moving movieclip to change direction when it hits certain x and y coordinates. I want the movieclip to move horizontally, then down, then horizontally again. With this code my movieclip starts off moving down at a diagonal and I can't for the life of me figure out why. (probably something simple I'm overlooking?) I'm a beginner at actionscript.

[Code]...

View 4 Replies

IDE :: Telling MovieClip How Many Pixels To Move In X Direction

Apr 29, 2009

I'm moving a movie clip using actionscript (as2) instead of a motion tween (because I want to save file size) and I have this code on the first frame of the main timeline ("stone" is the movieclip instance name) and it tells the movie clip how many pixels to move in the x direction:
Code:
xTargetstone = 600;

I have this code on the movie clip itself ("stone" is the mc instance name) to handle the actual moving of the movie clip:
Code:
onClipEvent (enterFrame) {
xstone = getProperty(_root.stone, _x);
movestone = _root.xTargetstone - xstone;
setProperty(_root.stone, _x, xstone + (movestone/5));
}

The movement works fine, but the issue is that it starts out fast and then slows down over time (even though that amount of time is small). The result is that the movie clip seems to wiggle and vibrate before it stops. Is there a way for me to change the code so that it doesn't wiggle and vibrate? perhaps something with the math I'm just not totally understanding? I would like a nice consistent motion from start to finish, while being able to set the time it takes to move etc.

View 4 Replies

ActionScript 2.0 :: How To Get MovieClip To Move With Mouse Direction

Apr 20, 2004

How do I get a movie clip to move to the mouse when it is clicked and released and have it rotate in the direction that it moves?

View 5 Replies

ActionScript 3.0 :: Direction Of The Ball In The Direction Of The Mouse

Mar 17, 2011

have a ball with the name of mc which can be moved using the keyboard .. when you press the left mouse button shoots the ball, this ball and the other flies in the face where the cursor was in the shot .. but if you move the cursor to another location and shoot a second time then the second ball is also flying in the direction of the cursor and the first ball change direction toward a second shot ..

ActionScript Code:
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.MouseEvent;

[Code]....

how to make that first ball did not change its direction and continued to fly in the direction of the shot?

View 5 Replies

Professional :: MovieClip Smooth Rotation And Direction Change

May 19, 2010

I want to make a movieclip moves smoothly and when it changes the direction, it can turn smoothly but not a sudden turn, I try out the code below. and the truning is odd:
this.rotation = (Math.atan2(targetY-this.y, targetX-this.x )/Math.PI)*180;

View 2 Replies

Actionscript 3 :: Flip A Movieclip To Face Movement Direction?

Oct 5, 2011

Working on a maze game. When the leftkey is pressed the movieclip (char) should turn 90 degrees to the left.

char.scaleX *= -1;

However, the most important thing is that the character doesnt go through the walls of the maze.And I think thats my problem for implementing the code above.Because it doesnt work properly when i put in here;

if(!mazehit) {
char.y += speed;
char.scaleX *= -1;[code].....

View 1 Replies

ActionScript 2.0 :: Rotate Movieclip According To Mouse Direction, Drag

Nov 8, 2007

Is it possible to rotate movieclip, while dragging, according to mouse direction and mouse x, y on that clip.

on the picture the 0, 0 of the mc containing red box is where the lines cross, the mouse point is indicated with cursor and around it is the circle where clip's x and y should be constrained and movieclip should rotate according to mouse movement direction for example: when mouse is moving straight down then the clip's x, y rotates up and stops when its 12 o'clock...

View 7 Replies

Moving From One MovieClip To Another?

Mar 7, 2009

I have a main MovieClip in which I have several frame labels, each will eventually have different MovieClips associated with them. First time through I want to play an "intro" MovieClip, which I have placed on the stage at the begining of the main timeline, then at the end of the "intro" Clip, go to the first frame label and play that MovieClip.

The way I was going about it was placing this code in the last frame of the "intro" MovieClip:

Code:

MovieClip(parent).screen_mc.gotoAndPlay("home");

'screen_mc' is the instance name of the Main MovieClip.

[URL]

View 3 Replies

[F8] Moving Movieclip With A Mouseclick?

Nov 26, 2008

Im currently making a game that has one of those old-skool Fallout maps (a world map where you click somewhere and the "you" marker moves there) that im trying to replicate.I already have the scripts ready for map interaction (using onhit here). But i was wondering if someone could help me with a script that works this way:

1. I have a movieclip (the character)

2. When i click somewhere on the map i want this movieclip to move there. Not instantly but moving over the screen to that point where you clicked.

3. I also want there to be passages that when the movieclip hit that movieclip (named hit for example) it stops dead and doesn't move (will be used on the map for mountains and such) and the player has to click somewhere else to move it that path (im assuming this will be something like onhit: hit - speed=0 something but im not a good scripter and it would had to be worked into the script.

4. ok this one is kinda optional but would be great! If it's possible to have it worked in the script that when the clip doesn't move (and is stationary on the map) the movieclip stays on frame 1 but when the movieclip is in motion (and moving across the screen) the movieclip is on frame 2 (and reverts to frame 1 when it's not moving anymore and so no)

View 15 Replies

Professional :: Moving Movieclip Up And Down

Aug 9, 2010

I have a movieclip that I want to move down and up.I use a new tween using the Elastic. easeOut property to move the movieclip down over a duration of 2 seconds.But right after it moves down I need to move it right back up so it looks like a uniform animation.I used setInterval(reverse,2000) and reverse contains yoyo();This almost works.Since Elastic slows down the movement of the movieclip at the very end, there seems to be a pause between the movieclip moving down and the movieclip moving up.It does not give the impression that it is 1 tween, which is what I was going for.I tried to set the duration to less than 2 seconds, but then Elastic property is not 'stretchy'.It is too fast and comes to a halt, not elastic, and then the reverse (when the movieclip goes back up) is much faster than when the movieclip goes down.Is it possible to move the movieclip down AND up by using just 1 "new tween" function?

View 2 Replies

Professional :: Moving Movieclip Up And Down?

Oct 25, 2006

I have a movieclip that I want to move down and up.  I use a new tween using the lastic.easeOut property to move the movieclip down over a duration of 2 seconds.  But right after it moves down I need to move it right back up so it looks like a uniform animation.  I used setInterval(reverse,2000) and reverse contains yoyo();This almost works.  Since Elastic slows down the movement of the movieclip at the very end, there seems to be a pause between the movieclip moving down and the movieclip moving up.  It does not give the impression that it is 1 tween, which is what I was going for.  I tried to set the duration to less than 2 seconds, but then Elastic property is not 'stretchy'.  It is too fast and comes to a halt,not elastic, and then the reverse (when the movieclip goes back up) is much faster than when the movieclip goes down.  Is it possible to move the movieclip down AND up by using just 1 "new tween" function?  I am out of ideas.

View 2 Replies

ActionScript 2.0 :: Moving A Movieclip?

Jun 4, 2004

I want to rotate an object in AS because i think moving it manually is a waste of time

View 1 Replies

ActionScript 2.0 :: Moving A Movieclip Up And Down

Nov 17, 2002

how to make the scroll/list menu in 2advanced's portfolio section, it can be found here [URL]

I kinda had a idea on how to make it , by using a mask and movie clip which holds the buttons, and then just use the up and down buttons to move the movie clip up and down, but dnt really know how to really do this.

basically want to know how to move a Movie clip up and down when a up or down button is pressed with restriction to how much i can move it up and down,

View 12 Replies

ActionScript 2.0 :: Horizontal Moving Movieclip?

Jan 12, 2009

I have a movieclip that I am moving behind a mask to achieve a panning effect. I am able to move my movie clip onRollOver and stop onRollOut. So far so good, except that I have no boundaries or margins on my movie clip so when I keep my mouse on my button, my movieclip continues to move indefinitely forever. Can someone please tell me how to set boundaries on the left and right or how to limit the scrolling to an X -1000 and X +1000?

[Code]...

View 1 Replies

ActionScript 3.0 :: Moving MovieClip From Left To Right

Mar 11, 2009

Basically I need to have a cartoon character walking to the right hand side of the screen and then turning around and moving back to the left hand side and so on.
I have some code done but it could be all wrong as I am not the best coder at all, just starting out.

Code:
package classes{
import flash.display.MovieClip;
import classes.RollableChar;
public class MainApp2 extends MovieClip{
//public var theCharacter:MovieClip;
//public var myCarrot:RollableChar;
[Code] .....

View 1 Replies

ActionScript 3.0 :: Moving MovieClip With Keyboard?

Sep 29, 2010

I'm exploring menu's in flash and I'm currently trying to put together a thumbnail menu where thumbnails are contained in a Parent MovieClip.I want to then be able to move that movieclip along the stage (to the left or right, depending on the keyboard key pressed)..I know I can do this using this code, when the Parent MovieClip

stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);function myKeyDown (e:KeyboardEvent):void{
if (e.keyCode == Keyboard.RIGHT){my_mc.x -=125; }

[code].....

View 5 Replies







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