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




Seamingly Easy Movement ?



I have a block that i'm trying to make move from right to left, and if the block gets to a certain point, it will move back to it's original position. So, i have this on my block (movieclip) rightnow
Code:
onClipEvent(enterFrame) { speed = 3 dist = 8.5 _x -= speed; if (_x = dist) { _x += 3 } }
But all this is doing is throwing the block at the 8.5 distance... any help???????? Thanx in advance



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-15-2004, 08:16 PM


View Complete Forum Thread with Replies

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

Seamingly Easy Movement ?
I have a block that i'm trying to make move from right to left, and if the block gets to a certain point, it will move back to it's original position.
So, i have this on my block (movieclip) rightnow


Code:
onClipEvent(enterFrame) {
speed = 3
dist = 8.5
_x -= speed;
if (_x = dist) {
_x += 3
}
}
But all this is doing is throwing the block at the 8.5 distance...

any help???????? Thanx in advance

Easy Random Movement?
Hi everybody

Anyone knows an easy way to make random movement? This is, I have a fly on the stage, and I want it to move all around randomly.

As easy as it sounds...

I also need how to make it stop and fall to the bottom of the screen when I press a button, as a spray or something like that.

Thx in advance!

MC Control And Movement.. This Should Be Easy
I am using flash MX 2004 and am struggling with a bit of actionscript. I am just beginning to get to grips with actionscript but do not fully understand it... here's my problem:
All I want to do is make one MC (a) move down by about 20 pixels when the mouse is over another MC (b), and when the mouse rolls off the MC (b), then MC (a) returns to it's original place.

I need to tie the above in with this actionscript:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}

I have been trying things like:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
movieClipa.x = -20, y=0();
}
}

the main thing I need to know is the correct actionscript for moving objects on the x and y axis. The bit in italics above is where I have not got a clue what I'm doing.
Help!! I'm sure this should be easy enough!!!!!!

Mouse-movement Triggers Background Movement - Help Me Find Tutorial
I want to learn how to make an image react on my mouse-movement, so you get the effect as if you're looking around. You move the mouse to the right, and the image on the screen moves to the right, etc. I've seen an example of that on http://www.center-of-the-world.com/ - but I don't know how to find a tutorial for that on the Flashkit-site. Can anyone help?

Capturing Mouse Movement/locking Out A Direction Of Movement
does anyone have a good solution in AS 2 for simulating horizontal and vertical finger gestures like on an iPhone?

I have a Mouse listener that calculates movement in both directions and whichever one is larger in value (primary movement of mouse) then it locks out the other using a boolean value. And then once the mouseUp event is triggered, it sets the values to true again to listen for another horizontal or vertical gesture movement.

the problem I'm running into is that every once in awhile while I'm "gesturing" or moving the mouse in a particular direction, I'll get some funky results which clues me into that the other direction might not being totally locked out.

Make any sense?

Flowing Mc Movement Opposite Of Mouse Movement
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. Can anyone help me out? Thanks.


onClipEvent (mouseMove) {
buffer=20 //movement buffer
mousePos=_root.fStrip._xmouse //store mouse position
if (mymouse!=_root.fStrip._xmouse){ //if the mouse has moved
diff=mymouse-_root.fStrip._xmouse; //find amount of movement
_root.fStrip._x-=diff/buffer; //buffer & set strips movement
updateAfterEvent(); //adding this makes the movement cleaner
}
}

