AS3 - Slow Random Movement
how can i make this kind of slow random movement ... like you see here the clouds bg: http://www.acidhousepost.com/home.htm
Ultrashock Forums > Flash > ActionScript
Posted on: 2008-07-01
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
AS Movement Slow? :(
Hi there all!
I'm currently bussy making a basic game. I have iteems falling from the sky, 5 max. at the time.
All the falling items have a motion tween in them.
It works fine when I test my movie (ctrl+enter) But when I open it in my webbrowser, the items are falling kind a slow and bit bumpy too :(
My frame rate is 31fps I've tried to make that larger, but even then it bumps :s
Someone know how this can be?
Oh btw. the movement of the items is controlled in an onEnterFrame. Could this be the problem? And if so, someone knows an other way to move them?
Thanks in advance! Dwight
Help, Slow Movement With Actionscript.
This is probably really easy but,
I need to know how to move/rotate an object slowly using action script. I made a test file to try and rotate a MC by 20 points left or right in a smooth motion. Here is a code example:
function rotateRight() {
for(var i=20; i>0; i--) {
_root.myDial._rotation = _root.myDial._rotation + 1;
}
}
Now this works.. But it rotates it so fast I might as well not use a counter. I hope I'm explaining myself well .
Thanks in advance,
Slow Movement When Arrow Over
can anyone help. i want to create the navigation as http://www.square-enix-usa.com/dvd/ff7ac/ -press on characters button. The buttons/images slow when arrow over. I want to do the same as this.
Any links to flash script or any help would be great.
Scripting Very Slow Movement
Hello,
I am trying to impart random direction very slow movement (on the order of a pixel every minute or so to a movie clip. Essentially when the clip loads I want to give it positive or negative x and y direction and then have it move along those lines very slowly. The problem I am having is that the increments are small enough that flash is returning eros and all of the clips move in the negative direction regardless of the variable that controls direction. I was wondering if anyone had a work around for the small increments issue. The script is below. Thanks
ActionScript Code:
onClipEvent (load) {
rate = math.random()*(0.5);
moveDirX = math.round(math.sin(math.random()*(360*3.14/180)));
moveDirY = math.round(math.sin(math.random()*(360*3.14/180)));
}
onClipEvent (enterFrame) {
_parent._x += (moveDirX*rate)/100;
_parent._y += (moveDirY*rate)/100;
if (_parent._x <=1) {
_parent._x = 549;
} else if (_parent._x>=550) {
_parent._x = 2;
}
if (_parent._y<185) {
_parent._y=186;
moveDirY=moveDirY*-1;
} else if (_parent._y>=215) {
_parent._y=214;
moveDirY=moveDirY*-1;
}
}
Hod Do You Slow Mouse Movement?
Hey all,
I just joined Kirupa, my friend recommended it to me when I told her what I was trying to do. I am a designer, but writing actionscript is not my strong suit.
I'm working on a project where I'm trying to slow the actual mouse movement as it is moved to the center of the top of the stage. So, the mouse would move normally at the bottom of the stage, and slower and slower until, at the center of the top, it would come to a halt.
I'm not sure where to begin, can anyone help me out/point me in the right direction?
Thanks...
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
Slow Action Script Movement
I have 2 problems with a site i am currently building, any help with either would be great.
1) i have a moving background with stripes on it, as it move all the strpes look funny.I have tried a jpeg and gifs, and even drawn directly into flash.The result is always the lines being disjointed and looking in strange.
note that in safari they look fine, this is only in IE.
2) I am using actionscript to movie movieclips
ie-
on button::::::
on (press) {
box.xFinal = -228;
box.yFinal = 256;
box.xScaleFinal = 100;
box.yScaleFinal = 100;
}
with the movie clip actionscript being::::::
onClipEvent (load) {
var easing = 4;
var xFinal = this._x;
var yFinal = this._y;
var xScaleFinal = this._xscale;
var yScaleFinal = this._yscale;
}
onClipEvent (enterFrame) {
this._x += (xFinal-this._x)/easing;
this._y += (yFinal-this._y)/easing;
this._xscale += (xScaleFinal-this._xscale)/easing;
this._yscale += (yScaleFinal-this._yscale)/easing;
}
the problem is that on every computer it seems to be a different speeds.
on newer pcs it is much faster than on older pcs.It is also different speeds on different macs, also loading a movie in a higher level with this kind of actionscript movement seems to slow it down, whereas if itsthe base movie it is better.
thanks for any pointers
NPC Movement Script Is Running Ridiculously Slow... Sometimes.
Hello everyone! This is my first post on this forum. I'm extremely new to actionscript and I'm diving headfirst into it. I hope to eventually be able to provide the help I'm looking for to others in my extremely frustrating situation.
Anyhow, I've got a little NPC to follow my player character. I'm trying to make my code as reusable as possible, so everything has its own class. I really don't know the do's and don'ts, and I have a feeling I'm breaking a lot of rules already. So what happens is extremely weird. The game runs fine if the NPC is very close to my player, but as soon as he gets just a few pixels too far away, it slows down considerably. I really don't understand what's going on.
I also noticed that it seems to slow down the timer instead of just the framerate. I made my main loop a timer on the document class that calls all the main loops of each class. I did this as a failed attempt to maintain the same speed of movement, even when I can't guarantee the same framerate.
Thank you all for any help you may be able to offer. Here is the relevant part of my NPC Class script.
Code:
public function NPC()
{
this.addEventListener(Event.ADDED, initialize)
}
function initialize(event:Event)
{
MyParent = event.currentTarget.parent;
MyBorder = MyParent.nBorder;
}
public function myLoop()
{
hitDet();
chase();
moveCharacter(CurrentVSpeed, CurrentHSpeed);
}
public function chase()
{
if(MyParent.Player.x < this.x)
{
CurrentHSpeed = Speed;
}
else if(MyParent.Player.x > this.x)
{
CurrentHSpeed = -Speed;
}
if(MyParent.Player.y > this.y)
{
CurrentVSpeed = Speed;
}
else if(MyParent.Player.y < this.y)
{
CurrentVSpeed = -Speed;
}
else
{
CurrentHSpeed = 0;
CurrentVSpeed = 0;
}
}
function moveCharacter(VSpeed, HSpeed)
{
if(VSpeed < 0 && BlockedUp)
{
VSpeed = 0;
}
else if(VSpeed > 0 && BlockedDown)
{
VSpeed = 0;
}
if (HSpeed < 0 && BlockedLeft)
{
HSpeed = 0;
}
else if(HSpeed > 0 && BlockedRight)
{
HSpeed = 0;
}
this.x += HSpeed;
this.y += VSpeed;
}
Unwanted Vibration In Image With Slow Movement
Hi,
I have a Flash animation where I have images moving slowly. The point is a serene graceful look but I'm getting unwanted vibrations on the images. The vibration or shaking is very minimal but enough that the client noticed it. I havent been able to find a work around. I was hoping someone maybe able to help me.
Thanks!
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();
}
Slow Down Random
Excuse me,
I have another post running around but Im into a big project and with thousands of doubts...please forgive my million help requests.. short question: how can I slow down this color random?
thanks
50 MCs Moving At Random Makes The Movie Slow
Hi friends..
I'm doing an animation where 50 balls are moving at random using actionscript. but i find the movie to be slow. ( compared to when the number of balls are reduced to 10 )
I would appreciate if anybody could help in educating me on this problem
Thanks.
Pramod
VERY Random Slow Playback On User Machines
okay... I searched the forums here for this, and found nothing specific to this problem. Now, I understand that I have no control over how a persons computer is configured, what bg tasks are running, how many apps they have open, or if they have a corrupt flash player, but I have had numerous wildly varying complaints that my site plays incredibly slow on machines that should have absolutley no problem with playback. (P3/p4 with nvidia or radeon vids) But then others (including myself) have abolutely no problems with it, even when I test it on an old PII or my old iMac.
http://www.torqdesign.net/portfolio (interactive side)
There is a quick AS while... that loops and duplicates the menus across the top, populating and colorizing them, but it executes properly and is terminated properly. Other than that, the files are very small (60k or less) and the animation isnt that intense. FPS is set to 30fps. What's the dealio? Has anyone heard/received similar feedback on their sites? I read an article on MM about very high framerates (60-100) causing issues with some machines, but I have always worked at 30fps with my stuff for the smoothest transitions and never had a problem - knock on wood. Been doing flash since version 3 and have never gotten feedback that it played doggedly slow...........
Any help or feedback is greatly appreciated...... I want to be able to either fix the problem, or give the people with the nasty feedback a reason why it's not the site and perhaps their player.
Thanks guys :-D
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
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.
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
|