PDA

View Full Version : How do I use actionscript instead of a motion tween?


scanman20
12-09-2001, 06:57 PM
I've noticed some slick effects where text or images can move quickly and smoothly across a movie and I know this is done with actionscript instead of motion tweens. Can someone explain how to do this with a quick example? I've tried using motion tweens at various frame rates and it always ends up looking jerky so I know that it must be an actionscript thing.

As a side note, I've also noticed where text or graphics move smoothly and quickly and gradually slow down (or vice versa). Any pointers or examples would be extremely appreciated.

Billy T
12-09-2001, 09:43 PM
this example has a few effects and tricks - including the movement one you were asking about

cheers

scanman20
12-09-2001, 10:26 PM
Thanks Billy! I'll check out the zip as soon as I can. In the meantime I figured out how to use actionscript to move an object with a loop, but it goes way too fast so now I'll see bewteen your zip and my nosing around if I can figure it out.

Jesse
12-10-2001, 09:03 AM
See the ActionScripted Movement tutorial also :)

Ricod
12-10-2001, 09:06 AM
if things go to fast using a frame loop u could set a variable where u define the speed. Compare this to yer fps (12 by default) and use this variable to define how fast yer animation should go. Check the tutorial :
http://www.actionscripts.org/tutorials/intermediate/actionscripted_movement/index.shtml

heh :p guess Jesse was just ahead of me while I was replying !

scanman20
12-10-2001, 05:34 PM
Thanks Jesse and Ricod, that tutorial is extremely helpful.

Now I have one more question (sick of the new guy yet?). The tutorial seems to deal with objects moving at a constant speed. Is there a tutorial to show how to accelerate or decelerate an object? I'm thinking along the lines of how a motion tween has easing in and easing out. I'm assuming this would just be some actionscript algebra to calculate the acceleration/deceleration but if an example exists, it would save me hours of frustration. Thanks.

Billy T
12-10-2001, 09:57 PM
did you even look at the file I uploaded?

scanman20
12-10-2001, 10:07 PM
Sure did. But I haven't had the chance to break it down to the one effect I was looking for. I was hoping for a walk thorugh rather than trying to figure out what you did. As soon as I get the time I will try and break down your movie. I did manage to find a few tutorials on the subject in the meantime though.

Billy T
12-10-2001, 10:17 PM
in the code layer you will see a movieclip (just a dot I'm afraid - this was made before I got in the habit of put a box behind my code clips)

in there you will see on frame 1

current_x = getProperty("../sections", _x);
gets the current x of the clip you are scrolling

dif_x = current_x-/:xpos;
calculates the difference between it's current x and the x pos of where you want it to go

setProperty ("../sections", _x, current_x-(dif_x/5));
sets the new x of your target clip. Dividing the x by 5 gives the smooth movement - play around with this - try changing 5 to 10 or whatever and note the difference.


on the buttons on the stage you will see

on (release) {
/:xpos = "674.4";
}

This simply sets a new target x for your scrolling clip

hope this helps

cheers

scanman20
12-10-2001, 10:23 PM
Thanks a bunch for clearing that up and saving me time Billy, I really appreciate your help, and everyone elses pointers. :)

I'm going to get this to work tonight. Will post with success story soon ;)