hey everyone,
Been a while hope everyones good.
I need some help on how to make my animations more efficient and functional by putting repeating code into a function or prototype.
Here’s an example of the sort of animations i mean:
_root.content.box._xscale = 0;
_root.content.box._yscale = 0;
_root.content.mask._xscale = 0;
_root.content.mask._yscale = 0;
_root.content.maintext._alpha = 0;
_root.content.pic._xscale = 0;
_root.content.pic._yscale = 0;
duration1 = 20;
duration2 = 10;
duration3 = 15;
duration4 = 20;
duration5 = 15;
b=0;
t=0;
r=0;
h=0;
y=0;
this.onEnterFrame = function(){
if(Go == true){
if(t<duration1){
_root.content.box._xscale = Math.EaseOutBack (t,0,100,duration1);
t++;
}
if(t>=(duration1/3)){
if(b<duration2){
_root.content.box._yscale = Math.EaseOutBack (b,0,100,duration2);
b++;
}
}
if(b>=duration2){
if(r<duration3){
_root.content.mask._xscale = Math.EaseOutQuint (r, 0, 100, duration3);
_root.content.mask._yscale = Math.EaseOutQuint (r, 0, 100, duration3);
r++;
}
}
if(r>=duration3){
if(h<duration4){
_root.content.maintext._alpha = Math.EaseInExpo (h, 0, 100, duration4);
h++;
}
}
if(h>=(duration4/2)){
if(y<duration5){
_root.content.pic._xscale = Math.EaseOutCirc (y,0,100,duration5);
_root.content.pic._yscale = Math.EaseInOutElastic (y,0,100,duration5);
y++;
}
}
}
}
button.onPress = function(){
Go = true;
}
// BTW - i have used penner's eqs
I have attached the fla so you can see what it looks like.
Now this method works fine and i get the desired animation etc. However it’s bloody inefficient!
Let’s say i got a site to do where this animation is exactly the same, but there are 20 sections each with there own heading, text and pic. How do i go about putting this code in once and then referencing it whenever necessary?
If someone could make this a prototype, or explain how to go about doing this, i would be very grateful.
in this particular case, i ideally want the site to be all on 1 frame, with different sections preloading when the various buttons are pressed and then the animation commencing once the content for each section is loaded. I don’t really need help for the preloading or anything, just a good way to reference the animation without having to write this code over and over.
Thanks guys,
Kd