我在主机组件上设置了皮肤类,但是它给出了零点异常

时间:2011-04-19 23:56:33

标签: flex

<!--

    ADOBE SYSTEMS INCORPORATED
    Copyright 2008 Adobe Systems Incorporated
    All Rights Reserved.

    NOTICE: Adobe permits you to use, modify, and distribute this file
    in accordance with the terms of the license agreement accompanying it.

-->

<!--- The default skin class for a Spark SkinnableContainer container.  

     @see spark.components.SkinnableContainer

      @langversion 3.0
      @playerversion Flash 10
      @playerversion AIR 1.5
      @productversion Flex 4
-->
<skins:MPLBaseWidgetContainerSkin xmlns:skins="com.directv.mpl.player.chrome.widgets.skins.*" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
                                  xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5" minWidth="9" minHeight="9" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="mplbasewidgetskin1_creationCompleteHandler(event)" xmlns:widgets="com.directv.mpl.player.chrome.widgets.*">
    <fx:Metadata>[HostComponent("com.directv.mpl.player.chrome.widgets.MPLWidgetContainer")]</fx:Metadata>

    <fx:Script fb:purpose="styling">
        <![CDATA[         
            import com.directv.mpl.player.chrome.widgets.MPLStepSliderWidget;
            import com.directv.mpl.player.chrome.widgets.events.MPLSliderEvent;
            import com.directv.mpl.player.metadata.MPLVolumeMetadata;

            import mx.events.FlexEvent;
            /**
             *  @private
             */

            private function updateVolumeChips():void{
                if(metadata){
                    volChip1.alpha = volChip2.alpha = volChip3.alpha = volChip4.alpha = volChip5.alpha = volChip6.alpha = volChip7.alpha = 0;
                    if(!MPLVolumeMetadata(metadata).mute){      
                        var chipIndex:Number = Math.round(MPLVolumeMetadata(metadata).volume / MPLStepSliderWidget.VOLUME_STEP_SIZE);
                        while(chipIndex > 0){
                            this["volChip"+chipIndex].alpha = 1;chipIndex--;
                        }
                    }
                }
            }

            protected function volChip_clickHandler(chipIndex:Number):void
            {
                var evt:MPLSliderEvent = new MPLSliderEvent(MPLSliderEvent.SLIDER_CHANGE);
                evt.chipIndex = chipIndex;
                this.dispatchEvent(evt);
            }


            protected function mplbasewidgetskin1_creationCompleteHandler(event:FlexEvent):void
            {
                this.updateView = updateVolumeChips;
            }

        ]]>        
    </fx:Script>
    <skins:states>
        <s:State name="normal" />
        <s:State name="disabled" />
    </skins:states>


    <widgets:MPLSparkButton id="volumeTrack" width="100%" height="100%"/>
    <s:HGroup gap="1" x="4" y="9">
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip1" click="volChip_clickHandler(1)"/>
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip2" click="volChip_clickHandler(2)"/>
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip3" click="volChip_clickHandler(3)"/>
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip4" click="volChip_clickHandler(4)"/>
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip5" click="volChip_clickHandler(5)"/>
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip6" click="volChip_clickHandler(6)"/>
        <widgets:MPLSparkButton  width="100%" height="100%" id="volChip7" click="volChip_clickHandler(7)"/>
    </s:HGroup>

</skins:MPLBaseWidgetContainerSkin>

TypeError:错误#1009:无法访问空对象引用的属性或方法。     在spark.components.supportClasses :: SkinnableComponent / commitProperties()[E:\ dev \ 4.x \ frameworks \ projects \ spark \ src \ spark \ components \ supportClasses \ SkinnableComponent.as:427]     at com.directv.mpl.player.chrome.widgets :: MPLWidgetContainer / commitProperties()[/ Users / kodaliasha / Documents / Adob​​e Flash Builder 4 / _workspace / MediaPlayerLibrary / includes / core / MPLCoreSkinUpdateInclude.as:178]     在mx.core :: UIComponent / validateProperties()[E:\ dev \ 4.x \ frameworks \ projects \ framework \ src \ mx \ core \ UIComponent.as:7933]     在mx.managers :: LayoutManager / validateProperties()[E:\ dev \ 4.x \ frameworks \ projects \ framework \ src \ mx \ managers \ LayoutManager.as:572]     在mx.managers :: LayoutManager / doPhasedInstantiation()[E:\ dev \ 4.x \ frameworks \ projects \ framework \ src \ mx \ managers \ LayoutManager.as:730]     在mx.managers :: LayoutManager / doPhasedInstantiationCallback()[E:\ dev \ 4.x \ frameworks \ projects \ framework \ src \ mx \ managers \ LayoutManager.as:1072]

1 个答案:

答案 0 :(得分:0)

这些代码都没有显示您的主机组件或设置外观类的位置。

在spark架构中,类由两个类组成;一个是组件类(AKA是主机组件),另一个是皮肤类。你只向我们展示了你的皮肤类。

组件类中的某个位置(类名是com.directv.mpl.player.chrome.widgets.MPLWidgetContainer,基于您提供的代码),您将希望使用skinClass样式为该类提供外观。像这样:

this.setStyle('skinClass',com.directv.mpl.player.chrome.widgets.MPLBaseWidgetContainerSkin);

我通常会在构造函数中添加此代码 - 对于默认外观;虽然我相信也可以通过CSS设置它。