Actionscript 3 在HGroup的新类中调用可能未定义的函数updateDisplayList?

Actionscript 3 在HGroup的新类中调用可能未定义的函数updateDisplayList?,actionscript-3,apache-flex,flex4.5,Actionscript 3,Apache Flex,Flex4.5,super.updateDisplayList(unscaledWidth、unscaledHeight) 为什么抛出“调用可能未定义的函数updateDisplayList” 在Spark中,“s:HGroup”不再是类似于“HBox”的显示对象。仅可用于布局和分组。因此,HGroup上无法更新任何背景色或其他内容 因此,它内部没有updateDisplayList()方法 我建议将您的组件封装在SkinableContainer中,并使用以下“解决方法”(以防您仍然希望使用spark) 阿

super.updateDisplayList(unscaledWidth、unscaledHeight)

  • 为什么抛出“调用可能未定义的函数updateDisplayList”

  • 在Spark中,“s:HGroup”不再是类似于“HBox”的显示对象。仅可用于布局和分组。因此,HGroup上无法更新任何背景色或其他内容

    因此,它内部没有updateDisplayList()方法

    我建议将您的组件封装在SkinableContainer中,并使用以下“解决方法”(以防您仍然希望使用spark)


    阿德里安·皮瓦雷斯库所说的大部分都是不真实的。HGroup也是一个DisplayObject,最重要的是,它也是一个UIComponent,就像它不推荐使用的对应项HBox一样。因此,它有updateDisplayList方法


    您收到的警告似乎是Flash Builder中的一个bug,在尝试调用任何超级保护方法时出现。虽然它不会影响实际的编译器,并且应用程序仍然可以工作,但它确实会在文件中显示一个恼人的黄色警告。我还没有找到解决方案。

    我需要正确扩展HGroup,以便内部的所有控件在调整组的大小时固定它们的位置。呃,HGroup已经自动执行此操作了?您是对的,但是如果我删除x0 y0处的super.updateDisplayList所有childs colapse,就像它不是HGroup一样。这就是为什么我认为覆盖updateDisplayList是必须的。那么不覆盖updateDisplayList?我不明白你想通过改变这个来做什么。
    <?xml version="1.0" encoding="utf-8"?>
    <s:HGroup xmlns:fx="http://ns.adobe.com/mxml/2009" 
              xmlns:s="library://ns.adobe.com/flex/spark" 
              xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
    
                override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number ) : void
                {
                    super.updateDisplayList( unscaledWidth, unscaledHeight );
                }
    
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
    </s:HGroup>
    
    <?xml version="1.0" encoding="utf-8"?>
    <s:SkinnableContainer
              xmlns:fx="http://ns.adobe.com/mxml/2009" 
              xmlns:s="library://ns.adobe.com/flex/spark" 
              xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
    <s:HGroup width="100%" height="100%" >
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
    
                override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number ) : void
                {
                    super.updateDisplayList( unscaledWidth, unscaledHeight );
                }
    
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
    </s:HGroup>
    </s:SkinnableContainer>