Hi
I am having set of movieclips, say
mc1,mc2,mc3,mc4 and mc5
I do have the properties for these movieclips as below
mc1.val = 4
mc2.val = 7
mc3.val = 3
mc4.val = 2
mc5.val = 7
I need to know how can i sort these movieclips in ascending order like below based on the variable val .
mc4 , mc3 , mc1 , mc2 , mc5
Regards,
Kameshwaran A.
I am having a set of pages( like the letter pad with same size) that i have created using separate movieclip. I am placing the set of bitmap images in those page template in the sequence which i got as input. User has the option to move the image. Once he is done with that i need to give the reference to next process like which image is placed in which template. But i should not give them in the input sequence. I have to give them in the template sequence. So while placing the image i am giving the template number to each and every movieclip. Also, i am doing the same while moving the image. now i need to give it in the template sequence. Thats y i am asking this option.
kindly let me know if still i am not clear.
What you can do is place them into an array as objects, each defining the mc and its val property, and then use the Array.sortOn method...
mc1.val = 4;
mc2.val = 7;
mc3.val = 3;
mc4.val = 2;
mc5.val = 7;
var mcs:Array = new Array({mc:mc1, val:mc1.val},{mc:mc2, val:mc2.val},{mc:mc3, val:mc3.val},{mc:mc4, val:mc4.val},{mc:mc5, val:mc5.val});
var sortedMCs:Array = mcs.sortOn("val", Array.NUMERIC);
for(i=0;i<sortedMCs.length;i++){
trace(sortedMCs[i].mc)
}
mc1 = _root.createEmptyMovieClip("mc1",_root.getNextHighestDepth());
mc2 = _root.createEmptyMovieClip("mc2",_root.getNextHighestDepth());
mc3 = _root.createEmptyMovieClip("mc3",_root.getNextHighestDepth());
mc4 = _root.createEmptyMovieClip("mc4",_root.getNextHighestDepth());
mc5 = _root.createEmptyMovieClip("mc5",_root.getNextHighestDepth());
mc1.val = 3;
mc2.val = 2;
mc3.val = 1;
mc4.val = 4;
mc5.val = 5;
var mcs:Array = new Array({mc:mc1, val:mc1.val},{mc:mc2, val:mc2.val},{mc:mc3, val:mc3.val},{mc:mc4, val:mc4.val},{mc:mc5, val:mc5.val});
trace(mcs)
var sortedMCs:Array = mcs.sortOn("val", Array.NUMERIC);
for(i=0;i<sortedMCs.length;i++){
trace(sortedMCs[i].mc)
}
When i try with the above code it is not working. kindly let me know what is wrong in the above code.
North America
Europe, Middle East and Africa
Asia Pacific