Image Movement Based On Mouse Movement
I have my Flash canvas. In the Canvas I have an image that's centered and larger than the canvas. Obviously the entire image isn't shown. How can I use actionscript to move the image according to where the mouse is? So if I move my mouse to the top right corner I want the image to move accordingly to display the top-right corner (obviously in a smooth fashion . I tried looking for examples but wanted to know if anybody out there new.

Any ideas?

Little help and thanks in advance!
Brian

Ants Movement (based On Snow Movement)
Hey! I have a question for those who think they can help and might have the time to do so. 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;

//mods for ants
i = 1+Math.random()*5;
k = 1.2*(-Math.PI)+Math.random()*Math.PI;

//each ant diff
this._xscale = this._yscale=38+Math.random()*30;
this._alpha = 75+Math.random()*100;
this._y = -10+Math.random()*movieHeight;
this._x = -10+Math.random()*movieWidth;
}
onClipEvent (enterFrame) {
rad += (k/70)*Math.PI;
this._y -= Math.cos(rad);
this._x += i;
if (this._x>=movieWidth) {
this._x = -3;
}
if ((this._y>=movieHeight) || (this._y<=0)) {
this._y = -2+Math.random()*movieHeight;
this._x = -3;
}
}

(I apologize for posting the code without one of those code boxes ppl use, I do not know how to do that yet....)

Any help is greatly appreciated! I wanted to congratulate everyone here at kirupa for having a great community, and great help to those that need it. I am so glad to be a part of it.

Luke

Object Movement Based On Mouse Movement
Not sure how to word this but. I have a object on the stage lets say that is 300 pixels wide. The actual stage is only 100px wide. I want to be able to "pan" the object left and right based on mouse position/movement. I saw a tutorial for it a while back but cant seem to find it. Anyone have a link to a tut or can throw out a little source code? It would be greatly appreciated.

Ants Movement (based On Snow Movement)
Hey! I have a question for those who think they can help and might have the time to do so. 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;

//mods for ants
i = 1+Math.random()*5;
k = 1.2*(-Math.PI)+Math.random()*Math.PI;

//each ant diff
this._xscale = this._yscale=38+Math.random()*30;
this._alpha = 75+Math.random()*100;
this._y = -10+Math.random()*movieHeight;
this._x = -10+Math.random()*movieWidth;
}
onClipEvent (enterFrame) {
rad += (k/70)*Math.PI;
this._y -= Math.cos(rad);
this._x += i;
if (this._x>=movieWidth) {
this._x = -3;
}
if ((this._y>=movieHeight) || (this._y<=0)) {
this._y = -2+Math.random()*movieHeight;
this._x = -3;
}
}

(I apologize for posting the code without one of those code boxes ppl use, I do not know how to do that yet....)

Any help is greatly appreciated! I wanted to congratulate everyone here at kirupa for having a great community, and great help to those that need it. I am so glad to be a part of it.

Luke

SUPER EASY / RETARDED EASY SetMask ?
Ok got a simple retarded question. I have 1 swf loading into a holder_mc and a mask_mc set with setMask but it is not working. There is nothing else to this but so help me it is not working and I know I have to be overlooking something simple but I am just not seeing it.

Heres the whopping 3 lines of code:
code: stop();
contentHolder_mc.loadMovie("home.swf");
contentHolder_mc.setMask(contentMask_mc);


Example attached.

thx

c

Sluggish Movement With ActionScripted Movement...
I really enjoy using the following bit of code for quick little flash animations:

=======================================

onClipEvent (load) {
_root.targXscale = 50;
_root.targYscale = 200;
}
onClipEvent (enterFrame) {
cXscale = this._xscale;
cYscale = this._yscale;
difXscale = cXscale-_root.targXscale;
difYscale = cYscale-_root.targYscale;
setProperty(this, _xscale, cXscale-(difXscale/5));
setProperty(this, _yscale, cYscale-(difYscale/5));
}


=======================================

It comes straight from the tutorials ("Basic Animation via ActionScript"). Anyways, whenever I view the .swf (via IE) on my computer (2.4 Ghz / 512 MB RAM), it looks great... better than great... it looks AWESOME! But, if I check it out at work (550 Mhz, 256 MB RAM) it looks terrible. It's choppy, mouse movement is sluggish, and the entire animation looks like it's running at 1 or 2 FPS.

I know it can't be completely dependent on the computer speed, b/c I've seen other flash sites that look great on the slower PC. Even some of the non-scripted movements are sluggish on my work PC... what the?! Is there a snippet of code that would / could help?

