all groups > flash actionscript > september 2005 >
You're in the

flash actionscript

group:

Generic motion tween?


Generic motion tween? cre8ive1974
9/6/2005 9:22:54 PM
flash actionscript:
is there a way to set up a generic motion tween?

for example I have an empty circle on the stage. On the stage I also have 4
buttons. red, green, blue and yellow.

In the library I have a red, green, blue and yellow circle all the same
dimension and registration of the empty circle.

When I click on the red button I want it to fade (not just change but to fade)
from the empty circle to the red circle, however next I want to be able to
click on the blue button (or yellow or green) (whichever) and have it fade from
the red circle to the Blue circle (or whichever color), then if I wanted to
click on another color button, I would want the circle to fade from whatever
color it is to whatever color I want. Is there a way to do this wihtout having
to make every color fade combination (red to blue, red to yellow, red to green,
green to red, green to yellow, green to blue, blue to red ....you get the idea)


Thanks!
D

Re: Generic motion tween? NSurveyor
9/6/2005 10:07:32 PM
Open up the library, right click on circle_mc, select Linkage. Then, select
Export for ActionScript. Hit OK. Then put this script on the frame that holds
your circle_mc:

var clips = [circle_mc];
var count = 0;
_global.fadeToCol = function(frame){
newc.onEnterFrame = null;
clips.push(newc);
trace(clips);
newc = this.attachMovie('circle_mc','c'+count++,count);
newc._x = clips[0]._x;
newc._y = clips[0]._y;
newc.gotoAndStop(frame);
newc._alpha = 0;
newc.onEnterFrame = function(){
this._alpha+=5;
if(this._alpha>=100){
for(var c in clips){
clips[c].removeMovieClip();
}
clips = [];
delete this.onEnterFrame;
}
}
}

And then for each button, use:

on(release){
fadeToCol(2);//for red
}
Re: Generic motion tween? cre8ive1974
9/7/2005 12:00:00 AM
Wow! I have no idea what you just wrote. I'm still trying to figure out this
actionscript stuff. But thanks for the response, I will try to look up
reference to see what you did. That's awesome that you know the code so
well.....

Thanks again
D
Re: Generic motion tween? NSurveyor
9/7/2005 12:00:00 AM
I'll try to explain it best I can. Basically, the screen starts off with one
instance of circle_mc, on the first frame. When you fadeToCol(2) a new circle
is created and goes to the red frame. But, it's alpha is set to 0 and slowly
inreases to 100. When it hits 100, it can delete all the circle_mc's (stored in
an array) below it, since they are no longer visible. However, if it does not
hit 100, and you use fadeToCol(3) the fading of the last clip will stop, and
that clip will be added to the array of clips underneath the top. And then, a
new instance of circle_mc that fades in and then removes the old instances,
when it hits 100, or if you fade again, it stops, and the new ones fades, etc.

I made in this way, in case a user clicks on a different button, before the
fade finishes - to make it look smooth.
AddThis Social Bookmark Button