00:00
00:00

As: Fading Trail Effect

9,611 Views | 31 Replies
New Topic Respond to this Topic

As: Fading Trail Effect 2005-10-29 08:11:25


AS: Main

One for the specific projects/effects section.

FADING TRAIL EFFECT

You've probably seen the effect which is used in flashes like the slow-mo scene of Xiao Xiao 3, and various other 'bullet-time'-style movies.
It basically consists of copies of the character, running a frame, or several frames, behind the main one, and alpha'd down.
Crappy example
It's certainly possible to create this effect purely via animation. But, there's a much simpler way, and it goes a little something like this:

Make your animation inside an Movie Clip. If you don't intend to loop it, add a stop(); action on the final frame.
Exit edit mode, select the MC on stage, and give it the Instance Name 'pie'

IF YOU ARE NOT INTENDING TO LOOP THE ANIMATION:
Press F9, and add these actions:


onClipEvent (load) {
numCopies = 5; //Number of copies to make, adjust as you wish
this.swapDepths(1100); //Make sure the original MC is at the 'top of the pile'
if (_name == "pie") { //Only run this code from the original MC, not the dupes
for (i=1; i<numCopies+1; i++) {
duplicateMovieClip("_root.pie", "dmc"+i, i+1000);
_root["dmc"+i].nm = i; //Holds the # of the MC
_root["dmc"+i].af = 100/numCopies; //Used to calculate the amount to fade each MC
_root["dmc"+i].onEnterFrame = function() {
with (this) {
if (_root.pie._currentframe == _root.pie._totalframes) { //If main MC has finished, fade dupes out
_alpha-=af;
if(_alpha<=0) {this.removeMovieClip();}
} else {
gotoAndStop(_root.pie._currentframe-nm); //Go to frame, based on 'distance' behind main MC
_alpha = 100-(af*nm); //Set alpha based on 'distance' behind main MC
}
}
};
}
}
}

IF YOU ARE INTENDING TO LOOP THE ANIMATION:
Press F9, and add these actions:

onClipEvent (load) {
numCopies = 15; //Number of copies to make, adjust as you wish
this.swapDepths(1100); //Make sure the original MC is at the 'top of the pile'
if (_name == "pie") { //Only run this code from the original MC, not the dupes
for (i=1; i<numCopies+1; i++) {
duplicateMovieClip ("_root.pie", "dmc"+i, i+1000);
_root["dmc"+i].nm = i; //Holds the # of the MC
_root["dmc"+i].af = 100 /numCopies; //Used to calculate the amount to fade each MC
_root["dmc"+i].fr =1-i; //Used to calculate which frame to go to
_root["dmc"+i].onEnterFrame = function() {
with (this) {
fr++; //Which frame?
if(fr>_totalframes) {fr=1;} //Loop it
gotoAndStop(fr);
_alpha = 100-(af*nm); //Set alpha
}
};
}
}
}

I'm not going to go into detail about how these work, if you understand AS it's fairly clear, and if you don't, go check out

AS: Duplicated Movie Clips
AS: ClipEvents by Inglor
AS: swapDepths by -liam-
AS: Variables by Rantzien
AS: Loops & Conditions by BleeBlap
AS: Maths - Basic by T-H


- - Flash - Music - Images - -

BBS Signature

Response to As: Fading Trail Effect 2005-10-29 08:13:35


wouldn't a if(_name.indexOf("dmc") == -1) produce a similar effect as =="pie" and wouldn't require the user to give his MC an instance name?

Response to As: Fading Trail Effect 2005-10-29 08:13:44


Maybe more of a FOSS thread?
Oh well pretty nice I know alot of matrix wannabe movies that could use this :)


- Matt, Rustyarcade.com

Response to As: Fading Trail Effect 2005-10-29 08:15:26


cool, some AS i could use :) thnx


Gamertag: Medieval Turkey.

I also make signatures - PM what you want, and I'll make it.

BBS Signature

Response to As: Fading Trail Effect 2005-10-29 08:15:35


At 10/29/05 08:13 AM, Inglor wrote: wouldn't a if(_name.indexOf("dmc") == -1) produce a similar effect as =="pie" and wouldn't require the user to give his MC an instance name?

It surely would. That's quite a neat bit of code, I'll be using it in future.


- - Flash - Music - Images - -

BBS Signature

Response to As: Fading Trail Effect 2005-10-29 08:42:23


At 10/29/05 08:15 AM, lucozadedude wrote: cool, some AS i could use :) thnx

Agreed. It's very useful, indeed.

Wouldn't it be easier if you just add:

_name = "pie";

To the onClipEvent(load) instead of telling people to give it a pie instance name?
I remember when I was a beginner at flash, I animated crappy movies without even knowing what a frame label is, what an instance name is, etc...


BBS Signature

Response to As: Fading Trail Effect 2005-10-29 08:46:20


Well toast you have grown alot since last week : )


- Matt, Rustyarcade.com

Response to As: Fading Trail Effect 2005-10-29 08:50:01


fucking with _name in actionscript is known to have issues and is very illogical

Response to As: Fading Trail Effect 2005-10-29 08:55:13


At 10/29/05 08:50 AM, Inglor wrote: fucking with _name in actionscript is known to have issues and is very illogical

So this guy is illogical?

At 10/29/05 08:46 AM, Ninja-Chicken wrote: Well toast you have grown alot since last week : )

???


BBS Signature

Response to As: Fading Trail Effect 2005-10-29 08:57:25