Easy Question, Hopefully Easy Answer...
How can i create a grid of 20 movieclips? I would like to have 4 columns and 5 rows.
Its going to be used for a drag and drop game. any help would be REALLY appreciated!!

"Electron Movement" Tricky Actionscript Movement Animation
Can anybody help me with the actionscript for this one?

Objects floating from right to left on a page, when they float into static objects instead of passing behind them or in front of them or bouncing off them and going the other way, they simply move round the static objects and carry on.

Like drunks walking through a jungle of lamposts.

Something Really Easy To Answer, But Yet Not So Easy
Can anyone tell me if the ; is needed in flash MX because in flash 5 it gave me errors when i never put it in. But in MX it doesn't seem to make a difference.

Easy Question Or Not So Easy?
I am trying to save buttons and movies I have created to the main Library for use in other projects and I am having trouble figuring out how to do this. I am using flash mx. I tried going into program files and flashmx and finding the library that way. I thought I found the folder and exported a file to it and when I opened the folder it was there but when I was in flash and opened the main library flash provides for you it did not show up. Please help this newb.

thanks,

Don

Easy Easy Question
alright i have a movie clip within my movie that will display text, but the text is always different and it loads it dynamically what is the best way for each of my buttons to tell the movie clip to load and then tell the textbox to load a specific file.

_alpha / Easy In And Easy Out
I need for this code a Easy in/ onRollOver and Easy out/ onRollOut.

---

for(i=1;i<6;i++){
theButton=_root["mc"+i];

theButton.thisNum = i ;
theButton._alpha = 0;
theButton.speed = 5

theButton.onEnterFrame=function() {

if (_root["mc"+this.thisNum].overMe) {

this.elasticScale(150, 0.7, 0.3)
} else {
this.elasticScale(100, 0.7, 0.3)
}
}
theButton.onRollOver=function(){

this.speed = 5;

if (this._alpha > 100)
{
this._alpha += speed;
}
else
{
this._alpha = 100;
}


_root["mc"+this.thisNum].overMe=true;

_root["mc"+this.thisNum].swapDepths(5000)
}
theButton.onRollOut=function(){

this.speed = 5;

if (this._alpha > 100)
{
this._alpha -= speed;
}
else
{
this._alpha = 0;
}


_root["mc"+this.thisNum].overMe=false;

_root["mc"+this.thisNum].swapDepths(5000)
}
}

Movement Of One Object Dependant On The Movement Of Another Object
I am trying to get the browser to move the levers which in turn moves a constant laser beam.

The two levers control the beams position if you move the top beam it moves left to right, and the side beam controls the horizontal movement. I only want the beam and the levers to be moved to the following.

Horizontal lever between positions 10 and 2 o'clock (the levers rotate at a central point)

Vertical lever - between 2 and 4 o'clock

The laser beam to be moved anywhere in the red circle but once the lever is not being moved then the beam also stops moving.

I appreciate this is a big ask and would be grateful for any help

Please see attached.

Arc Movement Via AS?
Anyone know a way to make a MC move in an arc to a specified location no matter where it is on the stage - via AS? - I can do the straight line movement but the MC will be in a random location and need to "arc" into the new position - any ideas? Thanks AGAIN!

Movement
|-----[rectA]-------------------[rectB]-------------|B
A

can someone pls teach me how could i make 2 rectangles slide along a straight path( those ----) and when they collide they will move in the other direction. collision also occurs when rectA reached point A and rectB reaches B.



also..how can i change the speed of the movement ?

thanx alot

Movement
im trying to make something move horizontally about 20 pixels when rolled over and then go back when rolled off, how can i do this?
Thanks in advance

Movement
I made a movieclip that has actions in it to move left and right when you press the left and right keys. but i want the movieclip to not be able to move right at a certain pixel in the movie... Can any experts tell me how i could do it?

