Jump to content
Search Community

Bring Current Movie Clip In Sequence To Front

Buzzafett test
Moderator Tag

Recommended Posts

Obviously addChild(mc1); works on a single clip, but

how would I bring the current movie clip in the sequence

to the front?

 

Thanks.

 

 

Here's my code.

 

var mcArray:Array = new Array(mc1,mc2,mc3,mc4,mc5);

var timeline:TimelineMax = new TimelineMax({repeat:1});
timeline.insertMultiple (TweenMax.allTo(mcArray, 2, {bezierThrough:[{z:0}, {z:-200}, {z:0}],
orientToBezier:false, ease:Linear.easeNone}, 1));

Link to comment
Share on other sites

Maybe just use an onUpdate on your tween that calls a function that loops through your objects, analyzes their z property, and does setChildIndex() accordingly. You could put them in an array and use sortOn() with their z property (you may need to create generic objects with the data for sortOn() to work - I can't remember)

Link to comment
Share on other sites

Sure. Here's an idea:

 

var mcArray:Array = [mc1,mc2,mc3,mc4,mc5];
var timeline:TimelineMax = new TimelineMax({repeat:1, onUpdate:sortZ});
timeline.insertMultiple (TweenMax.allTo(mcArray, 2, {bezierThrough:[{z:0}, {z:-200}, {z:0}],
orientToBezier:false, ease:Linear.easeNone}, 1));

function sortZ():void {
   var a:Array = mcArray.sortOn("z", Array.NUMERIC);
   var lowestIndex:uint = 0; //use whatever you want here as the base index
   for (var i:int = 0; i < a.length; i++) {
       this.setChildIndex(a[i], lowestIndex + i);
   }
}

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