[AS2] setting variable on rollover

Hello, hope someone can help…

I am using laco tweening prototypes http://laco.wz.cz/tween/ and have a little problem which im sure is easy to solve, but i just dont know how…

I have e.g 3 movieclips which i want to animate with a rollover from 3 different buttons - btn1 animates mc1, btn2 animates mc2 etc.

Each mc has the same animation (3 tweens - x,y and rotation) so i have set up a function for the three tweens using a variable for the mc name:

var my_mc = "mc1";

function PageTween() {
	my_mc.tween("_x", 165, 1, "easeOutExpo");
	my_mc.tween("_y", 75, 1, "easeOutExpo");
	my_mc.tween("_rotation", 1, 1, "easeOutExpo");
}

this is so when i rollover btn2 i can change the var my_mc to “mc2” so that i can reuse the function.

btn2.onRollOver = function() {
      my_mc = "mc2";
	PageTween()
};

but, it doesnt work. I am assuming that the tween ignores the variable.
is there some way inserting a calculation to get the variable instead of my_mc at the start of the tween?

thanks for your time

Lee

[AS]function PageTween(my_mc:MovieClip):Void {
my_mc.tween("_x", 165, 1, “easeOutExpo”);
my_mc.tween("_y", 75, 1, “easeOutExpo”);
my_mc.tween("_rotation", 1, 1, “easeOutExpo”);
}
for (i=1; i<4; i++) {
this[“btn”+i].ind = i;
this[“btn”+i].onRollOver = function() {
PageTween(_root[“mc”+this.ind]);
};
}[/AS] :slight_smile:

Hi BlueNar,

Thanks for the quick response, i ahve tried the script provided, and in my main movie that im working on it had no effect, so i tried it on a fresh movie and found that when i included in the laco as:

#include “lmc_tween.as”

i was gettting an error:

found Number where String is required.
for (i=1; i<4; i++) {

I have uploaded the test here >

http://www.leeharding.net/test/tweenFunction.zip

i hope you can figure this one out as it is giving me a headache. Thanks for your time, i appreciate it.

regards

Lee

does anyone else have any ideas as how i can do this?

thanks

Lee

What is the line of code before the for loop…

the code before the for loop

function PageTween(my_mc:MovieClip):Void {
    my_mc.tween("_x", 165, 1, "easeOutExpo");
    my_mc.tween("_y", 75, 1, "easeOutExpo");
    my_mc.tween("_rotation", 1, 1, "easeOutExpo");
}

thanks

Lee

the code before the for loop

function PageTween(my_mc:MovieClip):Void {
    my_mc.tween("_x", 165, 1, "easeOutExpo");
    my_mc.tween("_y", 75, 1, "easeOutExpo");
    my_mc.tween("_rotation", 1, 1, "easeOutExpo");
}

thanks

Lee

can you post the lmc_tween.as file… laco.wz site is acting strange.

tis a strange site…

i used the mxp installer, but here is the as file

let me know if you need the mxp

cheers

Lee

the problem lies within the laco tween class syntax, which Im unfamiliar with. I replaced it with the tween class to show that the function does work properly.

thanks - thats going to be helpful for something else im working on…

unfortunately im using the laco tween throughout the site that i need this for…

i will have to try something else… if you get any ideas, let me know.

is there any way i can just use the

function PageTween(my_mc:MovieClip):Void {

without the for loop?

thanks for your time

Lee