Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Flash




Random Movement



I would like to create some random movement for a mc i made. my stage size is 790 x 600 but the area i want the movie clip to move is is only 720 x 268. www.izzos.com/beta is where the site is and you will see the roll your own text at the top. I only want it to move within that green background area. I have used some scripts before but all of them make my text scroll around the entire stage area. Any help is appreciated, thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

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 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 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?

Random Movement
hey all

having some trouble with a game im making. i need an MC to reappear at a random location inside a box. im using this code

setProperty (_root.object, _y, _root.object._y=random(100-350)
setProperty (_root.object, _x, _root.object._x=random(300-250)

im only a beginner and im probably doin somthing stupid here so it would be much appreciated if someone could point me in the right direction??

cheers

Random Movement AS?
Hey,

Does anyone have any code,tips or tutorials involving random movement of an object? I don't mean random x or y values, but fluid movement. A good example would be like a fish moving around - that sort of thing...

Random Movement
Hi There,

I am using the below code to ease a movie clip to a random target, which it does, but I want it to then ease to another random target, once it reaches the target before, so in effect, it is constantly moving to random targets. Any ideas????

On frame 1:

_y=100;
targety=n;
n=random(100-600);
speed=32;


On Frame 2:

distancey=targety-_y;
amount=distancey/speed;
_y+=amount;


On Frame 3;

gotoAndPlay(2);


Thanks in advance!!!

Barry

Random Movement
Im making a game and I needs o have butterflys moving in a random way, I would be very happy for any help. I want then to curve instead of just a sharp corner.

Thanx in advance,

Random Movement
I am making a flash movie for a screen saver I have a Movieclip I want to move all around the stage on a Random basis. How would I code or script the (motion)Movieclip to move around randomly?
If you know some code or a tutorial I would appreciate the help.

Thanks.

Random Movement?
Hey everybody.

Just wondering:
How to make an as moving a MC randomly around a swf.

Example:
An ant moving around the page randomly..

Thank you for your time

Need Random Movement
anybody know of a good tute for making an object move randomly about the stage area.

Random Movement
I'm sure I’ve seen something like this before an image to move up, down, left, right and diagonally randomly using AS.

I plan to have a box let's say size 100x100 and within that box will be an image about 200x200 in size, so all you can see of the image is 100x100 (sort of masking), then the image to move randomly in all directions and if possible with random speed.


Please can someone point me in the right direction.


Many thanks


Michael

Random Movement
Hi,

I looked at some flash-sites and one site draw my attention.
I'm talking about www.derbauer.de.
In there you see a very nice flash-site.
But what I'm interested in is the background.

You see screens opening and closing, stuff appearing and so on....
At first it doesn't look so hard but the thing is, it looks like is doing that randomly.

And that the part i don't get, how does he do that?
Does anyone here know how to do something like that?
Because I don't and I would really like to know.

So would anyone be so nice and tell me or give me an example of how it is done?

Thx

Random Movement
hi everyone,

i need some action script to work with random movement. basically i need fish to swim randomly over the movie but also if they change direction the instance movies needs to be flipped.
Could anyone help me with this problem
thanks.

Random Movement
Im creating a game in which i need to make a load of objects randomly move. Does anyone know how i can do this? I also need them not to disappear off screen. If anyone could help i'd be very greatful.

Thanks

Random Movement
Is it possible to have random movement for a movieclip within a restricted area?

If so , anyone have a clue on how to do it?

Random Movement
I'm making a game in an overhead type of view and want to know how to make a movieclip Randomly move around the map and face the direction that it is moving. I have the movie clip moving but it doesn't face the direction that it faces. Which looks really bad.

Random Movement Etc.
Hi,

I'm trying to make these fireflies: http://listic.dk/324fireflies.swf

I have loaded the thing into a flash decompiler, but I must be doing something wrong, because it doesn't work, my .fla can be found here: http://listic.dk/fireflies.fla

I would very much appreciate if one of you experts maybe could take a look at the scripting and see where I'm doing it wrong :-)

All the best

Andrew

Random Movement...
Im trying to get a movieclip to be placed on the stage (from a button press) and move randomly in one direction at one speed.


Eventually ill write the code for it to stop when it hits the edge but im just looking for the random directional movement right now...

any help would be greatly appreciated

Random Movement
you can i make a few movie clips move in a randomly around the stage?

Random Movement
Does anybody have any random code I can slap on a movieclip that will look like a bird (seagull) moving in the distance? I tried tweening it it but it just looks too repititive and boring.

Please!!!

Random Movement
Hey guys,

i'm slowly but surely piecing parts of my game together, but I was wondering if you could help...

I want a target to move around the window at random, bouncing off of the walls and then continuing on. Is this possible to do, and secondly is it easy to do, coz I have no flash skill whatsoever and this has to be completed in the next few hours.

I have the target already made into a movie clip within Flash, I just need help with the actions that have to be attatched.

any help that you can provide is greatly appreciated. Thanks.

Random Movement
Hey guys,

i'm slowly but surely piecing parts of my game together, but I was wondering if you could help...

I want a target to move around the window at random, bouncing off of the walls and then continuing on. Is this possible to do, and secondly is it easy to do, coz I have no flash skill whatsoever and this has to be completed in the next few hours.

I have the target already made into a movie clip within Flash, I just need help with the actions that have to be attatched.

any help that you can provide is greatly appreciated. Thanks.

Random Movement
Hey guys,

i'm slowly but surely piecing parts of my game together, but I was wondering if you could help...

I want a target to move around the window at random, bouncing off of the walls and then continuing on. Is this possible to do, and secondly is it easy to do, coz I have no flash skill whatsoever and this has to be completed in the next few hours.

I have the target already made into a movie clip within Flash, I just need help with the actions that have to be attatched.

any help that you can provide is greatly appreciated. Thanks.

[CS3] Random Movement
Hi everyone

i have a 779 x115 movie with text in the middle. I have a few squares which randomly move around the movie using this actionscript

onClipEvent (enterFrame) {
_x = random(779);
_y = random(115);
_alpha = random(100);
}

if i want the squares to just randomly move around the area where the text is how do i tell it to do that? corodinates are top left: 263, 65 bottom right: 515,74 probably very easy to do but im not very good at script yet.

thanks very much for your help

AS3 Random Movement
Hi there,

I'm looking to do something like this: http://www.samburdge.co.uk/developme...2#comment-8835 in AS3 and wondered if anyone could help. I'm new to Flash in general and can't seem to figure it out. Basically I want a number of move clips on the stage (preferably moving in some way) and when the mouse hits off them, they scatter/move out of its way.

Any help would be greatly appreciated.

Daria

Random Movement
im looking for a peice of code that allows a movie clip to move randomly whilst avoiding the mouse, theres no end of tutorials for mouse avoid and random movement but given that to combine the two im having to hack together code with out knowing how it realy works i end up with a mess that dosnt do anything! so any one know of an inclusive tutorial or a peice of code that is idiot proof??

John

Random Movement + More
Okay, i made a random movement on a mc. here's the code:

onClipEvent(load){
xDir=random(3)-1;

}
onClipEvent(enterFrame){
_x+=xDir;

if (random(10) == 0){
xDir=random(9)-4;
}

}

(it only moves in x)

So now i want the mc to rotate to the position where it is going. lets just say that the mc is an arrow. then i want the arrow to the right when its moving to the right, and the arrow to the left when its moving left. And if its possible, the arrow should point up when the mc is standing still...

Also im looking for a action, that make the mc turn arround and move away when it hits "the walls".

Can anybody help me?

Thanks, Andy

Help With My Random Movement
Hi was wondering if anyone could help me out a little.

I found this brilliant bit of code (might have even been on this forum cant quite remember) credit to the author it is good.

My problem being is that the random movement (floating) has the potential to move off the stage which i dont want it to do. It quite simply floats away.
Is there any way i can make this have boundrys? and if thos boundrys are broken send it back down wards but in a nice fashion, eg smoothly?

Any help is much appreciated.

regards

alan


Code:
onClipEvent(load){
var my_x:Number = 0;
var my_y:Number = 0;
}

onClipEvent(enterframe){
my_x += 0.1;
my_y += 0.2;

this._x =this._x +Math.sin(my_x);
this._y =this._y +Math.cos(my_y);

}

Random Movement
i'm making a game, kinda like asteroids, i need some help making the asteroid randomly move, i need a basic code, or and easy way to make it go in a strait path but randomly everytime.......please help

Random Movement
Currently I’m working on a website measuring 770 X 440
And I want to make a random movement in my movie
But not the whole movie coz when I’m going 2 make a random movement
It contain the whole movie size not the size which I want
I want 2 make a random movement movie size 200 X 300 in a 770 X 440 movie
Is there any way to make dat movement?

hope any guy will help me

regards
amjad

Random Movement
this is a great site. i love the feel of it but i have a question
how where the little cells made so they can float around freely such. they never move in the same path twice it is at random movements everytime.

http://www.jakalope.net/

-Tim

Random Movement For Mx
hello all

I´m so newbie in this, and thats why I´m making this question, anyone, as the ramdom movement code working for mx, i´d tryied to follw the threads of the forum but I can´t manage to start working the thing. Anyone can help me?

thanks

thebull@mail.telepac.pt

Random Movement
I've seen the tutorial for the random movement in flash mx but i've bee having some problems. How do you make it so that it starts where you want it. Ex. after i set the coordinates and I test the movie it will slide somewhere(at random) then start sliding only in the set parimaters. I'm not sure if you understand that but plz could someone help me?

Random Movement
Aight i read your tut on random movement and it worked. but i tryed it on a MC with 6 mc's in it. the 6 mc's have already done some tweeding and at the end are all aligned. the thing is, when the random source comes to play, he 6 mc's all start from the same spot and then starts to move at a random direction. what i want is that they move from the position at the end of their tweeding... yes im a big ***** noob at this, but it would be really great if i could get help to this. Thx......... oh happy late new years, Peace y'all

Random Movement
Hello,

I followed the tutorial for random movement, http://www.kirupa.com/developer/mx/random_motionMX.htm
This is working but i dont want the object do straight lines, but if possible natural swirls or movent....

how can i fix this in the actionscript?

Thanx for your reply...

Andreas

Random Movement Help
I would like to create something along the lines of the random movement tutorial, but instead of the object stopping randomly and moving randomly, I want them to bounce off the walls and continue in the bounced direction, would anyone know where I can learn to do this?

thanks alot

-dryst

Random Movement
I know that the site has a page on random movement, but can someone explain the code to me because I'm still quite a newbie. Also, is there a way to not have the movie clips pause? Thanks.

Random X Movement
I want to have a movie clip that moves just in the x direction but is randomly placed and has a random speed. I've tried to tweek other random codes out there but I can't get them to work. Could someone please provide me with a little assistance?

Copyright © 2005-08 www.BigResource.com, All rights reserved