Jump to content
Search Community

Correct way to add, remove and re-add child- to parent-timeline?

powtoon test
Moderator Tag

Recommended Posts

Hi,

 

i am sequencing timelines on a master timeline which tween graphic objects (UIComponents) in a flex application.

 

sometimes i want to move a child timeline on the master timeline, so instead of say at second 5 it will start at second 8.

 

so i do something like this:

 

private var master:TimelineMax = new TimelineMax();

private var child1:TimelineMax = new TimelineMax();
//add tweens to child1

private var child2:TimelineMax = new TimelineMax();
// add tweens to child2, fading in and out objects.

master.insert(child1, 0);
master.insert(child2, 5);

//some function calls:
master.play();

//and another this:
master.stop();
master.remove(child2);
master.insert(child2, 8);

// and again another function calls:
master.gotoAndPlay(0);

 

after i remove and re-add the timeline, the objects tweened by the second timeline are not visible any more. i can see in the debugger that they still exist but they seem to being set to visible false or something like that...

 

any ideas highly appreciated.

 

thanks,

 

Sven

Link to comment
Share on other sites

This is not something I often do, but I made an example and had no problems.

Instead of removing and re-inserting your child2, you can alternately just change child2's startTime.

 

my sample looks like this:

 

import com.greensock.*;

var mainTl:TimelineMax = new TimelineMax({onUpdate:showTime});
mainTl.insert(TweenLite.to(black, 5, {x:520}));

var blueTl:TimelineLite = new TimelineLite();
blueTl.insert(TweenLite.to(blue, 1, {y:0}));

mainTl.insert(blueTl, 4);

TweenLite.delayedCall(2, shiftBlue);

function shiftBlue(){
 trace("remove");
 mainTl.remove(blueTl);
 mainTl.insert(blueTl, 3);
//or instead of removing and re-inserting you can change the startTime
//blueTl.startTime = 3;
}

function showTime(){
    time_txt.text = mainTl.currentTime.toFixed(2);
}

 

cs4 attached.

 

if you continue to experience weird results, please provide a very simple file that illustrates the error. thanks

shiftChildTimeline.zip

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