Creating an Item Renderer : Controls « Graphics « Flash / Flex / ActionScript






Creating an Item Renderer

 
package
{
    import flash.display.Sprite;
    import flash.text.TextField;
    public class Main extends Sprite
    {
        private var array:Array = ["one", "two", "three", "four", "five"];
    
        public function Main()
        {
            super();
            for(var i:int = 0; i < array.length; i++)
            {
                var spr:Sprite = new Sprite();
    
                spr.graphics.beginFill(0x880088, 1);
                spr.graphics.drawRect(0, 0, 100, 30);
                spr.graphics.endFill();
    
                var txt:TextField = new TextField();
    
                txt.text = String(array[i]);
    
                spr.addChild(txt);
    
                addChild(spr);
    
                spr.y = i * 32;
            }
        }
    }
}

        








Related examples in the same category

1.Volume Control
2.Panel Control
3.Draw the Play/Pause graphic