Jump to content
Search Community

Call a movieclip named from a var

domi85 test
Moderator Tag

Recommended Posts

Hello,

I would like to make some tweens with movieclips, but these movie clips change from a var . I made this code :

 

activite = function() { // function that determines the movieclips concerned by the tween
var clipactif:MovieClip = this["clip_"+actif];
var imagegauche:MovieClip = this["image_"+synopsis+"_gauche"];
var imagedroite:MovieClip = this["image_"+synopsis+"_droite"];
};
bouton_rubrique2.onRelease = function() {
activite();
TweenLite.to(clipactif,1,{autoAlpha:0}); // the movieclips determined with activite() disappear
TweenLite.to(imagegauche,1,{_x:-460});
clip_rubrique2._x = 38;
TweenLite.to(clip_rubrique2,1,{autoAlpha:100}); // the new movieclips appear
TweenLite.to(image_rubrique2_droite,1,{_x:1000});
}

 

You would help me very much !

Thanks in advance,

Link to comment
Share on other sites

The problem is that you're defining your variables as LOCAL variables inside your function. Local variables are always deleted as soon as the parent function finishes running. So you just need to define those variables outside your function.

 

var clipactif:MovieClip;
activite = function() { 
  clipactif = this["clip_"+actif];
};
...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...