CLICK HERE FOR LIVE DEMONSTRATION OF THE TUTORIAL FINAL RESULT
DOWNLOAD THE SOURCE FLA FILE
DOWNLOAD THIS TUTORIAL TO YOUR HARD DRIVE
HERE IS THE SOURCE CODE!
//by AVRAHAM SALTOUN
// solutions at say-web dot com
// FREE TO USE AND DISTRIBUTE
var MagicAccessories:Array=
[Book1_mc, Book2_mc, Book3_mc, Scroll1_mc, Scroll2_mc, Scroll3_mc];
// We created an ARRAY that contains
// Movie Clips, Books and Scrolls
// now let’s sort…
function SortAccessories(event:MouseEvent):void
{
var instanceName:String;
// This variable will store the item name
// to check if it is a scroll or a book
for (var i:uint=0; i < MagicAccessories.length; i++)
// Lenght is a property
// that tells how many items
// store in the array
{
instanceName = MagicAccessories[i].name;
//this will store the accessory name
// to check if it is a book or scroll
if (instanceName.indexOf(“Scroll”)!=-1)
{
MagicAccessories[i].x = 30;
MagicAccessories[i].y = 30;
}
else
{
MagicAccessories[i].x = 600;
MagicAccessories[i].y = 30
}
}
}
sort_btn.addEventListener(MouseEvent.CLICK, SortAccessories);
// This will set the compiler waiting for a mouse click






Tue, Aug 25, 2009
ActionScript