Gabums Posted April 10, 2012 Posted April 10, 2012 Hello all, I'm trying to add multiple images to a blank movie clip on my stage using the addChild method in an array. After many hours I got it almost working. The only problem now is that all of my arrayed images tween at the same time. They don't stagger. Is there any way to take the code that I have done and have each image tween, then the next, and so forth? I also need the timeline to repeat indefinately after all arrayed images have finished (which is why I have nested timelines). Thank you! var myTimelineCardMain:TimelineMax = new TimelineMax({repeat:-1}); var sArray:Array = [] var imgBD:BitmapData=new card_28(315,355); var card1:Bitmap=new Bitmap(imgBD); card1.x = -315; card1.y = -355; var img1BD:BitmapData=new card_21(315,355); var card2:Bitmap=new Bitmap(img1BD); card2.x = -315; card2.y = -355; sArray.push(card1,card2); for(var i:int = 0; i < sArray.length; i++) { card_main.addChild(sArray[i]); } var myTimelineCard:TimelineLite = new TimelineLite(); myTimelineCard.insertMultiple([new TweenLite(card_main, 0, {y:467, x:920}), new TweenLite(card_main, 3, {rotation:-9, ease:Back.easeOut}), new TweenLite(card_main, 3, {delay:3, rotation:200, ease:Back.easeOut})], 0, "sequence"); myTimelineCardMain.insertMultiple([myTimelineCard], 0, TweenAlign.SEQUENCE, 3);
Carl Posted April 11, 2012 Posted April 11, 2012 the main reason why your cards aren't staggering is because you are only tweening one object which is card_main. from what I can tell, card_main holds card1 and card2. also I really think you want to create myTimelineCard timelines for EACH card and then insert each timeline into myTimelineCardMain. in order to do that you should probably create your child timelines inside the loop that is already in place that adds card1 and card2 to card_main. I can't be certain this code will work, but you need to do something more like: for(var i:int = 0; i < sArray.length; i++) { card_main.addChild(sArray[i]); //create new timeline for sArray[i] var myTimelineCard:TimelineLite = new TimelineLite(); myTimelineCard.insertMultiple([ new TweenLite(sArray[i], 0, {y:467, x:920}), new TweenLite(sArray[i], 3, {rotation:-9, ease:Back.easeOut}), new TweenLite(sArray[i], 3, {delay:3, rotation:200, ease:Back.easeOut})], 0, "sequence"); //add sub-timeline to main timeline myTimelineCardMain.append(myTimelineCard); } //end loop
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