Moving Objects?
I'm simulating a plane moving and when you hold down an arrow key it will move faster. I'm looking for a little better way to do it because it seems to get exponentially faster the way I'm doing it but I can't think of a better way of doing it.
Frame 1:
Code: var speed = 1; var count = 0;
Frame 2:
Code: var myListener:Button = new Button(); var mySoundWave:MovieClip = new MovieClip();
if(plane._x>800)//Keep plane on screen plane._x=0; if(speed>40) trace("SPEED OF SOUND");
plane._x+=speed; plane._y+=plane._rotation/5;
count+=1; if(count%4==0)//Don't display a soundwave everytime { showMovie("soundWave",plane._x,plane._y); }
function showMovie(linkageId, xpos, ypos) { var linkageId :String; var xpos:Number; var ypos:Number; mySoundWave = this.createEmptyMovieClip("mySoundWave", this.getNextHighestDepth()); mySoundWave._x = xpos; mySoundWave._y = ypos; mySoundWave.attachMovie(linkageId,e,this.getNextHighestDepth()); }
myListener.onKeyDown = function() //This is the relevant code for moving { if (Key.getCode() == Key.LEFT) { speed -= .001; } else if (Key.getCode() == Key.RIGHT) { speed += .001; } if (Key.getCode() == Key.UP) { plane._rotation -= .001; } else if (Key.getCode() == Key.DOWN) { plane._rotation += .001; }
};
Key.addListener(myListener);
Frame 3:
Code: gotoAndPlay(2);
I made everything really small because I didn't want it to get out of control.
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-18-2008, 05:27 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving Objects: Moving Keyframes?
Can I move multiple layers on a timeline, so that they will all move. Basically I just want to move the location of the multiple layers.
Whenever I do this, it seems to move only some of them and thus the whole animation is messed, different starting points and ending points...a big mess.. It makes me want to cry.
Seems like there is an easy answer or I might just be the biggest chump on the planet.
Case
Moving Objects: Moving Keyframes?
Can I move multiple layers on a timeline, so that they will all move. Basically I just want to move the location of the multiple layers.
Whenever I do this, it seems to move only some of them and thus the whole animation is messed, different starting points and ending points...a big mess.. It makes me want to cry.
Seems like there is an easy answer or I might just be the biggest chump on the planet.
Case
Moving The Stage After Resizing - Or Moving All Objects On The Stage? Heeeelp
Hello! I'm in dire need of help!
I've been forced to resize the stage of my movie but as the stage is expanded to the right and down everything ends up in the wrong place. So I wonder:
Is there any way to move the stage rather than the contents thereon?
or
is there a way to move all the content on all layers and even all scenes simultaneously?
or
is there a way to expand the stage equeally on all sides rather than just right and down?
THANKS ALOT TO WHOEVER COULD HELP ME!
Freddy D, Stockholm, Sweden
Moving Objects
Hi, i'm making an anamtion that scrolls pictures by left and right when you put your mouse over the "<" and ">" buttons. I have that part working fine but my problem lies here... i have this code in a separate movie so that the movie will loop and run the code over and over again will the mouse is still over the button.
//this is for the left button and it moves the picture to
//the left 10 (there's also one for pic2-pic5. this code
//works fine
tellTarget ("/pic1") {
setProperty ("/pic1", _x, _x -= 10);
}
//if the picture got beyond a certain _x val i wanted to
//move it to the other side so i used this code.
if (pic1_x <= -1240) {
tellTarget ("/pic1") {
setProperty ("/pic1", _x, "1240");
}
}
now this code, well, kinda works. it sees that the picture is beyond -1240 and it moves it self to 1240. But for some reason it doesn't start moving to the left again. In fat i tried a += 50 where the "1240" is and it kept moving to the right 50 so it's running that if statement even though it's no longer <= -1240. is there something wrong with my if statement?
Moving Several Objects As One
I'm creating a list of items using the duplicateClip function.
Each item is placed clip._height below the previous one.
It just so happens that the list may be too long to fit on the screen, so I have to give the effect of moving the group.
Can I create this list of items as if they were one? Then, all I would have to do is move this one item.
Better yet, because I'm sure that this question or one like it has been asked several hundred times, what should I search for when looking for tutorials or previous posts on the subject? Does this concept have a name?
Thank you
Whe Are Objects Moving?
heeelp....my objects are moving
e.g. i want my objects to be on whole pixels, so x=15 and y=15 however as soon as i press enter it moves back to 15.3 and 15.7 or something like that. i unchecked 'snap to grid' 'snap to guide' however that doesnt seem to be the problem.
any ideas?
thx!
Moving Objects
I know this might be silly, but.. I cant quite figure out the way to make objects moveable on a flash screen. You know, the eggplant way?...
Moving Objects?
How do I get a object to move along the x axis when the user presses the left and right cursors.
And how do I stop the object from goin off of the side of the scene?
thanx alot
cya
Andrew
Containing Moving Objects
hey
i've got a bit of a problem i've created a function that tells eight objects to randomly choose between eight possible directions and move in that direction. this works perfectly. the problem is i want to contain this motion within a set square for example if it hits the border of the square diagonaly iwant it to bounce off in the opposite direction. does anyone know of any tutorials showing how i can create these parameters.
Moving Objects
Hi, I'm trying to make an animation in which a square (line, or any other shape) moves from one point to another (like moving from top to bottom). I was wondering if there's a way to do it different than making many frames and just change the possition of the object in each frame 'til it gets to the final possition. If there's an easier way to do it or if there's some sort of software that may help to do this, PLEEEEASE let me know.
Thanks a lot.
G.
Moving Objects....
Is it possible to move objects in micro movements? I know I can move objects in larger spaces holding shift down. But can I move in smaller increments by holding something else down..
Moving Objects
I created a map movie, and decided late in the game that I was going to load the map movie into my interface with a load movie function. Originally, the movie was created with the map in it.
Anyways, how can you move all of your animated parts, frames, ect. While keeping everthing intact. Basically I need to move all my files and resize my movie.
Is there an easy way to do this? Like a select everthing? I tried selecting all the layers but it always seems to miss some parts.
-eric
Moving Objects
Ultra newb question here, but how do you move an object around on a layer similar to the way you do with the move object tool in PS?
Moving Two Objects At Once
I have to images one of a sun and the other is a flower.I have it so that i can drag the sun from one spot to another but what im trying to do is have it so that the flower image will flip or move so that it is following the sun as it moves.
Any help would be great.Thanks.
Moving Objects
Me & some friends are making a game. You are in a sliegh & have to dodge objects. But i can't make the objects move. This is the code i am using:
ActionScript Code:
// Random Tree Postion
var xpos = 0;
var numObjects = 15; // Edit to Change how many trees - number of snowballs
for (i=0; i<numObjects; i++) {
var randomObject = attachMovie('tree', 'tree'+i, i);
if (i<=numObjects) { // DEV: No Overlapping
randomObject._x = xpos-240;
xpos += 44;
}
randomObject._y = random(500);
}
// Random Snowball Postion
var numObjects1 = 6; // Edit for how many snowballs.
for (s=0; s<numObjects1; s++) {
var randomObject = attachMovie('snowball', 'snowball'+s, s);
if (s<=numObjects) { // No Overlapping
randomObject._x = xpos-640;
xpos += 66;
}
randomObject._y = random(500) + 700; // create snowball behind.
// DEV: Move snowballs
randomObject._y -= 3;
}
Moving Objects
Hello guys, my first post here
Here i am helping out a friend with a website. I'm Designing a website completely made of flash (customer request :/ ). There is a part at the bottom of the screen thats like a tab. I want to move the whole tab (and a wider box attached to it too) a little up everytime the mouse rolls over it.
Looking at various tutorials I've found one that seems to suit me. It basicly moves the movie clip (the whole thing at the bottom the tab + the bottom box is converted to a movie clip for this) in incriments. It needs a yTarget{instancedname} variable. For example if i give the movie clip an instance name of MC the variable would be yTargetMC and the number i associte it with is where the movie clip moves to.
So i can make a button that has :
on (rollOver) {
yTargetMC = 50;
}
on (rollOut) {
yTargetMC = 100;
}
It works as long as the movie clip and button are on the same "stage". I want the movie clip to move up on mouse over so i palce the button inside the movie clip but when i do this the yTargetMC is useless coz it wont change the variable in the main stage (i'm assuming this)thus wont work. Is there a way that i can make the button inside the movie clip assign the variable change to the main scene? Maybe a script code that makes the button work like it was NOT inside the movie?
I'm kinda lost here and i hope i managed to explain this properly. Any help would be welcome - i'm ok with rebuilding this too if there is a more easier and logical way too. As i said i'm learning and helping at the same time so hence i'm a newbie yet again
Thanks in advance,
Osman
Edit : here's the code for the movie itself (that is moved)
onClipEvent (enterFrame) {
yMC = getProperty(_root.MC, _y);
moveMC = _root.yTargetMC - yMC;
setProperty(_root.MC, _y, yMC + (moveMC/10));
}
Moving All Objects
This is a stupid question, I know but I neet help urgently. How can I move all elements in a time line? I have 50 key frames If I select all and move them with the mouse only the frame with the marker on it is moved.
What am I doing wrong
Tanks in advance
Moving Objects
Hi guys,
I have created a break apart effect for my headings.. I have around 6 headings. I made it using a different program (as it was automated). It has made the effect for each heading by moving the letters slightly on each key frame. When I import the swf file into my movie in flash 5, it puts it in the top left corner. The only way to move it to the right for example is frame at a time, and as you can imagine.. with 30 frames per heading and 6 headings, im not doing it that way!! :)
Is there any way I can 'move' the position of a block of frames??
Sorry if its a simple question.
Wazz
Moving Objects
i want to move a movie clip's x and y in my movie in the same way that the movie in the fla download's section called 'SlideMenu' does. but it only does x positions. ne ideas?
Moving Objects
I AM NEW TO FLASH AND I WANT TO LEARN HOW TO CREATE THE MOVING CLOUDS EFFECT THAT I SEE ON SOME SITES. Thanks for the help
Moving Objects
Does anyone know a tutorial that explain how to script the "button system" on this site: link ? Seen it many places, quite handy and stylish
Moving Objects With Actionscript
On the main stage, I have 2 identical objects (1 symbol X 2), both moving along the X-axis. One is moving from the left toward the center; one is moving from the right towards the center. I would like actionscript that will allow me to have these objects move each from a specified point to a specified point (not user-specified, but predetermined) in the same specified number of frames.
Can anyone help? I am totally new to actionscript, so please explain thoroughly.
Thankyou,
S. Reebar
MOVING OBJECTS With Actionscript
On the main stage, I have 2 identical objects (1 symbol X 2), both moving along the X-axis. One is moving from the left toward the center; one is moving from the right towards the center. I would like actionscript that will allow me to have these objects move each from a specified point to a specified point (not user-specified, but predetermined) in the same specified number of frames.
Can anyone help? I am totally new to actionscript, so please explain thoroughly.
Thankyou,
S. Reebar
Moving Objects On The Stage Help
Hello,
What I am trying to do is;
Assume there are 5 playing cards on the stage spread out evenly across the stage, and what I want to do is, when you move the mouse of each card (should I make them a button or movie instance?), the card will move to center of stage and go from about 20% of its size to 100% by the time it is in center screen. But this will have text on it, so at 20% you can't read it until it gets to center and is at 100%. Is this actionscript? I am not familiar with that other than gotoAndStop and so forth.
Ok, yes I am new to Flash MX, but I am learning more everyday from all of you, so can anyone please help me?
Thank you
Thorrax
Moving Objects By Using Actionscript
hi ppl,
i m having this problem of not being able to move an object created in flash according to coordinates. i m basically working on a projectile path displayer using flash 5. when i give co - ordinates to individual keyframes they are jumping to each position in the flash player & no tweening is visible. I NEED HELP FAST!!! as my project guide is v. angry with me.
help me out guys...
Sidz-the zapperbug
my e-mail is zapperbug@rediffmail.com
Problem Moving Objects
hi,
ok, I'm new to this, so it's a simple question....
I made a small text animation (10 letters) each letter is blending in after an other:
(alpha 0% ---> 100%)
(alpha 0% ---> 100%)
(alpha 0% ---> 100%)
fine !
but now I have to move the hole word a bit to the top (it's not part of an animation, just a simple alignment!!).
If I try to do this, (I select all letters) and move it up a bit, this move is now a part of the animation :-((
What am I doing wrong ????
thanks for your needfull help !!!!!!
greets otix
Moving Objects Within A Projector
hello all. I'm newish to this game. I can create projects happily in flash 5....but I am stuck on one thing at the moment. I want the user to be able to grab an object from a position within the projector and relocate it wherever he wants within the projector. I know this is going to be some simple comand or creation of a certain type of graphic but i am a spanner...please help me.........
thanks
Andy
Moving Objects With Actionscript
hi everyone
i have a movie on the main timeline that contains an object1 with a long motion tween.
i have a 2nd movie on the main timeline that contains a movie with the controll pannell for this object1.
i would like that when you push the ff button, the object1 skips two frames so it looks like it's going in fast forward on it's motion tween. same, i would like to push the rw button and have it go back two frames in the motion tween to look like it's going backwards in rewind.
here's my code on the ff button contained within an on press:
_root.PIXI.gotoAndPlay(_currentframe + 2);
but its not working. it brings object1 back to it's first position always.
what am i doing wrong?
best wishes,
slimpixi
Moving Objects Along A Line?
i've been using motion tweens to animate my movies and i'd like to reduce the size by using actionscripting to achieve the same effects. can anyone suggest any tutorials that will take me through the basics of using actionscripting to move objects along a line?
here's my current website and the first 20 frames are nothing but motion tweens. any suggestions on how to reduce the load up time??
http://web.mit.edu/jbradd/www
Moving Objects With ActionScript
Hey,
I think this should be possible, but I have no clue how to do it. I am using regular Flash MX by the way. Here's what I'm trying to accomplish:
When you click a menu button, it will tell a movie clip to shink and then move off of the screen with an alpha transition. Once the clip is off the screen, I want to execute a simple gotoAndPlay .... but I don't want the gotoAndPlay to execute UNTIL the movie clip is off the screen. Is this even possible? Hope this makes sense. Thanks for your time.
Randomly Moving Objects
I need assistance with this, since I can't find it in the forums. I want to have at most 10 circular-objects moving randomly around the page. Also if it's possible to have some of them appear and disappear after time. Can this be done?
thanks!
Dynamically Moving Objects
I have two movie clips that I want to control with a button. They need to change: size, position and move on a semi-circular path. I would love to do this with actionscript, instead of using a motion path, but I want the movement to be fluid. Any ideas? (see attached diagram)
Moving Objects To Certain X,y Points
I have a main menu box that contains navigation buttons.
This box can be dragged anywhere on the screen. If i want
a button to move that box to a certain x and y point, no matter
where it is at anytime, how can i script this?
Randomly Moving Objects
Does anyone know a script that can randomly move objects on a rollover then revert back after rolled out? I plan to use this as a menu, so when someone rolls over text, the letters will move seperately, but different every single time. I will post my FLA if needed to show what I want.
Thanks in advance,
James
Moving Objects In ActionScript...
I was wondering if there is syntax in Actionscript where you can smoothly move an object from point "A" to point "B", just like a tween... Here is some fictitious code to help explain my question:
code: tweenTo (Initial X, Initial Y, Destination X, Destination Y)
That code obviously won't work, so I am looking for the correct syntax. If you can help me that would be great. Thanks alot!
-Layz
Moving Other Objects When The Mouse Is Over One
i'm using flash MX
basically what i want is i have 7 objects in a row. when you put the mouse over one object, i want the other 6 to move downward. when you remove the mouse from that object, i want the other 6 to move back up into place.
any help would be much appreciated.
Function For Moving Objects
I have an array of objects whic have start and end positions defined like this.
PHP Code:
for(var i=0; i<arrusr.length; i++){
_root["cccc" + arrusr[i]] = game.clip["char" + arrusr[i]]
_root["cccc" + arrusr[i]].xtile = _root["cccc" + arrusr[i]].trgtx
_root["cccc" + arrusr[i]].ytile = _root["cccc" + arrusr[i]].trgty
_root["cccc" + arrusr[i]].x = _root["cccc" + arrusr[i]].xtile*game.tileW;
_root["cccc" + arrusr[i]].y = _root["cccc" + arrusr[i]].ytile*game.tileW;
_root["cccc" + arrusr[i]].xiso = _root["cccc" + arrusr[i]].x - _root["cccc" + arrusr[i]].y;
_root["cccc" + arrusr[i]].yiso = (_root["cccc" + arrusr[i]].x + _root["cccc" + arrusr[i]].y)/2;
_root["cccc" + arrusr[i]].speed = 5;
_root["cccc" + arrusr[i]].trgtx = p.data["x"+arrusr[i]]
_root["cccc" + arrusr[i]].trgty = p.data["y"+arrusr[i]]
_root["cccc" + arrusr[i]].moving=true
llll = _root["cccc" + arrusr[i]]
llll.speed = 5
...
I have a move function from Tonyas tuturials
PHP Code:
function moveChar1(llll) {
.
.
.
llll.y += llll.speed*llll.diry;
llll.x += llll.speed*llll.dirx;
llll.xtile = Math.floor(llll.x/game.tileW);
llll.ytile = Math.floor(llll.y/game.tileH);
// calculate position in isometric view
llll.xiso = llll.x-llll.y;
llll.yiso = (llll.x+llll.y)/2;
// update char position
llll._x = llll.xiso;
llll._y = llll.yiso;
// calculate depth
llll.depthshift = (game.tileW-16)/2;
llll.depth = (llll.yiso-llll.depthshift)*300+(llll.xiso)+1;
llll.swapDepths(llll.depth);
// face the direction
llll.gotoAndStop(llll.dirx+llll.diry*2+3);
i call the function with this:
PHP Code:
for(var i=0; i<arrusr.length; i++){
moveChar1(_root["cccc" + arrusr[i]]);
}
if i dont heve this two it doesn work.
PHP Code:
llll = _root["cccc" + arrusr[i]]
llll.speed = 5
And whent the objects move one object from the array interferes with movement of others. So if I move two objects, the first is halted by the second.
Please help!
Thank you!
Moving Objects Using Actionscript
Hi,
I am new to actionscripting.
How do I move objects from different positions to a fixed position. for e.g: You have object A (x,y) and object B (a,b) at different positions x,y and a,b. Using actionscript they should move to Object C (r,s) which has a fixed position on the stage.
Appreciate if you could help me!
Moving Objects In Flash
I tried moving this the complete object in flash and this only partial objects moved.
http://www.lesfemmesmodels.com/page1i.html
Can someone help out.
Thx in advance
Sanjiv
Z-CHANGE, Moving On Top Of Other Objects ////
Hey people. I'm having a few buttons on one frame. I want it so when one of them rolls over, it goes on top of the others. How can I do that? Is there a command or something? If not, what way would you suggest? Thank you.
Actionscript Moving Objects
I simply want to move a object to one point, stop then to another point stop then to another point and so on.
I can move an object to one point no problem but if i put more code after it, it uses that piece of code instead.
I have tried various methods to move the object but still cant get it to work.
any help would be apprieciated
Thanks
[F8] Lots Of Objects, Moving
whats the least proccessor intensive way to handle several movieclips(100+) that need to be constantly moving and responding to user input?
onEnterFrame? setInterval? somebetter method?
Moving Different Objects To One Location
Howdy, i have the following problem
First Object: x100 y100
Second Object: x400 y400
Thrid Object: x200 y200
when a counter reaches a certain number they all have to move to
x300 y300
how can i do this via AS??
any help
thanx in advance
[F8] Moving Objects In Movieclips
I have a movieclip that has two objects on. Say when it moves to frame 10, BOTH objects move forward. Then, in frame 20, I ONLY want one of the objects to move upwards. But for some reason, both of the objects move upwards. I tried to just edit one of the objects on the keyframe but it didnt work.
any ideas? Been trying it out for ages!
[F8] Moving Objects - Function, _x, _y
Hi
I try to create a banner with some rotating objects and some bars, moving in a certain area. The rotating objects are no problem for now, but I have no idea what I'm doing wrong with the bars. The bars should move smooth and slowly. The speed of the bars and the length of the paths should be different each time(random). My problems are, that the bars only move in one direction, their movement is not smooth enough, at a certain point the bars stop and after changing some things they now don't move at all
Maybe you can help my a bit? Thank you very much for reading this =)
Here is the code I wrote for now...
Code:
var a, richtung_x, richtung_y, schritt_x, schritt_y;
function zahl() {
a = random(79)+20;
}
function bewegung() {
zahl(); //how far should the object move alltogether?
richtung_x = random(2); //should the object go to left or to the right?
richtung_y = random(2); //should the object go up or down?
schritt_x = (random(100)+1)*0.000001; //how big should one step on the x-axis be?
schritt_y = (random(40)+1)*0.000001; //how big should one step on the y-axis be?
for (var i = 0; i<a; i++) {
//horizontal
if (richtung_x == 1) {
this._x -= schritt_x;
} else {
this._x += schritt_x;
}
//vertikal
if (richtung_y == 1) {
this._y -= schritt_y;
} else {
this._y += schritt_y;
}
}//end of for-loop
};
//following should assign the function to the movie clips
balken1.onEnterFrame = bewegung();
balken2.onEnterFrame = bewegung();
balken3.onEnterFrame = bewegung();
balken4.onEnterFrame = bewegung();
balken5.onEnterFrame = bewegung();
[F8] Moving Objects Around A Shape.
Please can somebody poin out the obviouse to me and tell me how to make an object follow a circular path.
i have a box in layer one, do i need to add a motion guide or layer guide and how do i get the box to rotate around the circle...
Any help appreciated.
Thanks
JaM
Moving Objects Smoothly.....Please Help
I have a movie that I want to have movieclips floating around the stage. I want them to randomly move around and move smoothly. I'm new to ActionScript and am building this site for my husband. I'm not sure where to start, but did read something about the Brownian motion.
I've added:
Code:
buttonMC.onEnterFrame = function() {
var maxMoveValue=50;
this._x += (Math.random()-0.5)*maxMoveValue;
this._y +=(Math.random()-0.5)*maxMoveValue;
};
to the frame, but then it just jiggles (albeit randomly) it about the stage and eventually moves off of the stage conpletely. What I'm working on is http://www.lucyohara.talktalk.net/menu.swf
Thanks for your help.
Moving Random Placed Objects
I have a star movieclip that i want to lets say place 10 of them on the screen at random positions. I then want them to be animated from left to right on the screen.
How would one go about doing this?
Also how would i make it so that when it gets to the end of the right side of the stage it starts at the left side of the stage again and doing this continuously?
|