Be a Supporter!

As: Fading Trail Effect

  • 7,900 Views
  • 32 Replies
New Topic Respond to this Topic
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
As: Fading Trail Effect Oct. 29th, 2005 @ 08:11 AM Reply

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
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:13 AM Reply

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?

Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:13 AM Reply

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


- Matt, Rustyarcade.com

Lucozadedude
Lucozadedude
  • Member since: Jul. 28, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:15 AM Reply

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
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:15 AM Reply

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
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:42 AM Reply

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
Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:46 AM Reply

Well toast you have grown alot since last week : )


- Matt, Rustyarcade.com

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:50 AM Reply

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

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:55 AM Reply

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
Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:57 AM Reply

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

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 08:58 AM Reply

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
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:02 AM Reply

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
Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:03 AM Reply

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

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:05 AM Reply

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
Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:07 AM Reply

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
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:19 AM Reply

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

I never liked rystic's jumping engine :P

Zielak
Zielak
  • Member since: Sep. 21, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:32 AM Reply

YAY !!! BULLET TIME EFFECT ;DD

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 09:57 AM Reply

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
T-H
T-H
  • Member since: Jan. 7, 2004
  • Offline.
Forum Stats
Member
Level 40
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 12:16 PM Reply

I like your new sig denvish

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 12:20 PM Reply

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

Fanks mister


- - Flash - Music - Images - -

BBS Signature
Devenger
Devenger
  • Member since: Dec. 24, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 12:24 PM Reply

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.

Musician
Musician
  • Member since: May. 19, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 02:30 PM Reply

At 10/29/05 09:19 AM, Inglor wrote:
At 10/29/05 08:55 AM, -Toast- wrote:
So this guy is illogical?
I never liked rystic's jumping engine :P

it works better than a hitTest engine, and is definently less taxing on RAM


I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs

Begoner
Begoner
  • Member since: Oct. 10, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 02:58 PM Reply

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.

Tantric
Tantric
  • Member since: Oct. 29, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to As: Fading Trail Effect Oct. 29th, 2005 @ 03:13 PM Reply

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?

Phyruss
Phyruss
  • Member since: Dec. 29, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to As: Fading Trail Effect Jan. 27th, 2006 @ 02:53 PM Reply

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

H-W-T
H-W-T
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Fading Trail Effect Sep. 15th, 2006 @ 05:50 PM Reply


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

TrueDarkness
TrueDarkness
  • Member since: Aug. 31, 2004
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to As: Fading Trail Effect Sep. 15th, 2006 @ 09:25 PM Reply

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.

H-W-T
H-W-T
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Fading Trail Effect Sep. 16th, 2006 @ 08:25 AM Reply

ok thanks

Sinvader
Sinvader
  • Member since: Jul. 17, 2007
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to As: Fading Trail Effect Apr. 7th, 2008 @ 04:02 PM Reply

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
Sunrie
Sunrie
  • Member since: Sep. 14, 2003
  • Offline.
Forum Stats
Member
Level 28
Animator
Response to As: Fading Trail Effect Jul. 1st, 2009 @ 05:25 PM Reply

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