jtvalles Posted August 21, 2012 Posted August 21, 2012 I am trying to create a timeline that is populated with content from an xml source. My questions are: How do I fade out the previous mc for the next mc? How do I restart the whole she-bang after the mcs have been populated? How do I reset the timeline when the xml file is updated? function loadTaglines():void { for ( var i:uint = 0; i < xml.length(); i++ ){ var tagline = new mc; tagline.txt_tagline.text = xml.tagline[i] tagline.x = 816; tagline.y = 47; tagline.scaleX = 4; tagline.scaleY = 4; tagline.alpha = 0; addChild(tagline).name = tagline + i; timeline.append( new TweenLite (tagline, .5, {scaleX:1, scaleY:1, alpha:1) ); } }
Carl Posted August 22, 2012 Posted August 22, 2012 Hi. To fade out each mc you can just append another tween in your loop like so: function loadTaglines():void { for ( var i:uint = 0; i < xml.length(); i++ ){ var tagline = new mc(); tagline.txt_tagline.text = xml.tagline[i] tagline.x = 816; tagline.y = 47; tagline.scaleX = 4; tagline.scaleY = 4; tagline.alpha = 0; addChild(tagline).name = tagline + i; timeline.append( new TweenLite (tagline, .5, {scaleX:1, scaleY:1, alpha:1}) ); //fade out the tagline .5 seconds after it fades in timeline.append( new TweenLite (tagline, .5, {alpha:0}), .5 ); } } you can restart the timeline with timeline.restart(); If you want the timeline to repeat you should look into using TimelineMax or set up an onComplete callback that will restart it. var timeline:TimelineLite= new TimelineLite({onComplete:replay}); function replay(){ timeline.restart() } If you need to reset the timeline try timeline.clear() please see the docs for other handy methods: http://www.greensock.com/as/docs/tween/com/greensock/TimelineLite.html
jtvalles Posted August 22, 2012 Author Posted August 22, 2012 Thanks Carl. Works like a charm. I love Greensock.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now