Eye Movement
Hi I am new here but not to FLash I know I good amount but I want to know how to make characters eyes move when you have your mouse over the flash anim. I see a lot of examples in it in peoples sigs. If you culd tell me, or direct me to a tutorial I would greatly apreciate it.

MC Movement?
Is it possible to move a MC with an onClipEvent?

I just do not want to use an actual button to trigger the movement.

My reason is because I do not want my cursor to change with that silly hand icon.

Any help would do,
Preston

Movement Help
(Flash MX)


i was lookin at the tutorial on how to build a starship game or somethin lie that and it shows you how to move the ship with the arrow keys. well i got that down but i want to know how to get it to stop at certain points, kinda like the constrain to rectange option on the startDrag

also im workin on another one (im just getting into games so i really dont know what im doing)with a plane as the "custom cursor" and when you click it fires and when you let go of the mouse button its supposed to stop, well it works except i have it "constrained to rectangle" and if i try to click while at the edges of the rectangle it wont fire. i've uploaded the .fla to http://www.geocities.com/unicoscc/plane2.fla
in case anyone wants to take a look
(dont forget this is my first venture into gametype stuff and i've only looked at that one tutorial and the in program help so if it looks nappy thats why)
any help is appreciated even if you tell me the movie is set up completely wrong (which i suspect it is)
thanx RegalKnight

Movement With As
I have a pair of mc´s some are part of a menu and other are just objects , i like to move those to a specific location with as , but with inertia, a soft movement.
which one is the easy way?
thanks

MC MOVEMENT VIA A/S PLEASE HELP
i figure this is pretty obvious to most of you, but i cant see it.



code:--------------------------------------------------------------------------------
line_vert.i = 1;
line_vert.endPosx = 410.5;
line_horiz.i = 1;
line_horiz.endPosy = 281;
stop();
--------------------------------------------------------------------------------
this is my action, it is controlling 2 MC's movements, and i placed this code on a keyframe, and i want to to execute. but nothing happens...it works on a button with the "on (release) {"

i figure its just some little bit that i missing.

thanks

Movement?
Hello,
I made a Flash file for graphics:
I made a grid and put a round Movie Clip.
Then I made 2 dynamic text boxes: When someone types numbers in the boxes and clicks on "Go,", the round movie clip will go to the position given...
For ex. If I type 2 in the first text box, and -3 in the second, the round Movieclip will go to the point <2;-3>.

My question: How can I, using actionScript, make "Round" MOVE to the location, instead of simply going there in a Flash?

Thanks a lot

Mc Movement Help
I have this script attached to a movie clip:

onClipEvent(enterFrame) {
_x = _root._xmouse;
_y = _root._ymouse;
}

so that the clip is basically attached to the mouse. this is okay, but i'd prefer if the clip gradually drifted towards the mouse, wherever it is on the stage. is there a loop i can put into this script that will continually move the movie clip towards the _xmouse and y_mouse coordinates? i can't figure out how to do it. anybody know how?

thanks!
Clint

Movement
Hi,

I'm trying to get a movie clip to move following pre selected coordinates.

I currently am selecting coordinates on buttons, i.e each click of the right button increases the X coordinate by 50 etc.

Once my array is filled, does anyone know how I can get my movie clip to move to each coordinate in turn?

Any ideas are welcome.

X Y Movement
I have a menu system like a grid 5 blocks high and 4 blocks wide. The blocks of the grid are used as a mask, to display jpg's loaded bleow which move according to which button is pressed. At the moment the jpg's move x,y & diagonally. What Im trying to do is make the jpg's move ONLY on an x,y axis can anyone suggest a good method? Below is the method I am using atm...

function buttonPress() {
_root.backImage.dx = _root.Items[this.index].dx;
_root.backImage.dy = _root.Items[this.index].dy;
}
function buttonOver() {
}
function backMotion() {
this._x = this._x+(((-this.dx)-this._x)/2);
this._y = this._y+(((-this.dy)-this._y)/2);

Thanks.

_y Movement
can anyone help me in my quest in moving and object in a random postion (smoothly) along the y axis within the confindes of the stage?

basically, i want my object to move smoothly up and down in a random way and at a constant speed

any ideas would be most helpfull.

thanx alot,
Sam

8 Way Movement?
I'm new to flash acionscripting and I'm having problems with the following code. I've got a movement system in the making, and I'm trying to have 8 way movement, I've succesfully managed 4 way, (left, right, up, down) but I'm having very big problems having the diagonal movement. I've tried the following code, it doesn't return any debug errors, however, the character only moves right under all circumstances. Can anbody see what I'm doing wrong? Any suggestions?


CodenClipEvent(keyDown) {
var movemnt;
var goleft;
var goright;
var godown;
var goup;

goup = false;
godown = false;
goright = false;
goleft = false;

if (Key.isDown(Key.UP)) {
goup = true;
}
if (Key.isDown(Key.DOWN)) {
godown = true;
}
if (Key.isDown(Key.LEFT)) {
goleft = true;
}
if (Key.isDown(Key.RIGHT)) {
goright = true;
} else {
movemnt = null;
goup = false;
godown = false;
goright = false;
goleft = false;
}

if (goup = true) {
movemnt = "up";
if (goleft = true) {
movemnt = "upleft";
}
if (goright = true) {
movemnt = "upright";
}
}
if (godown = true) {
movemnt = "down";
if (goleft = true) {
movemnt = "downleft";
}
if (goright = true) {
movemnt = "downright";
}
}
if (goleft = true) {
movemnt = "left";
}
if (goright = true) {
movemnt = "right";
}

_parent.walk(movemnt);
updateAfterEvent();
}

Movement Help
I am trying to make a little game, and i need to make a movie clip have the same x axis as the mouse postion, please help.
thanks in advance

Movement Help
I am trying to make a little game, and i need to make a movie clip have the same x axis as the mouse postion, please help.
thanks in advance

Movement
Can you but a wait function so if you have a car that can't move at the begining of a race?

Movement
Hi, ok ive got these randomly drawn shapes at the top and bottom of the screen. This is the code to move draw them and move the top ones..
code: //Vars
xspeed=-0;
acceleration=.001;

//Function to draw the triangle
function myDraw(n, x, y)
{
var temp_mc = this.createEmptyMovieClip("shape" + n*2, n*2);
trace(temp_mc);

temp_mc._x = x;
temp_mc._y = y;
temp_mc.lineStyle(1, 0x000000, 100);//Line colour and Alpha
temp_mc.beginFill(0x000000, 100);//Fill colour and Alpha
temp_mc.moveTo(400, 0);//Start shape at X Y
temp_mc.lineTo(random(250)+5, random(60)+60);//Draw a line at random
temp_mc.lineTo(0, 0);//Draw a line
temp_mc.endFill();//End the shape
}
myDraw(n*2, 100, 0);

//Repeat myDraw function
for(var i=2*n; i < 100; i++)//1000 Times
{
myDraw(i, i*250, 0);//adding 250 to X
}

//Move them
this.onEnterFrame = function() {
for (i=n*2; i<=100; i++) {
this["shape"+i]._x += xspeed;
xspeed-=acceleration;
}
};

function myDraw2(n, x, y) {

var temp_mc2 = this.createEmptyMovieClip("shape2"+n*2+1, n*2+1);
trace(temp_mc2);

temp_mc2._x = x;
temp_mc2._y = y;
temp_mc2.lineStyle(1, 0x000000, 100);//Line colour and Alpha
temp_mc2.beginFill(0x000000, 100);//Fill colour and Alpha
temp_mc2.moveTo(400, stage.height);//Start shape at X Y
temp_mc2.lineTo(random(250)+5, stage.height-random(60)-70);//Draw a line at random
temp_mc2.lineTo(0, stage.height);//Draw a line at random
temp_mc2.endFill();//End the shape
}
myDraw2(2*n+1, 101, 0);
//Repeat myDraw2 function
for(var i=0; i < 100; i++)//100 Times
{
myDraw2(i, i*250, 0);//adding 250 to X
}
And its all working good up to now, then i add this to move the bottom ones...
code: //Move them
this.onEnterFrame = function() {
for (i=n*2+1; i<=100; i++) {
this["shape2"+i]._x += xspeed;
xspeed-=acceleration;
}
};
and when i add it, it moves the bottom ones (apart from the first one) and stops the top ones from moving, any one have any ideas what im doing wrong?? thanks

Movement
Hi,

I have a box in Flash and 5 buttons. What I need is a code that can
tell the movie to resize or repostion the box when clicking on a button.

What to do?

-Sweetz

Movement
oookay, i want to make stuff fly in together, like assemble from 0% alpha, and from various spots on the stage...but

#1, i dont like motion tweens, because they just annoy me, and
#2, i want it to be smooth when the graphics come to a stop... like i want each object to gradually descelerate until they come to a stop, and i have tried doing it in a motion tween, but its reeeally hard to get it right

...how can i do this in actionscript?(also using alpha from 0% to 100% )

thanks if anyone can help

sorry, im kinda rambling, but im tired, lol ^_^

_x And _y Movement
I am following along in this tutorial, and am understanding it pretty good, but some of the code, I don't understand why it is used and what it does. Could someone help me?

//rad (short for radians)
rad = 0

I don't really understand what a radian is.
and I really don't understand this line a whole lot.

onClipEvent (load) {
k = -Math.PI+Math.random()*Math.PI;
};

onClipEvent (enterframe) {
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);

What is the Math.cos doing?
I will post the full code underneath // just in case nobody understands.

code:

onClipEvent (load) {
//variables
width = 300;
height = 200;
//random x,y, and alpha
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 20+Math.random()*50;
//random x and y for flakes
this._x = -width+Math.random()*(3*width);
this._y = -10+Math.random()*height;
//speed and trigonometric value
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
rad = 0;
}
onClipEvent (enterFrame) {
// horizontal movement
rad += (k/180)*Math.PI;
xmovement = _root._xmouse;
this._x -= Math.cos(rad)+(xmovement-(width/2))/50;
// vertical movement
this._y += i;
// remove clips when they misbehave (overstep boundaries)
if (this._x>(width+50)) {
this._x = -45;
this._y = Math.random()*height*2;
}
if (this._x<-50) {
this._x = width+45;
this._y = Math.random()*height*2;
}
if (this._y>=height) {
this._y = -50;
this._x = -width+Math.random()*(3*width);
}
}

Movement - Please Help
Hi,
I'm trying to make an animation for bubbles rising upwards (a soda carbonation effect). I found this actionscript at Kirupa (see below) for falling snow. I changed {this._y += i;} to { this._y -= i;} and it plays upward once than stops.


What do I need to do in order for it to continuously play upward?


Code:
onClipEvent (load) {
//specifies the size of the movie stage
movieWidth = 300;
movieHeight = 200;

//variables that will modify the falling snow
i = 1+Math.random()*6;
k = -Math.PI+Math.random()*Math.PI;

//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*180;
this._alpha = 75+Math.random()*100;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/0)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
}
if ((this._x>=movieWidth) || (this._x<=0)) {
this._x = -10+Math.random()*movieWidth;
this._y = -5;
}
}{


Thanks for the help!

Movement
hi,

is there a script that i can put on an animation that does this:

an object going from point a to point b. the closer the object gets to point b it slows down more and more.

i see this effect everywhere and i think it's great.

any help is appreciated

thanks

MC Movement
I'm trying to get the laser to shot in the last direction of movement.
I've been working on this for a while now and this is what I got.

code:
onEnterFrame = heroPlacement();
hero.onEnterFrame = movement;
onEnterFrame = laserPlacement();
function heroPlacement() {
attachMovie("hero", "hero", 10);
hero._x = 270.5;
hero._y = 120.5;
speed = 5;
Key.addListener(watchKeyBoard);
}
function laserPlacement() {
attachMovie("laser", "laser", 20);
laserSpeed = 10;
}
laser.onEnterFrame = function() {
laser._x = _root.hero._x+30;
laser._y = _root.hero._y+30;
}
function movement() {
if (Key.isDown(Key.DOWN)) {
_root.hero._y += speed;
dir = down;
} else {
if (Key.isDown(Key.UP)) {
_root.hero._y -= speed;
dir = up;
}
}
if (Key.isDown(Key.RIGHT)) {
_root.hero._x += speed;
dir = right;
} else {
if (Key.isDown(Key.LEFT)) {
_root.hero._x -= speed;
dir = left;
}
}
if (Key.isDown(Key.CONTROL)) {
if (dir == "up") {
_root.laser._y -= laserSpeed;
} else {
if (dir == "down") {
_root.laser._y += laserSpeed;
}
}
if (dir == "left") {
_root.laser._x -= laserSpeed;
}
} else {
if (dir == "right") {
_root.laser._x += laserSpeed;
}
}
}

Everything works, but the laser doesn't shoot. I know it's gotta be something simple that I'm missing but, I'm so burned out on working on this I just don't see it. If anyone has any suggestions, I'd appreciate it.

AS Movement
I have a movieclip which I am using duplicate movie clip to get multiple copies of the mc. What I need now is a way to make all the mcs move the same way. I think it is some sort of prototype function but I have not used them before and dont know where to start. If someone knows of a prototype help file or better yet an exact answer to how to move multiple copies of one mc the same way, please post here.

Thanks

Movement
I have seen viedos where the movement on the body of a person or animal such as hands and legs, look like there were done using symbols for each body part. Is that true? How do you make it like that, and so the hands, and fingers move as well?

Movement<><>
ok i am trying to get a movie clip to move, go the code it works right, but i want the clip to change frames when the button is pressed and released i need to change frame when released and also is there a way to change frames if both keys are present like if i want the clip to move diagonal and change frames?

I got this so far

code:
onClipEvent(load){

moveSpeed=10;

}
onClipEvent (enterFrame) {

if (Key.isDown(Key.RIGHT)) {
this._x+=moveSpeed;
this.gotoAndStop(13)
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
this.gotoAndStop(12)
}

if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
this.gotoAndStop(6)
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
this.gotoAndStop(9)
}
}


