Показать сообщение отдельно
Старый 16.04.2007, 18:04
etc вне форума Посмотреть профиль Найти все сообщения от etc
  № 2  
Ответить с цитированием
etc
Et cetera
 
Аватар для etc

Регистрация: Sep 2002
Сообщений: 30,787
Потому что Tree кушает XMLList.

Код:
<?xml version="1.0" encoding="utf-8"?>
<!-- Tree control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();">

    <mx:Script>
        <![CDATA[
            [Bindable]
            public var selectedNode:XML;
            
            [Bindable]
            public var myData:XMLList;

            // Event handler for the Tree control change event.
            public function treeChanged(event:Event):void {
                selectedNode=Tree(event.target).selectedItem as XML;
            }
            
            private function init():void {
            	var xml:XML = 
            	<index>
            		<node label="Mail Box">
			            <node label="Inbox">
			                <node label="Marketing"/>
			                <node label="Product Management"/>
			                <node label="Personal"/>
			            </node>
			            <node label="Outbox">
                			<node label="Professional"/>
                			<node label="Personal"/>
            			</node>
            			<node label="Spam"/>
            			<node label="Sent"/>
        			</node>
        		</index>;
            	myData = xml.elements();
            }
        ]]>
    </mx:Script>

    <mx:Panel title="Tree Control Example" height="75%" width="75%" 
        paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">

        <mx:Label width="100%" color="blue" 
            text="Select a node in the Tree control."/>

        <mx:HDividedBox width="100%" height="100%">
            <mx:Tree id="myTree" width="50%" height="100%" labelField="@label"
                showRoot="true" dataProvider="{myData}" change="treeChanged(event)"/>
            <mx:TextArea height="100%" width="50%"
                text="Selected Item: {selectedNode.@label}"/>
        </mx:HDividedBox>
        
    </mx:Panel>
</mx:Application>
Цитата:
Сообщение от Help
An object that contains the data to be displayed. When you assign a value to this property, the Tree class handles the source data object as follows:


A String containing valid XML text is converted to an XMLListCollection.
An XMLNode is converted to an XMLListCollection.
An XMLList is converted to an XMLListCollection.
Any object that implements the ICollectionView interface is cast to an ICollectionView.
An Array is converted to an ArrayCollection.
Any other type object is wrapped in an Array with the object as its sole entry.
Можно даже строку запихивать.


Последний раз редактировалось etc; 16.04.2007 в 18:07.