ActionScript 3.0 Lesson 21: Sorting Movie Clip Symbols with Array and Loop

Tue, Aug 25, 2009

ActionScript

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!

//Sorting Movie Clip Symbols with an Array and Loop
//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

Related Articles:

, , , , , , , , , , , , , , , ,

Leave a Reply

You must be logged in to post a comment.

My name is Avraham Saltoun, and I live in Jerusalem, Middle East. I am currently on my mid  40's and I am a computer programming technician. Here you will find over one hundred quality video tutorials on Actionscript, and yes, I give online support for aspiring programmers, and pros as well, sharing screen on skype and delivering source code by email, click the button for live flash actionscript support now!

 
oDesk Certified Action Script Programmer
oDesk Certified Adobe Flash CS3 Designer
oDesk Certified Adobe Photoshop 6.0 Designer
Skype Me™!

$7.49 .Com! Score Savings Cartoon Smart Tutorials


1,260
Unique Visitors
Previous 30 Days
Powered By Google Analytics