Halo中的Panel标题栏右侧有status,Spark却去掉了。我们可以扩展spark.components.Panel把status再加上。
public class StatusPanel extends Panel
{
//----------------------------------
// statusField
//----------------------------------
[SkinPart(required="false")]
/**
* The skin part that defines the appearance of the
* title text in the container.
*
* @see spark.skins.spark.PanelSkin
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion Flex 4
*/
public var statusDisplay:IDisplayText;
public function StatusPanel()
{
super();
}
//----------------------------------
// status
//----------------------------------
/**
* @private
*/
private var _status:String = "";
/**
* @private
*/
private var statusChanged:Boolean;
[Bindable]
[Inspectable(category="General", defaultValue="")]
/**
* Title or caption displayed in the title bar.
*
* @default ""
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion Flex 4
*/
public function get status():String
{
return _status;
}
/**
* @private
*/
public function set status(value:String):void
{
_status = value;
if (statusDisplay)
statusDisplay.text = status;
}
/**
* @private
*/
override protected function partAdded(partName:String, instance:Object):void
{
super.partAdded(partName, instance);
if(instance == statusDisplay)
{
statusDisplay.text = status;
}
}
}
使用时只需要给status属性赋值即可,其他不变。
<view:StatusPanel id="mPanel" title="标题" status="副标题" skinClass="YourPanelSkin" />