【问题标题】:Flex 3 Accessing IncludeInLayout in Component InstanceFlex 3 在组件实例中访问 IncludeInLayout
【发布时间】:2010-09-06 02:47:56
【问题描述】:

我有一个关于在组件实例中使用 includeInLayout 的 Flex 3 问题。

所以,为了访问我的组件的实例,我使用了这样的东西:

var _myCard:Card = this["card"+cardNum];

我想“关闭”组件中的数据网格,所以我在“includeInLayout”和“visible”上使用了绑定:

if(myArray.length == 0){
       _myCard.myBoolean = false;  
       _myCardInstance.myBoolean = false;
    }

这很好用。 dataGrid 不可见。但是,我想知道为什么我不能直接访问 includeInLayout 和 visible 属性。为什么我做不到:

_myCard.myGrid.visible = false;   
_myCard.myGrid.includeInLayout = false;

有没有办法在没有绑定的情况下做到这一点?绑定很好。我只是不明白为什么上述方法不起作用。我正在努力学习。

我的缩短组件如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel 
    xmlns:mx="http://www.adobe.com/2006/mxml"  layout="absolute" 
    width="500"
    height="400">



    <mx:Script>
        <![CDATA[

        import mx.collections.ArrayCollection;

        [Bindable]
        public var myBoolean: Boolean = true;

        ]]>
    </mx:Script>



        <mx:Text text="My Text" textAlign="center"/>

        <mx:DataGrid  id="myGrid"    
            y="200"
            dataProvider="{myInitGrid}"
            includeInLayout="{myBoolean}"
            visible="{myBoolean}">

            <mx:columns>
                <mx:DataGridColumn dataField="TopicA" headerText="Topic A" width="130"  textAlign="center" />
                <mx:DataGridColumn dataField="TopicB" headerText="Topic B"  width="130"  textAlign="center" />                  
            </mx:columns>
        </mx:DataGrid>

</mx:Panel>

谢谢!

-拉克西米迪

【问题讨论】:

    标签: flex3 components instance


    【解决方案1】:

    myGrid.includeInLayout=false; 有什么问题?

    它是一个可读写的property

    【讨论】:

    • 嗨,尤金,感谢您的留言。 myGrid 在组件中,因此在主应用程序中不起作用。
    • 这是什么意思?你能展示你的最终代码吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    • 2018-09-08
    • 2020-05-28
    相关资源
    最近更新 更多