Forum Topic: As: Fading Trail Effect

(5,016 views • 32 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

Denvish

Reply To Post Reply & Quote

Posted at: 10/29/05 08:11 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

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

None

Inglor

Reply To Post Reply & Quote

Posted at: 10/29/05 08:13 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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?


None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/29/05 08:13 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,661

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

- Matt, Rustyarcade.com


None

Lucozadedude

Reply To Post Reply & Quote

Posted at: 10/29/05 08:15 AM

Lucozadedude FAB LEVEL 11

Sign-Up: 07/28/05

Posts: 3,905

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

None

Denvish

Reply To Post Reply & Quote

Posted at: 10/29/05 08:15 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

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

None

Toast

Reply To Post Reply & Quote

Posted at: 10/29/05 08:42 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,924

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...


None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/29/05 08:46 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,661

Well toast you have grown alot since last week : )

- Matt, Rustyarcade.com


None

Inglor

Reply To Post Reply & Quote

Posted at: 10/29/05 08:50 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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


None

Toast

Reply To Post Reply & Quote

Posted at: 10/29/05 08:55 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,924

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 : )

???


None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/29/05 08:57 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,661

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


None

Denvish

Reply To Post Reply & Quote

Posted at: 10/29/05 08:58 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

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

None

Toast

Reply To Post Reply & Quote

Posted at: 10/29/05 09:02 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,924

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...


None

Rustygames

Reply To Post Reply & Quote

Posted at: 10/29/05 09:03 AM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,661

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


None

Toast

Reply To Post Reply & Quote

Posted at: 10/29/05 09:05 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,924

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"...


None

Paranoia

Reply To Post Reply & Quote

Posted at: 10/29/05 09:07 AM

Paranoia DARK LEVEL 34

Sign-Up: 04/22/05

Posts: 9,697

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

None

Inglor

Reply To Post Reply & Quote

Posted at: 10/29/05 09:19 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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

I never liked rystic's jumping engine :P


Happy

Zielak

Reply To Post Reply & Quote

Posted at: 10/29/05 09:32 AM

Zielak FAB LEVEL 17

Sign-Up: 09/21/05

Posts: 865

YAY !!! BULLET TIME EFFECT ;DD


None

Denvish

Reply To Post Reply & Quote

Posted at: 10/29/05 09:57 AM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

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

None

T-H

Reply To Post Reply & Quote

Posted at: 10/29/05 12:16 PM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

I like your new sig denvish


None

Denvish

Reply To Post Reply & Quote

Posted at: 10/29/05 12:20 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

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

Fanks mister

- - Flash - Music - Images - -

BBS Signature

None

Devenger

Reply To Post Reply & Quote

Posted at: 10/29/05 12:24 PM

Devenger NEUTRAL LEVEL 09

Sign-Up: 12/24/04

Posts: 1,103

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.


None

Musician

Reply To Post Reply & Quote

Posted at: 10/29/05 02:30 PM

Musician EVIL LEVEL 04

Sign-Up: 05/19/05

Posts: 2,189

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


None

Begoner

Reply To Post Reply & Quote

Posted at: 10/29/05 02:58 PM

Begoner NEUTRAL LEVEL 10

Sign-Up: 10/10/04

Posts: 3,038

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.


None

Tantric

Reply To Post Reply & Quote

Posted at: 10/29/05 03:13 PM

Tantric LIGHT LEVEL 10

Sign-Up: 10/29/05

Posts: 472

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?


None

Phyruss

Reply To Post Reply & Quote

Posted at: 1/27/06 02:53 PM

Phyruss EVIL LEVEL 07

Sign-Up: 12/29/05

Posts: 286

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


None

H-W-T

Reply To Post Reply & Quote

Posted at: 9/15/06 05:50 PM

H-W-T EVIL LEVEL 17

Sign-Up: 02/14/05

Posts: 882


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


None

TrueDarkness

Reply To Post Reply & Quote

Posted at: 9/15/06 09:25 PM

TrueDarkness EVIL LEVEL 27

Sign-Up: 08/31/04

Posts: 4,718

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.


None

H-W-T

Reply To Post Reply & Quote

Posted at: 9/16/06 08:25 AM

H-W-T EVIL LEVEL 17

Sign-Up: 02/14/05

Posts: 882

ok thanks


None

Sinvader

Reply To Post Reply & Quote

Posted at: 4/7/08 04:02 PM

Sinvader EVIL LEVEL 06

Sign-Up: 07/17/07

Posts: 124

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

Questioning

Sunrie

Reply To Post Reply & Quote

Posted at: 7/1/09 05:25 PM

Sunrie NEUTRAL LEVEL 26

Sign-Up: 09/14/03

Posts: 316

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


All times are Eastern Standard Time (GMT -5) | Current Time: 09:13 PM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!