Jump to content
Search Community

addChild - TweenMax

Applauz test
Moderator Tag

Recommended Posts

I'm wondering if there is any way to perform a TweenMax only once a movie clip is actually ready to be tweened ?

 

 

When doing something like this

 

 

var chapterMenu_mc:ChapterMenu_mc = new ChapterMenu_mc();
this.addChild(chapterMenu_mc);
chapterMenu_mc.x = 0;
chapterMenu_mc.y = -710;

    TweenMax.to(chapterMenu_mc, 1, {y:42, ease:Expo.easeOut,  startAt:{x:0, y:-710}});

 

 

The menu is a large movie clip. and I find that the tween is starting before the menu is ready on the stage.

 

Is the only solution to put a delay parameter on the tween ?

Link to comment
Share on other sites

I guess it depends what you mean by "ready". I don't know what's causing the delay in your MovieClip being ready, but my advice would be to determine that and then add whatever listeners or code necessary to sense when that task has finished, and then do your tween. I wouldn't recommend using a delay because how would you know exactly how long the delay should be? What if it's 0.1 seconds on a 3.4Ghz i7 system, but it's 0.9 on an iPad?

 

Is there something you wanted TweenMax to do in order to sense when your MovieClip is "ready"?

Link to comment
Share on other sites

Well .. the application is only going to run on iPad2 and iPad3 .. so thats all I need to worry about.

 

I was just wondering if there was anything with TweenMax that could detect that a movie clip was actually visible on the stage before it started to tween.

Link to comment
Share on other sites

Simple answer is "no, TweenMax does not detect that a clip is on stage"

 

From my understanding the AS3 Event ADDED_TO_STAGE filres on the same frame that addChild() was called so you can't use that effectively here. If you want your tween to start after you are absolutely positive that the addChild object has been rendered, you can wait until the next ENTER_FRAME event fires.

 

from what i've read, I believe you can do

 

addChild(something);
something.addEventListener(Event.ENTER_FRAME, startTween);

function startTween(e:Event):void{
TweenLite.to(something, 1, {x:100})
something.removeEventListener(Event.ENTER_FRAME, startTween);
}

 

basically the first ENTER_FRAME event (that you are listening for) won't fire until the frame after addChild() was called and your object should have successfully rendered by then. I'm not 100% positive of all this but it might be worth a shot.

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