View Full Version : flash mx-motion trail
jimw00d
January 10th, 2003, 07:04 AM
If there is an mc on the stage, that moves around say simply from left to right, is there a way, using actionscript, that the motion trail can be seen, a little like the onion effect, to show where a mc has been.
Ryall
January 10th, 2003, 10:24 AM
you could duplicate the MC at distances behind the origonal relative to its direction of movement, then make them have lower and lower alpha values... I guess that would be entirely AS.. but you could easily animate [insert desired number here] instances of a MC and then offset their timing so you get that onion skin effect, but that wouldnt be all AS so i dunno:sigh:
Maybe if you gave an example of what you are trying to achieve.
Peace
BTW if you look at Dans footer, he used all tweens for that, so you can achieve it without AS too.
mjULTRA
March 28th, 2003, 07:03 PM
i too am looking for code that will offset the timing and alpha for any given movie clip. we know it can be done with multiple instances, but we want Actionscripting Code!!! Where are you Lost in Beta??
Many people say they know how, and that its easy, and then say, 'do it the old way...' ...but then again, if i was an AS-guru, i would get sick of people that always want code snippets, but take no initiative in learning it themselves. Perhaps if codes were accompanyed with comments, we could understand how they are working. I dont know, just a thought... Bleep! :rd:
senocular
March 28th, 2003, 07:07 PM
yeah, where is that lost in beta?
mjULTRA
March 28th, 2003, 07:09 PM
im sure the almighty senocular knows this.... or am i wrong??
senocular
March 28th, 2003, 07:12 PM
that all depends ;)
So how do you want it to operate? How portable does it need to be? Do you need this on one clip or do you want something that can be thrown anywhere anytime?
Theres different ways of handling it depending on the end result
:)
mjULTRA
March 28th, 2003, 07:34 PM
anywhere, anytime would be nice. :)
i would actually like something simple, that offsets an duplicate instance of an MC by one frame, lowers the alpha by 20%, before playing it, and then repeats until nothing is shown. Or anything that would act simliar to that. Does that make sense? :crazy:
How about i just ask, "Is there a way i could get an onion screening effect in an animation by using AS?"
:skull:
zylum
March 28th, 2003, 09:52 PM
Is this what you're looking for? it only uses one MC named ball and the rest is AS... Each ball is a duplicate of the first ball and then there is some AS to change the alpha and for each ball to follow the one that's ahead of it... enjoy
mjULTRA
March 29th, 2003, 09:40 PM
thats pretty much the effect that i wanted, but is there a way to apply that to a motion tweened movie clip? one that rely's on the position of the clip, as opposed the the mouse cursor...
ball._visible = false
for (i=0; i<5; i++) {
nm = "ball"+i
ball.duplicateMovieClip(nm, 5-i)
}
ball0.onEnterFrame = function() {
this._x = this._x-(this._x-_shape)/1.2;
this._y = this._y-(this._y-_shape)/1.2;
};
ball1.onEnterFrame = function() {
this._alpha = 80
this._x = this._x-(this._x-ball0._x)/1.2;
this._y = this._y-(this._y-ball0._y)/1.2;
};
ball2.onEnterFrame = function() {
this._alpha = 60
this._x = this._x-(this._x-ball1._x)/1.2;
this._y = this._y-(this._y-ball1._y)/1.2;
};
ball3.onEnterFrame = function() {
this._alpha = 40
this._x = this._x-(this._x-ball2._x)/1.2;
this._y = this._y-(this._y-ball2._y)/1.2;
};
ball4.onEnterFrame = function() {
this._alpha = 20
this._x = this._x-(this._x-ball3._x)/1.2;
this._y = this._y-(this._y-ball3._y)/1.2;
};
can something like this be used and applied to a movie clip in a motion tween?
zylum
April 7th, 2003, 08:46 PM
Sure you can tween. You can also script the motion. For a motion tween, just change the firs few lines of code to follow the main tweened ball / object...
ball0.onEnterFrame = function() {
this._x = this._x-(this._x-ball._x)/1.2;
this._y = this._y-(this._y-ball._y)/1.2;
};
for scripted motion such as a bounce change it to:
decay = 0.98
gravity = 1
dx = 25
ball._visible = false
for (i=0; i<5; i++) {
nm = "ball"+i
ball.duplicateMovieClip(nm, 5-i)
}
ball0.onEnterFrame = function() {
//bounce
dy *= decay
dy += gravity
this._y += dy
if (this._y>350){
this._y = 350
dy *= -1
}
//x movement
this._x += dx
dx *= decay
if (this._x>540){
this._x = 540
dx *= -1
}
if (this._x<10){
this._x = 10
dx *= -1
}
}
just do the normal scripting to the main or original MC and leave the rest the same. here are the flas if you wanna check them out...
zylum
April 7th, 2003, 08:48 PM
here is the scripted bounce with the trailer...
zylum
April 7th, 2003, 08:51 PM
here is the motion tween w/ the trailer...
p.s. the code may not be optimized since I'm not yet a flash 'guru' so bear with me. also, if you have any comments or suggestions on how to improve the script, i would like to hear from you...:block:
mjULTRA
April 8th, 2003, 11:32 AM
thanks a lot zylum! ball trailer3 is exactly what i was looking for!
And to think, LIB said it couldn't be done....
i could not get ball trailer2 to output anything. i get this error:
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 33: ';' expected
this._x = this._x-(this._x-ball0._x)1.2/*the intertia follow (this._x = this._x-
Of course you can never just add a ';' where it says and be done with it, cuz that would be too easy. Anyway, thanks a lot.
zylum
April 8th, 2003, 04:21 PM
alas, i took out a division sign when i wrote the comment... here's the code if you wanna fix it yourself
was:
ball1.onEnterFrame = function() {
this._alpha = 80
this._x = this._x-(this._x-ball0._x)1.2; /*the intertia...
is:
ball1.onEnterFrame = function() {
this._alpha = 80
this._x = this._x-(this._x-ball0._x)/1.2; /*the intertia...
notice the missing slash before the '1.2'... here's the fla if you're too lazy to put in the slash;)
mjULTRA
April 8th, 2003, 04:23 PM
sweet! thanks a lot zylum. you rock! :rd:
zylum
April 8th, 2003, 04:25 PM
no problem, you may want to ask one of the betters ASers to fix it up tho cuz i don't think it's really optimized...
Davehead
April 8th, 2003, 07:17 PM
Yeah,
Thanks, I have also been trying to create something like that!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.