PDA

View Full Version : Actionscrip for tweening ?


saltamontes
02-02-2002, 05:31 PM
First of all, I want to say hi to everybody.
This is my first post in this forum
and I wish to learn from all you gurus
and newbies (like me) out there.
In my part, I'll be more than glad to share
with you whatever in my experience may be helpful to you.

I want to use an _alpha property effect in some MCs.
It's a simple effect: when movie loads, MC _alpha
tweens from 0% to 100%. Movie stops. Then, when button
click, MC _alpha tweens back to 0%.

The thing is that, as I will need the same effect
in several different MCs, I'm concerned
about file size.
Will I have any important save in file
size if I use actionscript (instead of using keyframes in timeline)
for this effect?
If so, how it's done?

Thanks a lot in advance!

Regards,

The Saltamontes

Billy T
02-02-2002, 11:59 PM
its always better to actionscript ;)

on your mcs put this action

onClipEvent(load){
this._alpha=0;
_root.fadeIn=true;
}

onClipEvent(enterFrame){
if (_root.fadeIn==true && this._alpha<100){
this._alpha=this._alpha+2;
}else if (_root.fadeIn==false && this._alpha > 0){
this._alpha=this._alpha-2;
}
}

then on your button put

on (release){
if (_root.fadeIn==true){
_root.fadeIn=false;
}else{
_root.fadeIn=true;
}
}

have a look at the attached file

cheers

saltamontes
02-03-2002, 12:39 AM
Billy T:

I'm gonna try the code.
Probably it will take me longer than normal.
As soon as I'm done I'll be back here.


In the meantime, THANKS!!


Kind Regards,

The Saltamontes.

saltamontes
02-03-2002, 06:14 AM
Alright Billy T, I'm up and running!

Not just that, but also, I was able to adapt your script
for another MC that remains invisible until the button is clicked,
then, fades in.

This is the code:

onClipEvent(load){
this._alpha=0;
_root.fadeIn=true;
}

onClipEvent(enterFrame){
if (_root.fadeIn==true && this._alpha<100){
this._alpha=this._alpha==0;
}else if (_root.fadeIn==false && this._alpha<100){
this._alpha=this._alpha+15;
}
}

It was very helpful to study the code in your .fla and experiment tweaking it.
Well, that's a big step for me...

Thank you Billy T, I'm a happy man!


The Saltamontes.


P.D.: the script did reduced the file size from 381kb to 167kb.

Billy T
02-03-2002, 06:25 AM
happy to help

that's interesting about the file size - I wouldnt have expected such a big reduction.

with your code, I'm not sure what this means

this._alpha=this._alpha==0;

but if it's working for you then that's cool

cheers

saltamontes
02-03-2002, 06:54 AM
this._alpha=this._alpha==0;

is keeping the MC invisible until
the button change the variable to false.
After that, the MC fades in.


I'm also surprised with the file size. The original
fla had 7 frames with _alpha tweening in 3 layers, a label, a couple of frame actions... and now I just have 1 frame.


Regards


The Saltamontes

Billy T
02-03-2002, 06:57 AM
oh ok

should change it to

this._alpha=0;

cheers

saltamontes
02-03-2002, 07:04 AM
Do you mean

this._alpha=this._alpha=0;

or just

this._alpha=0;





The Saltamontes

saltamontes
02-03-2002, 07:05 AM
Done...


yeah, looks better now...



The Saltamontes