Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Buzzafett

Bring Current Movie Clip In Sequence To Front

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 post
Share on other sites

you mean

 

addChild(mcArray[0]);

 

or all array items

 

for (var i:int=0; i<mcArray.length; i++){
   addChild(mcArray[i]);
}

 

is that you looking for??

  • Like 1
Link to post
Share on other sites

Close to what I'm looking for, but how would I bring

the clip forward in a specific order, with an array?

 

var orderArray:Array = new Array(1,2,3,3,4);

Link to post
Share on other sites

Had a look on the Adobe site from your link,

but how would this be written in regards to my code,

bringing the current movie clip to the front in a given

sequence ie. 1,2,3,3,4 instead of 1,2,3,4,5 etc?

Link to post
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 post
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 post
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.

×