function alignClips(clips:Array, alignment:String, spacing:Number):Void { if (spacing == null) { spacing = 0; } var hori:Boolean = alignment == "horizontal"; var propA:String = hori ? "_x" : "_y"; var propB:String = hori ? "_y" : "_x"; var length:String = hori ? "_width" : "_height"; var value:Number = clips[0][propA]; var i:Number = 0; var n:Number = clips.length; while (i < n) { clips[i][propA] = value; if (i) { clips[i][propB] = clips[i-1][propB]; } value += clips[i++][length] + spacing; }} // Create an array and populate it with the movie clips// that we want to align.var myClips:Array = [mc1, mc2, mc3, mc4]; // Align the movie clips horizontally with 10px spacing.alignClips(myClips, "horizontal", 10); // or.. Align the movie clips vertically with 2px spacing.// alignClips(myClips, "vertical", 5);