Компоненты Flex во время выполнения - PullRequest
0 голосов
/ 18 февраля 2010
<mx:Repeater id="rep" dataProvider="{headingData.component}">
        <mx:HBox id="panel" label="{rep.currentItem.title}" 
width="100%" height="100%">
        </mx:HBox>
    </mx:Repeater>

protected function creationCompleteHandler():void
            {
                //Alert.show("init2");
                var components:Array = getComponentsFromXML(xml.component);
                var i:int = 0;
                var n:int = components.length;
                for (i; i < n; i++)
                {
                    panel.addChild(components[i] as DisplayObject);
                }
            }

Когда я не помещаю его в тег повторителя, компоненты создаются из XML, но если я это делаю, то компоненты не создаются.

Любые вопросы.

<components type="array">
    <component type="mx.controls::ComboBox" title="Title One" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." width="230" height="220">
                <link linkname="Option one"/>
                <link linkname="Option Two"/>       
    </component>

    <component type="mx.controls::RadioButton" title="Title Two" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.">
                <link linkname="Option one"/>
                <link linkname="Option Two"/>
    </component>

    <component type="mx.controls::RadioButton" title="Title Three" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.">
                <link linkname="Option one"/>

    </component>

    <component type="mx.controls::CheckBox" title="Title Four" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." height="220">
                <link linkname="Option one"/>
                <link linkname="Option Two"/>
                <link linkname="Option Three"/>

    </component>

    <component type="mx.controls::RadioButton" title="Title Five" width="230" description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." height="220">
                <link linkname="Option one"/>
                <link linkname="Option Two"/>
                <link linkname="Option Three"/>
    </component>


</components>

Ответы [ 2 ]

1 голос
/ 18 февраля 2010

Хорошо, проблема в том, что id='panel' внутри повторителя работает немного иначе, чем обычно. Поскольку эти компоненты могут повторяться, если вы можете просто установить идентификатор, он будет одинаковым для всех из них. Вот почему имя (в вашем случае panel) на самом деле является массивом (в данном случае массивом HBoxes).

Если вы хотите добавить дочерний элемент к первому, вам нужно выбрать первый элемент массива -

 panel[0].addChild(components[i] as DisplayObject);
0 голосов
/ 18 февраля 2010

Вам нужно много HBox или много компонентов в нем? Обычно Repeater не используется для вложенных вещей, как в вашем примере. Кроме того, вы не должны устанавливать свойство «id» дочернего элемента вашего репитера. Если вам нужен сложный компонент, вы должны наследовать его от HBox и вставить в него этот код as3.

Возможно, вы должны обернуть репитер в HBox. Тогда вы не должны добавлять свои элементы в панель. Они должны быть указаны в dataProvider.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...