错误#2007:参数antiAliasType必须为非null

时间:2011-12-22 14:43:16

标签: flash flex actionscript itemrenderer

我在ItemRenderer中收到此奇怪的错误消息。我不知道出了什么问题??? 请帮忙!

TypeError:错误#2007:参数antiAliasType必须为非null。     在flash.text :: TextField / set antiAliasType()

package xxx
{
    import spark.components.LabelItemRenderer;
    import spark.components.supportClasses.StyleableTextField;

    public class NewsItemRenderer extends LabelItemRenderer
    {

        private var date:StyleableTextField;
        private var title:StyleableTextField;

        public function NewsItemRenderer()
        {
            super();
            super.styleName = "NewsItemRenderer";
        }

        override protected function createChildren():void {
            date = StyleableTextField(createInFontContext(StyleableTextField));
            date.editable = false;
            date.selectable = false;
            date.styleName = "newsItemDate";
            date.width = 200;
            date.height = 20;
            date.styleDeclaration = styleManager.getMergedStyleDeclaration(".newsItemDate");
            addChild(date);
            date.commitStyles();

            title = StyleableTextField(createInFontContext(StyleableTextField));
            title.editable = false;
            title.selectable = false;
            title.styleName = "newsItemTitle";
            title.width = 200;
            title.height = 60;
            title.styleDeclaration = styleManager.getMergedStyleDeclaration(".newsItemTitle");
            addChild(title);
            title.commitStyles();
        }

        override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.layoutContents(unscaledWidth, unscaledHeight);
            // Hide the default label display
            if (labelDisplay) { 
                labelDisplay.visible = false;
            }
            setElementPosition(date, 5, 5);
            setElementPosition(title, 5, 20);
            setElementSize(date, measuredWidth, 20);
            setElementSize(title, measuredWidth, 60);
        }

        override protected function drawBackground(unscaledWidth:Number, 
                                          unscaledHeight:Number):void
        {
            // nada -> transparent
        }

        override protected function measure():void
        {
            measuredHeight = 80;
            measuredWidth = 300;
            measuredMinWidth = 200;
            measuredMinHeight = measuredHeight;
        }

        override public function set data(value:Object):void
        {
            trace(value);
            super.data = value;
            if(value != null)
            {
                var xml:XML = XML(value);
                date.text = xml.@pubDate[0];
                title.text = xml.@title[0];
            }
        }
    }
}

   TypeError: Error #2007: Parameter antiAliasType must be non-null.
            at flash.text::TextField/set antiAliasType()
            at spark.components.supportClasses::StyleableTextField/commitStyles()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableTextField.as:1068]
            at xxx::NewsItemRenderer/createChildren()[C:\workspaces\flexm\FlexMobile\src\xxx\NewsItemRenderer.as:27]
            at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7634]
            at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7495]
            at mx.core::UIComponent/addChild()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7176]
            at spark.components::DataGroup/initializeTypicalItem()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\DataGroup.as:326]
            at spark.components::DataGroup/ensureTypicalLayoutElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\DataGroup.as:384]
            at spark.components::DataGroup/measure()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\DataGroup.as:1467]
            at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::measureSizes()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8506]
            at mx.core::UIComponent/validateSize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8430]
            at mx.managers::LayoutManager/validateSize()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:665]
            at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:816]
            at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]

.newsItemDate {
    color: black;
    fontSize: 20;
    fontWeight: normal;
}
.newsItemTitle {
    color: white;
    fontSize: 20;
    fontWeight: normal;
}

1 个答案:

答案 0 :(得分:0)

date.styleName = this; 
title.styleName = this;

这解决了我的问题