AS3 List Menu Class

by tahadaf

Update made on 28 June, 2009: Every item can has its own style for color, font, etc. http://emstris.com/sample/AS3/listMenu/

AS3 List Menu Class

What Is It?

This AS3 class will help create list of items in flash easilly and fast. as you see in the preview, you can even have thumbnails for every. all colors and sizes are set dynamically when calling the class.

you can also feed the class with XML ! why not :)

it’s a perfect OOP class which you can easilly implement anything into it as an example you can add scrollbars into it. you can use your own version of scrollbar or mine (samples and more information on how to work with scrollbars are included)

to give you a preview on how you’ll use the class to create new instances of menus read below.


// initialize the list
myList = new MyFlashLabListMenu();
myList.w = 200; // width of the menu
myList.floorHeight = 20; // height of each item
myList.floors = 5; //not necessary when no scroller

// set style for the menu
var itemBg: Object = {colorA: 0xCCCCCC, colorB: 0xFFFFFF, thickness:1, strokeColor: 0xCCCCCC, curve:15};
var itemOver: Object = {colorA: 0xAAAAAA, colorB: 0xEEEEEE, thickness:1, strokeColor: 0xAAAAAA, curve:15};
var itemSelected: Object = {colorA: 0x999999, colorB: 0xBBBBBB, thickness:1, strokeColor: 0x999999, curve:15};
var labelStyle: Object = {size:10, color: 0x333333, fontName:"Verdana"};

var styleObject: Object = {itemBg:itemBg, itemOver:itemOver, itemSelected:itemSelected, labelStyle:labelStyle};
myList.itemStyle = styleObject;

// add items to the list
// every item has three 'Optional' parameters, label, value, Thumbnail address
myList.add("Item number 0", "00", "00.png");
myList.add("Item number 1", "01", "01.png");
myList.add("Item number 2", "02", "02.png");
myList.add("Item number 3", "03", "03.png");
myList.add("Item number 4", "04", "04.png");
myList.add("Item number 5", "05", "05.png");
myList.add("Item number 6", "06", "06.png");

// add listeners to interact with the menu
myList.addEventListener(ListMenuEvents.CHANGE, onMenuChange);

// [OPTIONAL] set the default selected index
myList.defaultItem = 1;

// add the list to anywhere you like
this.addChild(myList);

Technologies being used

  • Image smoothing when thumbs get loaded so when they are resized they won’t look disordered.
  • Intelligent image resizng. I wrote a carefull class to resize any given movieclip to your desired size without stretching the movieclip you just have to give a max width and height and all different targets will get resized nicely, this algurithm has been used here to resize the thumbnails when necessary.
  • Perfect OOP class with custome listeners. you will never have to open the class files to use the menu! just create new instances and use the listeners to interact with it.

*

My Suggestions

Although you can use your own scrollbars, I suggest using my version as you will surely find it handy and useful for ALL of your projects :) Scrollbar Class

Regards,
Hadi

P.S Give me a rating if you think this file is helpful

$8

Prepaid customers
pay just $6 - how? Prepay Your Account With our deposit system not only will purchasing be much faster, but we’ll also take $2 off the price! Find Out More Price

You must sign in or sign up to purchase this item.

Purchase 19 purchases

File Types Included
Flash CS3 (9+)
Item Attributes
Created 27 June 09
Published Size 13kb
Opens With Flash CS3 (9+)
Resolution Resizable
ActionScript Version AS3
Documentation Well Documented
Flash Files Included N/A
Collections that include this item