在覆盖updateDisplayList方法中使用 图标的经典写法

 

			
			var popUpIcon:IFlexDisplayObject =
				IFlexDisplayObject(getChildByName("popUpIcon"));
			
			if (!popUpIcon)
			{
				var popUpIconClass:Class = Class(getStyle("popUpIcon"));
				popUpIcon = new popUpIconClass();
				DisplayObject(popUpIcon).name = "popUpIcon";
				addChild(DisplayObject(popUpIcon));
				DisplayObject(popUpIcon).visible = true;			
			}
			
			popUpIcon.move((w - popUpIcon.width) / 2, (h - popUpIcon.height) / 2);
			

 

 

CSS

 

PopUpArrow
{
	cornerRadius: 0;
	upSkin: ClassReference("com.ztesoft.zsmart.corelib.skins.PopUpArrowSkin");
	downSkin: ClassReference("com.ztesoft.zsmart.corelib.skins.PopUpArrowSkin");
	overSkin: ClassReference("com.ztesoft.zsmart.corelib.skins.PopUpArrowSkin");
	disabledSkin: ClassReference("com.ztesoft.zsmart.corelib.skins.PopUpArrowSkin");
	popUpIcon: ClassReference("com.ztesoft.zsmart.corelib.skins.PopUpIconSkin");
}

 

 

PopUpIconSkin

 

package com.ztesoft.zsmart.corelib.skins
{

import flash.display.Graphics;
import mx.core.mx_internal;
import mx.skins.ProgrammaticSkin;

/**
 * The skin for all the states of the icon in a PopUpButton
 * 
 */
public class PopUpIconSkin extends ProgrammaticSkin
{
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor	 
     */
    public function PopUpIconSkin()
    {
        super();             
    }
    
    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    mx_internal var arrowColor:uint = 0x111111;    

    //--------------------------------------------------------------------------
    //
    //  Overridden properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
	//  measuredWidth
    //----------------------------------
    
    /**
     *  @private
     */    
    override public function get measuredWidth():Number
    {
        return 7;
    }
    
    //----------------------------------
	//  measuredHeight
    //----------------------------------
    
    /**
     *  @private
     */        
    override public function get measuredHeight():Number
    {
        return 5;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */    
	override protected function updateDisplayList(w:Number, h:Number):void
    {
		super.updateDisplayList(w, h);

        var g:Graphics = graphics;

        g.clear();
        g.beginFill(mx_internal::arrowColor);
        g.moveTo(w / 2, height);
        g.lineTo(0, 0);
        g.lineTo(w, 0);
        g.lineTo(w / 2, h);
        g.endFill();
    }
}

}
 

 

你可能感兴趣的:(display)