At 10/29/05 08:55 AM, -Toast- wrote:
At 10/29/05 08:50 AM, Inglor wrote: fucking with _name in actionscript is known to have issues and is very illogical
So this guy is illogical?

Thats what he said would you like us to write it again?
Dont bum people because of there level

At 10/29/05 08:46 AM, Ninja-Chicken wrote: Well toast you have grown alot since last week : )
???

lol n00b


- Matt, Rustyarcade.com

Response to As: Fading Trail Effect 2005-10-29 08:58:40


At 10/29/05 08:57 AM, Ninja-Chicken wrote:
At 10/29/05 08:55 AM, -Toast- wrote: So this guy is illogical?
Thats what he said would you like us to write it again?
Dont bum people because of there level

At 10/29/05 08:46 AM, Ninja-Chicken wrote: Well toast you have grown alot since last week : )
???
lol n00b

Oh god, here we go again. Just pack it in, will you?


- - Flash - Music - Images - -

BBS Signature

Response to As: Fading Trail Effect 2005-10-29 09:02:14


At 10/29/05 08:57 AM, Ninja-Chicken wrote: Thats what he said would you like us to write it again?
Dont bum people because of there level

At 10/29/05 08:46 AM, Ninja-Chicken wrote: Well toast you have grown alot since last week : )
???
lol n00b

You know, it's not even funny...


BBS Signature

Response to As: Fading Trail Effect 2005-10-29 09:03:05


lol sorry jokes <3
Hey denvish couldnt you do a variation of this code to make the entire stage have a motion trail


- Matt, Rustyarcade.com

Response to As: Fading Trail Effect 2005-10-29 09:05:52


At 10/29/05 09:03 AM, Ninja-Chicken wrote: lol sorry jokes <3

*Sigh*, sometimes I'm getting really fed up of those "jokes"...


BBS Signature

Response to As: Fading Trail Effect 2005-10-29 09:07:58


Moving back to the topic this is a real useful code. It's gotta be a hell of a lot faster than doing the effect by hand, especially if you tend to animate inside MCs anyway.


BBS Signature

Response to As: Fading Trail Effect 2005-10-29 09:19:54


At 10/29/05 08:55 AM, -Toast- wrote:
So this guy is illogical?

I never liked rystic's jumping engine :P

Response to As: Fading Trail Effect 2005-10-29 09:32:35


YAY !!! BULLET TIME EFFECT ;DD

Response to As: Fading Trail Effect 2005-10-29 09:57:20


At 10/29/05 09:07 AM, -Paranoia- wrote: Moving back to the topic this is a real useful code. It's gotta be a hell of a lot faster than doing the effect by hand, especially if you tend to animate inside MCs anyway.

Yeah. I'm still playing with the code. You can get slightly different effects by playing with various variables
In the second (looping) code, replace
_root["dmc"+i].fr =1-i; //Used to calculate which frame to go to
with
_root["dmc"+i].fr =1-(i*2); //Used to calculate which frame to go to

Gives a slightly more staggered trail - ANOTHER SHITTY EXAMPLE


- - Flash - Music - Images - -

BBS Signature

Response to As: Fading Trail Effect 2005-10-29 12:16:55


I like your new sig denvish

Response to As: Fading Trail Effect 2005-10-29 12:20:02


At 10/29/05 12:16 PM, T-H wrote: I like your new sig denvish

Fanks mister


- - Flash - Music - Images - -

BBS Signature

Response to As: Fading Trail Effect 2005-10-29 12:24:07


That's some pretty nice effect you've got there.

i'm not posting my stuff, because it's horribly unoptimized. i might make a much nicer version... well, i started, but then flash crashed for no reason, and i'm too lazy to start again

I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.

Response to As: Fading Trail Effect 2005-10-29 14:58:31


Rystic himself said that he used _name so noobs could just copy and pastethe it and expect it to work. It is not the best way.

Response to As: Fading Trail Effect 2005-10-29 15:13:57


At 10/29/05 09:03 AM, Ninja-Chicken wrote: Hey denvish couldnt you do a variation of this code to make the entire stage have a motion trail

Couldn't you just put everything in an MC?

Response to As: Fading Trail Effect 2006-01-27 14:53:54


but then wouldnt the mc have the effect. so just a sqaure with the effect around the outside

Response to As: Fading Trail Effect 2006-09-15 17:50:04



Make your animation inside an Movie Clip. If you don't intend to loop it, add a stop(); action on the final frame.
Exit edit mode, select the MC on stage, and give it the Instance Name 'pie'

what do u mean by make the animation inside the movie clip
i bet its really basic stuff and u all think im a idiot for not knowing but......i dont care im just learning

Response to As: Fading Trail Effect 2006-09-15 21:25:19


H-W-T:

Hit Control+F8 and select movieclip. Animate what you want in there. When you're done, go up top near where it says "File, Edit" and hit Scene 1.

From there, go into the library on the right, Control+L, and drag the "Movieclip" out to the stage where you want.

Hit control+enter to export and view.

Response to As: Fading Trail Effect 2006-09-16 08:25:25


ok thanks

Response to As: Fading Trail Effect 2008-04-07 16:02:43


I need code to have a single, arrow key controlled movie clip to have a trail.

Nothing is moving inside the movie clip, but the movie clip is moving on the stage. I need code for this please.


BBS Signature

Response to As: Fading Trail Effect 2009-07-01 17:25:52


Any way to make the trail a little further off from the main character? It seems to overlap a lot

Response to As: Fading Trail Effect 2009-07-01 17:37:11


Good job at bumping a 4-year-old thread with a simple question