WalnutTreeFalls
05-27-2010, 06:25 PM
Hi,
The coding below works just fine. However, I am trying to figure out how to loop the aList.addItem listings instead of typing each one out and still have the rest of the code work exactly how it is already programmed.
Here is the code:
aList.addItem({label:"Blue", data:0x0000CC});
aList.addItem({label:"Green", data:0x00CC00});
aList.addItem({label:"Yellow", data:0xFFFF00});
aList.addItem({label:"Orange", data:0xFF6600});
aList.addItem({label:"Black", data:0x000000});
var aBox:MovieClip = new MovieClip();
addChild(aBox);
aList.addEventListener(Event.CHANGE, changeHandler);
function changeHandler(event:Event):void
{
drawBox(aBox, event.target.selectedItem.data);
}
function drawBox(box:MovieClip,color:uint):void
{
box.graphics.beginFill(color, 1.0);
box.graphics.drawRect(235, 150, 100, 100);
box.graphics.endFill();
}
Any ideas?
Thanks,
WalnutTreeFalls
The coding below works just fine. However, I am trying to figure out how to loop the aList.addItem listings instead of typing each one out and still have the rest of the code work exactly how it is already programmed.
Here is the code:
aList.addItem({label:"Blue", data:0x0000CC});
aList.addItem({label:"Green", data:0x00CC00});
aList.addItem({label:"Yellow", data:0xFFFF00});
aList.addItem({label:"Orange", data:0xFF6600});
aList.addItem({label:"Black", data:0x000000});
var aBox:MovieClip = new MovieClip();
addChild(aBox);
aList.addEventListener(Event.CHANGE, changeHandler);
function changeHandler(event:Event):void
{
drawBox(aBox, event.target.selectedItem.data);
}
function drawBox(box:MovieClip,color:uint):void
{
box.graphics.beginFill(color, 1.0);
box.graphics.drawRect(235, 150, 100, 100);
box.graphics.endFill();
}
Any ideas?
Thanks,
WalnutTreeFalls