2007年6月22日 @ 22:57
flex Tree中的拖放
http://www.51as.com/article.asp?id=39
Tree 中的拖放 第一部分
这篇文章是关于如何放叶子节点——或者更确切地说是如何拖放叶子节点的。
因为这是一个有点复杂的主题而blog的文章不应该长达几页,所以我将这个主题分成了几篇文章。我将会讲述在一个Tree控件内的拖放,从一个Tree控件到其他地方的拖放,以及从其他地方到一个Tree控件的拖放。
如果你正在使用一个Tree控件那么你肯定已经确定了使用哪一种类型的数据:XMLListCollection 或者 ArrayCollection(请看Tree 控件的DataProviders,(这篇我已经翻译过了,译注)).不管你使用哪一种Tree的结构都是分等级的。这对XML来说非常理想,而对于ArrayCollections你则需要使用包含ArrayCollections子节点的ArrayCollections来提供这种结构。
我之所以提到这些,是为了让那些以前没有使用过Tree控件的人熟悉一下如何为Tree提供数据。由于我相信多数程序都使用XML作为Tree的数据,所以这些拖放的例子也将使用XML。
在一个Tree内进行拖放
让一个Tree控件允许用户进行拖拽节点来重新排列是非常简单的事情。想一下这样一个文件浏览器,你可以将文件从一个文件夹拖拽到另一个文件夹中。
这样设定你的Tree控件:
程序代码
<mx:Tree x="162" y="122" width="279" height="278"
dataProvider="{treeDataList}"
labelField="@label"
dragEnabled="true"
dragMoveEnabled="true"
dropEnabled="true"
/>
2007年6月6日 @ 20:38
Developing in Trees
If you develop SWF files using Flash or Flex you develop in a tree whether you realize it or not. Trees are the base structure within the Flash Player DisplayList or better named, the DisplayTree. The Tree within the Flash Player 9 using ActionScript 3 starts with the base class of your SWF either inherits from flash.display.Sprite or flash.display.MovieClip classes. These two classes inherit from flash.display.DisplayObjectContainer and thus have methods and logic to adding and removing children.


