Random Movement (motion)
i search for random movement (motion) on this site and i found the following. http://www.kirupa.com/developer/mx/random_motionMX.htm i followed the tutorial..but i am interested to know how do i change the speed of the motion? can someone tell me? i am not very good with actionscript. thank you.
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 08-18-2005, 07:20 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Motion/Movement
Attached is a fla that moves an image around in a hovering/floating effect. The instructions say to change the parameters to customize. I can't find the accelfactor variable to change this. Can someone help?
Random Rotation To Equal Random Movement Direstion?
k i finally got it so that my things randomly move around the screen and have walls etc etc.. anyways now i wanna know how to make it so that my randomly moving ship will rotate to face there direction if you want i can post the code i am using for random movement and thanks in advance
Random Motion Along Specified Paths At Random Intervals?
I am working on a site right now and I have a collaged background image with a faded ciruit board looking series of intersecting lines.
I would like to create a subtle gradated sphere to simulate a signal travelling along the cicuits. However, I would like several instances of the signal (or pulse) to take different routes and begin and end randomly.
Is there a way to set-up possible routes with a motion guide and then tell objects to randomly choose those routes at random intervals???
Smooth Circular Motion/movement
Hello guys,
how can I make a circular movement of an object around a point ?
I.E: a word around a dot ? I know I need to use some math funcs. but I cant manage to do it. Also I want it to move smoothly, like floating in water, like elastic. I hope u understand.
Thanks.
Smooth Circular Motion/movement
Hello guys,
how can I make a circular movement of an object around a point ?
I.E: a word around a dot ? I know I need to use some math funcs. but I cant manage to do it. Also I want it to move smoothly, like floating in water, like elastic. I hope u understand.
Thanks.
Movement A Bit Jumpy With Motion Tween
I have created a simple motion graphic.
the content is a static background, two lines, and some words. I have set up a mask layer so that as the two lines (one horizontal, and one verticle) move accross the graphic, the words are revealed.
my problem is that instead of a nice smooth movement of the lines and the mask, it jumps. Granted the jumping is very small increments, but it is deffinitly noticeable.
any ideas how to make motion tweens smooth?
thanks
Ras
Random Paths (NOT Random Motion)
I only know the basics in Flash so I'm not quite sure how to word this..
Say I've got one linear motion guide that then splits in three directions. I'd like my movie clip to travel on the path and then randomly choose which of the three paths to take. I have no idea where to begin and have searched for scripts - only random motion scripts have popped up through. Hopefully, in the end, I'd have multiple objects travelling on random paths - similar to this - http://www.flashkit.com/movies/Scrip...1926/index.php.
Thanks in advance.
Actionscript Movement Corrupt The Motion Tween
I have a MoveiClip in my stage, I use actionscript to move it to some other position. It works great.But in some frames later I inserted a keyframe and I used the same movieclip for a motion tween. but this motion tween is not considered at all. what's the problem.... how should I fix it ?!
the main goal of doing such a thing is below :
I'm doing a game, in the desired movieclip there are some other of movieclips which will be visible / invisible due to some conditions. after finishing the game I want the same MovieClip ( with exactly the same properties of visible / invisible internal movieclips) to start a motion tween, but It doesn't start the motion.
Scripted Motion - Simulating Upstream Movement
... been a while since I visited Kirupa! Hello all
How would you go about coding something like the waves in the header on this page?
http://www.trts.com/radio/radio.html
I'm hoping to write something that will look a bit like eels swimming upstream but wasn't quite sure where to start ... any pointers would be much appreciated. Thanks!
Tom
Random Movement, Random Opacity?
I want to create a mc, where a box(50x200) should duplicate itself, and change width randomly. But width should stay in ranges between 50 - 250 px. The boxes should move from left to right, right to left randomly. Also they should have random opacity and random colors(different variations of blue,and red). When the boxes overlap=the opacity should change accordingly, also color changes as they mix. Is creating something like this, or similiar possible?
If so does anybody have examples.
Thnx
Random Movement AND Random Speed
So I got this from the tut on this site and it's works great.
I can't figure out though how to make the speed random as well as the movent.
I want all my little clips to move at random speeds in adition to direction.
Any clues?
Thanks!
---------------------------------------
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
}
function hyp(a, b) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 600;
height = 400;
//-------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*4+5;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>1000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
};
--------------------------------
onClipEvent(enterFrame){
move();
}
[F8]random Scaling, But With Random Movement?
i am a bit lost. i make a prototype function that randomly scales a box when i click on the stage. i got the scaling right, but why does it move around when it scales?
here is the swf: scaleEase
here is the code:
ActionScript Code:
MovieClip.prototype.scaleEaseTo = function(ease){ onMouseDown = function () { newWidth = 1 + Math.random() * 250; newHeight = 1 + Math.random() * 250; }; this._xscale += (newWidth - this._xscale) / ease; this._yscale += (newHeight - this._yscale) / ease;};dot.onEnterFrame = function(){ scaleEaseTo(5);};
thanks in advance.
Random Movement AND Random Speed
So I got this from the tut on this site and it's works great.
I can't figure out though how to make the speed random as well as the movent.
I want all my little clips to move at random speeds in adition to direction.
Any clues?
Thanks!
---------------------------------------
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
}
function hyp(a, b) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 600;
height = 400;
//-------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*4+5;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>1000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
};
--------------------------------
onClipEvent(enterFrame){
move();
}
Random Motion
Need to create randomly moving object, not jerking though... Say, dog. Need script. Anybody, help... Please!
Will appreciate if you e-mail me to: dedbabay@aol.com
Random Motion
Hi all,
I am trying to modify one of the "action script tutorials" from Kirupa; it's called random motion. (http://www.kirupa.com/developer/actionscript/random.asp)
I am trying to modify it, so when the user roll over on one of the moving graphics, that particular one will stop, and when the user roll off on it, it will start moving again.
Anyway, I hope some one knows! Thanks a lot!!!!!!!!!!!!!!
Wa ha ha ha
Random Motion And More
Hello all,
Okay here is my problem. Say I have these letters spelling out a word. Each letter is a mc. Now I want these letters to move randomly over the screen. I also want them to every so often return to their original position and form the word. How would iz go about doing something like that.
Thanks.
Random Motion
Hi (again)
Can anyone tell me how i can duplicate a movie clip and place it at random places along the 'x' axis so that they then fall to the bottom of the screen individually of each other (i know how to make them fall). I use this script (below) to duplicate the movie clip but the movie clip just randomly flashes around the screen and dont fall individually of each other (they fall as a group).
increment = 0;
while (increment<=30) {
duplicateMovieClip("apple", "apple"+increment, increment);
increment = ++increment;
}
stop();
This script (above) is on the main timeline and inside the movie clip itself i have this script (below). I cant work out this random script to stop the movie clip from flashing around the screen.
this._x = this._x + (Math.random()*8)- 4;
this._y = this._y + (Math.random()*6)- 3;
I'm not to sure how this works or why the movie clip just flashes around the screen. I want it so that the movie clip appears on the screen and then falls to the bottom (but i think that i can work out the falling part).
Any ideas? I have no idea about this
Thanks anyway!! (this is really killing me)
(i havent put the falling script in yet)
[F8] Random Motion
hi
Doea anyone know how to create a smooth random motion with the object keeping the right orientation (allways 'looking' forward)?
I'm using FuseKit by the way ..
Random Motion
Hi all
here is a bit of actionscript I got from a tutorial at gotoandlearn which causes the ball movie clips to move around randomly. if you want to try itself just create a MC with a graphic in and make sure export for actionscript is selected under linkage(in the library) and give it an identifier of ball.
So the problem is that if I lower the speed at which the balls move around, which I do by changing the code this._x += (this.dx - this._x) / 8; to
this._x += (this.dx - this._x) / 25; then eventually all movement stops.
Any ideas why and how to prevent it from doing that?
here is the code:
for(i=0;i<20;i++){
var t = this.attachMovie("ball","ball"+i,i);
t._x = Math.random()* Stage.width;
t._y = Math.random()* Stage.height;
t.dx = Math.round(Math.random()* Stage.width);
t.dy = Math.round(Math.random()* Stage.height);
t._xscale = Math.random()* 20+80;
t._yscale = t._xscale;
t.onEnterFrame = mover;
}
function mover(){
this._x += (this.dx - this._x) / 8;
this._y += (this.dy - this._y) / 8;
if (Math.round(this._x) == this.dx)
{
this.dx = Math.round(Math.random()* Stage.width);
this.dy = Math.round(Math.random()* Stage.height);
}
}
Random Motion
i`ve made a random motion code, and added it to a MC. but when i duplicate MC a problem occurs. all duplicated MCs move randomly, but only for some time, afther that all, but one, move to (0,0).
why`s that??
look at .fla file
Random Motion
Hi all. Can somebody point me in the direction of a tutorial or some help to do with random triggering of movies? I have a small landscape and various little clips of events happening on the landscape, I need the events to happen at random times in no particular order. Does anyone know of a tutorial, or at least the terminology so I can look it up?
Many thanks.
L.
Random Motion
I enjoy the tutorial at
http://www.kirupa.com/developer/mx/random_motionMX.htm
it's very cool. I was messing around with the code, but i can't seem to limit the perimeter that the images are moving. The images are moving beyond the set
// specify the width and height of the movie
width = 300;
height = 200;
is there a code that I can allow for the images not to pass the desired width and height?
If you do not know what i'm talking about, u can click on the link above. Notice how the cones go beyond the width and height that is set.
Thanks for reading and any help is appreciated.
More Random Motion
Ok, so I've been playing with the random motion code from the vibrate tutorial and I have a question.
I like the effect I'm getting but I'm wondering if it's possible to write some code to animate the movement between the random jumps the objects make. I'm trying to create random motion with smooth transitions.
HELP - Containing Random Motion
Hi all, if anyone could help me with this I'd greatly appreciate it. I'm experimenting with random brownian motion and it works great. Code below:
goto=Math.random()*Math.PI*2
x=x+r*Math.cos(goto);
y=y+r*Math.sin(goto);
this.lineTo(x,y);
so what this gives me is a great random little scribbler that I love. What I can't get it to do is to follow an "approximate path" while moving randomly. I.e. moving randomly within a confined space. I don't want to use the traditional bouding box idea b/c the shape I'd like to confine it to is more complex. What I need is more of a path solution, or a bounding box that is a complex shape. Any ideas anyone?
Best regards,
zf.
Random Motion
I followed the random motion tut but itīs not working.
www.kirupa.com/developer/actionscript/random_movement.htm
Where should I put that code? in a frame or in the Mc or both?
thanks
Random Motion --better
I have studied this tutorial
http://www.kirupa.com/developer/mx/random_motionMX.htm
but i wonder is there anyway to make the motion more smoother? Not so "hard" when the mc change direction?
Random Motion
I am trying to make the movieClip named "fish" go to a randomly generated spot. I tried using the tutorial, but I didn't understand the math, so I tried it with my own code. I'm not as much interested in getting this to work as I am knowing why it doesn't work. So if someone could please explain why my code doesn't work, I'd be very appreciative.
PHP Code:
fish.onLoad = function() {
generatePoint();
}
fish.onEnterFrame = function() {
x = _x;
y = _y;
changeX = pointX-x;
changeY = pointY-y;
slope = changeY/changeX;
goX = speed;
goY = slope*speed;
if(_x<pointX) {
_x += goX;
} else {
_x -= goX;
}
if(_y<pointY) {
_y += goY;
} else {
_y -= goY;
}
if(hitTest(pointX, pointY, true)) {
generatePoint();
}
}
function generatePoint() {
pointX = random(Stage.width);
pointY = random(Stage.height);
speed = random(10)+1;
}
Thanks
Random Motion
I just went through the tutorial on random motion and wanted to take it a step further.
I would like to have the items stop on mouseover and load another movie. Basically, this is the bio page for a film company and the pictures of the two people are going to float around in random motion and when you mouse over one or the other, the pictures stop and go to the side and the bios load.
Thanks,
j
Random Motion
Hey All,
http://www.kirupa.com/developer/acti...dom_motion.htm
I was Wondering if there is any code that can flip the image Horizontally when movement travels to the right and of course flip it back when it travels left.
Thanks
vxd
AS3 Random Motion
Help! My balls aren't moving...
"mover" function worked in AS2, but not translating to AS3.
Code:
for (var i:Number = 0; i < 10; i++) {
var ball:Ball = new Ball();
ball.x = Math.random()* stage.stageWidth;
ball.y = Math.random()* stage.stageHeight;
ball.dx = Math.round(Math.random()* stage.stageWidth);
ball.dy = Math.round(Math.random()* stage.stageHeight);
ball.alpha = Math.random() * .9 + .5;
ball.scaleX = ball.scaleY = Math.random() * 4.5 + .8;
addChild(ball);
ball.addEventListener(Event.ENTER_FRAME, mover);
}
function mover(e:Event):void {
this.x += (this.dx-this.x)/.2;
this.y += (this.dy-this.y)/.3;
if(Math.round(this.x) == this.dx) {
this.dx = Math.round(Math.random()* stage.stageWidth);
this.dy = Math.round(Math.random()* stage.stageHeight);
}
}
Noob missing something simple?
Random Motion
I enjoy the tutorial at
http://www.kirupa.com/developer/mx/random_motionMX.htm
it's very cool. I was messing around with the code, but i can't seem to limit the perimeter that the images are moving. The images are moving beyond the set
// specify the width and height of the movie
width = 300;
height = 200;
is there a code that I can allow for the images not to pass the desired width and height?
If you do not know what i'm talking about, u can click on the link above. Notice how the cones go beyond the width and height that is set.
Thanks for reading and any help is appreciated.
More Random Motion
Ok, so I've been playing with the random motion code from the vibrate tutorial and I have a question.
I like the effect I'm getting but I'm wondering if it's possible to write some code to animate the movement between the random jumps the objects make. I'm trying to create random motion with smooth transitions.
HELP - Containing Random Motion
Hi all, if anyone could help me with this I'd greatly appreciate it. I'm experimenting with random brownian motion and it works great. Code below:
goto=Math.random()*Math.PI*2
x=x+r*Math.cos(goto);
y=y+r*Math.sin(goto);
this.lineTo(x,y);
so what this gives me is a great random little scribbler that I love. What I can't get it to do is to follow an "approximate path" while moving randomly. I.e. moving randomly within a confined space. I don't want to use the traditional bouding box idea b/c the shape I'd like to confine it to is more complex. What I need is more of a path solution, or a bounding box that is a complex shape. Any ideas anyone?
Best regards,
zf.
Random Motion
I followed the random motion tut but itīs not working.
www.kirupa.com/developer/actionscript/random_movement.htm
Where should I put that code? in a frame or in the Mc or both?
thanks
Random Motion --better
I have studied this tutorial
http://www.kirupa.com/developer/mx/random_motionMX.htm
but i wonder is there anyway to make the motion more smoother? Not so "hard" when the mc change direction?
Random Motion
I am trying to make the movieClip named "fish" go to a randomly generated spot. I tried using the tutorial, but I didn't understand the math, so I tried it with my own code. I'm not as much interested in getting this to work as I am knowing why it doesn't work. So if someone could please explain why my code doesn't work, I'd be very appreciative.
PHP Code:
fish.onLoad = function() {
generatePoint();
}
fish.onEnterFrame = function() {
x = _x;
y = _y;
changeX = pointX-x;
changeY = pointY-y;
slope = changeY/changeX;
goX = speed;
goY = slope*speed;
if(_x<pointX) {
_x += goX;
} else {
_x -= goX;
}
if(_y<pointY) {
_y += goY;
} else {
_y -= goY;
}
if(hitTest(pointX, pointY, true)) {
generatePoint();
}
}
function generatePoint() {
pointX = random(Stage.width);
pointY = random(Stage.height);
speed = random(10)+1;
}
Thanks
Random Motion
I'm trying to make add this little movie clip to my page but I can't seem to get it to work properly. What I'm trying to do is this. I have a bunch of short lines and i want them to move up and down smoothly and continously. I looked at the random motion tut on the site but it didn't look like what I was after.
Can some one help?
Thanks
PS. you can view the site at www.jcgsolutions.ca so you can have a look at what I'm talking about. The movie clip is in the upper right corner.
jayjay
Random Motion
I admit that I'm not too smart. I've just begun using FMX and I am revamping my website using a full-flash site (flashnetized, or what have you). I really want to use the Random Movement AS that is here, but when I add it to my existing movie - nothing moves. What am I doing wrong? Please help me, I'm dumb.
Random Motion
I just went through the tutorial on random motion and wanted to take it a step further.
I would like to have the items stop on mouseover and load another movie. Basically, this is the bio page for a film company and the pictures of the two people are going to float around in random motion and when you mouse over one or the other, the pictures stop and go to the side and the bios load.
Thanks,
j
Using Random Motion
hello ive created an external .as file and this is my code:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
bigButton.onPress = function(){
var it:Tween = new Tween(bigButton,"_y",Strong.easeOut,bigButton._y,randomNum,1,true);
}
var randomNum = Math.random()*300;
and here is the code from my flash file:
Code:
#include "externalas.as"
so when I press the bigButton movieclip it randomly goes to a location determined by the random(); function.
BUT when I press the bigButton again it does nothing!
can anyone tell my why this is and help me so that if i click on it once it will go to a random place and then if i press i press it again to another random place.
please help
Random Movement
Can anybody help please?
I want a movie clip to move randomly after a certain length of time, then keep looping over the same amount of time and changing the movie clips position randomly. Is there a script which will wait before executing an action, then keep looping that action until anougher condition tells it to do something else?
I tried
if (Number(getTimer()>=500){
---then do a random move function
{
The problem with this is it doesn't keep executing the script until I tell it to stop.
Thanx in advance
Nick
Random Movement
quite a simple one i'm sure.....
I have a series of objects and i want them to randomly move up and down the stage, no interaction necessary, i just don't want to have to tween 10 or so objects.
Is this possible, and is it also possible to replicate the effect of 'easing in and out'
thanks in advance....
Random Movement
i have 10 vertical bars that i want to randomly move across the screen left to right. i dont know how to accomplish this and am hoping that someone would be kind enough to expalain it to me. thank you.
josh
i_am_brucelee@hotmail.com
Random Movement For Mc
Hi everybody,
I am trying to get a movieClip to randomly move around within
a confined area of my stage. When I try to do this it moves very
irraticly and doesnt stay within any boundries.
this is what I tried:
onClipEvent(enterFrame){
this._x=Math.random()*50;
this._y=Math.random()*50;
}
I want a nice fluid motion that will stay in some defined boundries.
Thanks for the Help
Random Movement
u wud think that this wud be simple ah. simple to do, and even simpler to find. nope ..
does anyone know how i may create randomlly moving elements. ie, i want thesse incy wincy things to float around the stage. no collision detect, no nuffin'
i have looked all over this site .. i have found a couple of movie examples, but one is button triggered, and the other is waaaaaaaaaaaaay to complicated.
help Much appreciated.
thx
b
Random Movement
hej venner
could anybody helpme with a script that makes an object (button) move in an nice smooth random path (infinitly , and in an area slightly exceeding the visible)?
i would be most appreaciative@
thank you in advance
[Edited by sjovefro on 06-04-2002 at 12:23 PM]
Random Movement
I'm making a menu and when I go over the buttons I want them to shake. So i guess this would mean some random movment of some kind. Now I'm not very good at A.S., could someone code this up for me. I need the instance to shake, so in other words move from frame to frame move from one location to an other very quickly in a small amount of space.
Thank You,
Sebastien Couture
Random Movement Of MC
Please can anyone please suggest me how can i have a random movement of an movieclip using actionscript.
Arup
Random Movement
is there code that i can use to make a graphic move randomally within a rectangle on screen?
|