Does anyone know how to make a movie clip leave a trail? Would it use [AS]duplicateMovieClip();[/AS]. I need it to fade out at the same time after duplicating it so any help would bo good.
[AS]//make original clip invisible
ball._visible = false;
//create prototype function to fade out
MovieClip.prototype.fadeOut = function() {
//activates the clips onEnterFrame handler
this.onEnterFrame = function() {
//decrement the alpha by 10
this._alpha -= 10;
//if the alpha is less than or equal to 0
if (this._alpha<=0) {
//delete the onEnterFrame handler
delete this.onEnterFrame;
//remove the clip
this.removeMovieClip();
}
};
};
//when the mouse moves
this.onMouseMove = function() {
//if i is greater than 1000 make it equal 0, else increment by 1
i>1000 ? i=0 : i++;
//duplicate clip
mc = ball.duplicateMovieClip(“ball”+i, 10000+i);
//position to x and y mouse position
mc._x = _root._xmouse;
mc._y = _root._ymouse;
//fade it out
mc.fadeOut();
//make it run a bit smoother
updateAfterEvent();
};[/AS]
This assumes your original clip has the instance name “ball”
Was this of any help?
Oh and before you ask (like everyone does), these actions go on a frame :sigh:
Well sort of, how would i make it do it duplicate while it is motion tweening not just mouse move?
Yes I did know that I had to put it on a frame but just as well you said it incase i was in a stupid mood.
Well everyone always asks me where the code goes, so I wasn’t sure if you knew.
And I don’t understand what you mean? duplicate while it is motion tweening? I thought you meant a mouse trailer, but after re-reading I see that isn’t it. Can you explain what you are trying to do better?
Well I have a circle MC, I need to move it (Via motion tween) and I want a trail of its movement to be left, these “trailed” movie clips are then to fade out.
This any better?
Oh ok, so sorta like Dans (telekenesis) footer.
Well his is all tweens, I suck with tweens so don’t ask me that method
So in AS it would go something like this…
[AS]//define variable to hold how man clips there should be
var i = 10;
//put original clip on top of all duplicated clips
ball.swapDepths(i);
//create function to add multiple balls
function addBall() {
//if variable i is greater than 0
if (i>0) {
//decrement it by 1
i–;
//duplicate the ball clip
mc = ball.duplicateMovieClip(“ball”+i, i);
//set the alpha
mc._alpha = (i*10);
} else {
//else if variable i isn’t greater than 0
//clear the interval (stop running this function)
clearInterval(myInterval);
}
}
//set the interval and call the addBall function every 15 milliseconds
myInterval = setInterval(addBall, 15);[/AS]
At least in theory I didn’t really test it out.
I have no Idea what I am meant to do with this AS, sorry lol but I dont even understand it! I dont get any of the AS i see in magazines with stuff using “i” what is all that about?
i is a variable if im correct whose value is 10, so when you see code like this i>0, what this means is that i is greater than 0, i-- this mean to subtract i (10) minus 1, i*10 is i (10) multiplied by 10, so there i gave you som insight as to what i is in this script, and if your guessing how i=10 it was stated here
var i=10
mebbe someone else can help more im not that great using as but i try to understand some of it :-\
Yes “i” is just a variable. You could call it whoopdidoopiedoo if you wanted, but I think “i” is easier
It is set to 10.
i-- is the same as saying i = i-1, so it derements the variable i by 1. So according to the if statment if “i” is greater than 0 then decrement i. So from 10 that would be 9, 8, 7, 6, 5, etc, etc.
ball.swapDepths(i) is pretty self explanitory, you need to swap the depth of the original clip otherwise the new duplicated clips will be created on levels higher than the original clip thus making all the new duplicated clips be above your original clip which would look pretty funky.
mc = ball.duplicateMovieClip(“ball”+i, i);
That is the duplicateMovieClip code where “ball”+i is the new name (would be ball9, ball8, ball7, etc), since you can’t have 2 instance names exactly the same without conflicting it is easier to attach the value of i to the end to keep it unique. The regular “i” in the script is for the level. Each level can only contain 1 clip so you can’t keep loading to the same level, and in this case we want each new clip on a level lower than the previous clip (so the first clip will appear to be in the front and the last clip will appear to be on the bottom).
mc._alpha = (i10) is kind of self explanitory, simple math there to set the alpha value from 90, 80, 70, 60, etc. (aka 910, 810, 710)
clearInterval(myInterval) is for when i gets to be equal to 0 (or less) we want to clear the interval to stop running the function every 15 milliseconds.
myInterval = setInterval(addBall, 15) sets the interval to call the addBall function every 15 milliseconds. myInterval is the interval ID that we use to target via the clearInterval() command in the function. Every time the addBall function is run the variable “i” will decrement and the new clip with a new alpha value will be created.
im so happy im learning how to read AS :beam: i love kirupa.com
Ok now I understand it.
So what do I do with this actionscript? Can you post a .fla with it working?
you use it!
I think lostinbeta will soon be lostmehair too…
So where do I put the AS then??? I tried it on the frame and the MC but nothing is happening.
The classic question :sigh:
You put this on a frame. Your tween must be contained in a movie clip with the instance name “ball” (no quotes, and can be changed if you change the instance name in the script).
Perhaps you are better off tweening it. And as I stated before, me and tweens don’t mix well, so I can’t help you with that method :-\
I have it working now, finally! I had the tween in the main timeline so it was the MC moving not the inards of the MC. Anyway thanx lostinbeta!
No problem, glad it worked out for you. I never did test the code so I was hoping it wasn’t a mistake on my part