Jump to content
Search Community

as2 onComplete not triggering function

Gory test
Moderator Tag

Recommended Posts

hello everybody,

i m trying to do something very simple but i can't make it work(i'm new to AS), i just want to trigger a function onComplete, i don't understand what i do wrong, at the end of the tween nothing happens appart from text getting "some new text" .

 

here is the code:

 

TweenMax.to(bg_preloader, 2, {_alpha:0,ease:Elastic.easeOut, onComplete:nextTw, onCompleteScope:this });
function FinishTween() { 
                this.gotoAndStop("main");
};
this.Dyntxt_pre.text ="some new text";
function nextTw ( ):Void {
                TweenMax.to(Dyntxt_pre, 3, { _xscale:400, _yscale:400,_alpha:0, ease:Bounce.easeOut});
                if (bg_preloader._alpha == 0){ 
         FinishTween();       
         bg_preloader._visible =false;
         Dyntxt_pre._visible =false;
             }
} 

 

 

i've read other post on this topic but couldn't find a solution, i hope someone can help;

thanks in advance.

gory

Link to comment
Share on other sites

Did you import the classes?

 

import com.greensock.*;
import com.greensock.easing.*;

 

And you downloaded the code and put it in the same directory as your FLA, right? If you're still having trouble, please post your FLA that demonstrates the issue (don't forget to zip it first).

Link to comment
Share on other sites

It's a logic problem in your code. I saw two issues actually:

 

1) You loop between frames 1 and 2 while preloading, but you don't stop that loop when bytes_loaded == bytes_total, so your code keeps creating tweens over and over and over again which overwrite each other. That's why the onComplete never fires - the tween never completes because it keeps getting overwritten by a new one. Add a stop() inside that condition and you should be okay.

 

2) You nested 2 of your functions inside of a conditional statement which is pretty weird. I wouldn't recommend doing that.

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...