see i have several different movie clips in another so when the key is pressed it changes to the frame with the current action,
example:
if the up key is pressed it goes to the frame where the walking up animation is,

if this isnt clear enough just say and ill try to type it better.....
anyways can anyone help me?

W A S D Movement?
im trying to figure out how to make a MC move using the wasd keys instead of the right left up and down keys. i tried replacing the up with w and down with s and left and right with ad in the code but it dont work. can some one help me?

Non-Movement
OK, I've got my basic movement script set up for a character, with it detecting whether or not it's trying to go outside the boundaries and stops it doing that.


Code:
onClipEvent (load) {
moveSpeed = 16;
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT)) {
this._x += moveSpeed;
} else if (Key.isDown (Key.UP)) {
this._y -= moveSpeed;
} else if (Key.isDown (Key.DOWN)) {
this._y += moveSpeed;
} else if (Key.isDown (Key.LEFT)) {
this._x -= moveSpeed;
}
if (this._x < 0) {
this._x = 0;
}
else if (this._y < 0) {
this._y = 0;
}
else if (this._x > 352) {
this._x = 352;
}
else if (this._y > 352) {
this._y = 352;
}
}


Now, how do I code for an item which can't be passed, such as a rock? I know I could do this:


Code:
if (this._x = 32 && this._y = 64) {//don't move left}


But that seems like a long way around. Any help?

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