actionscript help please? (2.0)

16 posts

Flag Post

how do I keep the position from resetting from move-clip to movie clip (pressing the RIGHT arrow trigers a clip the rocket fireing rightward as well as, formerly, the vehicle moveing right)

 
Flag Post

Hey punking. It’s hard to ascertain exactly what you mean here. Give me a little more information and I’ll try to help you out. Are you saying that the right arrow makes a rocket fire AND makes the vehicle firing the rocket move to the right? And what position are you trying to keep from resetting? And what exactly do you mean by resetting? Is the movieclip appearing in the top left corner of your screen? Is it doing something else?

 
Flag Post

basicaly I’m super new at this, so I found some code that lets you move a clip around the screen and bounce it off the edges

anyway, I messed with the code so that pressing the arrow key also moves it to fram 2 where it is a picture of a rocket aplying thrust to the vehicle, when it swiches back to frame 1 the position that the vehicle was in wasn’t stored so it starts again from the center of the stage

(also I ’d really like to know how to make the frame two clip play from a position matching that of the vehicle clip)

 
Flag Post

better wording of the center portian

pressing the arrow key also moves the movie to frame 2 where it is a picture of a rocket aplying thrust to the vehicle, when it swiches back to frame 1 (on keyUp)the position that the vehicle was in wasn’t stored (I don’t know how to) so it starts again from the center of the stage

 
Flag Post

So are you moving to frame 2 of the main timeline? If so, it may be easier to have the second frame of the vehicle have the rocket thruster animation. This way, you never leave the first frame of the main timeline.

 
Flag Post

I’m sorry if I’m really sounding like an idiot now, but what’s a main timeline?

 
Flag Post

punking, you’re not sounding like an idiot at all. What I mean is when you open flash, the timeline that you see is your main timeline. Now if you double click a movieclip you will see that clip’s timeline. So, I’m guessing that you have a movie clip on frame one of your main timeline and another movie clip on the second frame of your main timeline. What you might try doing is, instead, double click your vehicle movieclip and click the second frame and put the vehicle with your animation on that frame. Just be sure to put stop(); in the actions of both frames. Then back on your main timeline put into the code that controls the right arrow key press to do something like vehicle_movieclip.gotoAndStop(2); and then when the arrow key is not pressed vehicle_movieclip.gotoAndStop(1);

Let me know if this makes sense to you or not.

 
Flag Post

I’m sorry if I’m really sounding like an idiot now, but what’s a main timeline?


Its ok punking, even professional devs like myself were once newcomers like you :)

Feel free to ask away, thats exactly what this forum is for.

 
Flag Post

yeah it all makes sense

it’s not working though,
(it moves around without changeing image) it might be that I’m not naming things right.

on the secondary timeline I selected everything and it’s instance of ball and underneith the symbol type chooseing thing it says “ball”

on the main timeline it says instance of rock and underneith the symbol type chooseing thing it says “ball”

oh, and thank you for being so helping

 
Flag Post

Hmm, It is hard to tell if something is going wrong, or if I’m just not explaining myself clearly enough. Lets try this. You have two movieclips, correct? A vehicle and a vehicle with a rocket animation. OK, take both and paste them in the first frame so that they are side by side. Call the one without the rocket animation “ball” (since that was what you were doing) and remove the instance name from the other clip. So now, when you push right the vehicle without the rocket animation moves. OK. Now cut, or copy, the vehicle with the rocket. Then double click the vehicle without the rocket. At the top of the screen you will see the timeline for your vehicle, click on the second frame and convert it to a blank keyframe. Now paste in the vehicle with the rocket animation. Make sure that it is at the same x,y coordinates as the vehicle in frame 1 (taking into consideration the rocket animation, of course). Now click frame 1 and go to actions, type stop(); then go to frame 2 and do the same. Now go back to the main scene. Now if you test your code the vehicle without the rocket should move around as before. You need to add one more bit of code. In your code that is handling the right arrow press add this: ball.gotoAndStop(2); Also, you will need to add ball.gotoAndStop(1); to the code that handles no key presses.

Let me know if you get it working or not.

 
Flag Post

yup that’s what I had done, if the x,y position determined from the upper left hand corner of the object I’ve made them match now, and it acts exactly the same as before :(

 
Flag Post

punking I made a very rough demonstration. Check out this file:

mc_example

It shows that if you press left or right the movieclip changes and moves. Once you stop pressing left or right the movieclip changes back.

Again, let me know how things go.

 
Flag Post

I’m not getting how this works,
I replace the pictures with my own, it works
I change it so left and right go to diffrent frames, it works
I change it so that all four directions go to diffrent frames, left right works up/down only moves it
I figure it must be the combo that it is makeing the left/right work so I add every possible arrow key combination, it stops working and moves without changeing frames

it there a grammer diffrent from
if
(!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN))
{
ball.gotoAndPlay(1);
for doing three key combos? and what would the four key one be?

 
Flag Post

ch00se I saw your flash demonstrastion and it helped me but how do I make it change colors example after it changes blue it changes green and so on

 
Flag Post

Mockster, here is another file. It is a simplified way of doing it, there are other and better ways, but this should be a good start:

mc_example_with_anim

You will now see the ball “squish” itself as it goes back and forth. What I did was put a boolean flag into the code to tell when the animation was running and when it wasn’t. That way you can put your animated movieclip into the second frame on its timeline. (double click the ball to see the animated movieclip).

You could also bypass using seperate frames by attaching the animated movieclip on the same x,y coords and depth as the stationary clip, but it all depends on how you want to handle it.

Hope this helps.

 
Flag Post

YEAH THANKS ALOT helps alot