我的漫漫程序之旅
專注于JavaWeb開發
隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
導航
BlogJava
首頁
新隨筆
聯系
管理
<
2009年5月
>
日
一
二
三
四
五
六
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(39)
給我留言
查看公開留言
查看私人留言
隨筆檔案
(43)
2021年12月 (1)
2012年12月 (1)
2012年11月 (1)
2009年11月 (2)
2009年10月 (1)
2009年8月 (1)
2009年7月 (1)
2009年5月 (2)
2009年4月 (2)
2009年3月 (1)
2009年2月 (3)
2009年1月 (1)
2008年12月 (2)
2008年11月 (3)
2008年9月 (2)
2008年8月 (1)
2008年7月 (2)
2008年6月 (2)
2008年5月 (9)
2008年4月 (2)
2007年12月 (3)
文章分類
(304)
AJAX(7)
(rss)
flex3(1)
(rss)
Hibernate(4)
(rss)
J2EE
(rss)
J2ME(2)
(rss)
J2SE(40)
(rss)
JavaScript(59)
(rss)
JavaWeb(27)
(rss)
Java筆試與面試(52)
(rss)
JQuery(1)
(rss)
Maven(2)
(rss)
opensource(15)
(rss)
Spring(10)
(rss)
SSH整合系列(2)
(rss)
Struts1.x(3)
(rss)
Struts2(13)
(rss)
WebService(14)
(rss)
數據庫(18)
(rss)
數據結構與算法(7)
(rss)
設計模式(17)
(rss)
軟件測試(10)
(rss)
文章檔案
(257)
2021年12月 (1)
2012年12月 (2)
2012年9月 (2)
2012年7月 (5)
2012年1月 (1)
2011年10月 (1)
2010年12月 (1)
2009年9月 (2)
2009年7月 (2)
2009年6月 (1)
2009年4月 (3)
2009年3月 (3)
2009年1月 (2)
2008年12月 (4)
2008年11月 (4)
2008年10月 (2)
2008年9月 (2)
2008年8月 (10)
2008年7月 (22)
2008年6月 (13)
2008年5月 (45)
2008年4月 (17)
2008年3月 (5)
2008年2月 (11)
2008年1月 (27)
2007年12月 (45)
2007年11月 (24)
搜索
最新評論
1.?re: 使用MyEclipse構建MAVEN項目
評論內容較長,點擊標題查看
--龍平
2.?re: JDK中的URLConnection參數詳解[未登錄]
好文要頂
--wy
3.?re: Ant path 匹配原則[未登錄]
我喜歡你惠茹
--aaa
4.?re: Ant path 匹配原則[未登錄]
dfdfdfdfd
--aaa
5.?re: 利用jSMSEngine開源包進行短信的收發[未登錄]
qq郵箱
550725115@qq.com
--我是菜鳥
閱讀排行榜
1.?Linux上安裝JDK1.7與Tomcat7.0(24268)
2.?將java應用程序打包成獨立運行的.exe方法(19834)
3.?HttpURLConnection請求數據流的寫入(write)和讀取(read)(19098)
4.?基于jsTree的無限級樹JSON數據的轉換(17631)
5.?javascript文件夾選擇框的兩種解決方案(16935)
評論排行榜
1.?基于jsTree的無限級樹JSON數據的轉換(27)
2.?Flash圖表(FusionChartsV3)的簡單應用 (22)
3.?WEB頁面導出為Word文檔后分頁&橫向打印的方法 (14)
4.?javascript文件夾選擇框的兩種解決方案(10)
5.?[原創]J2ME/J2EE實現用戶登錄交互(9)
Flex 基于數據源的Menu Tree
實現功能:
1.由外部參數flashvars指定數據源的文件位置或render鏈接.
2.在源數據上加href和target屬性來控制打開窗口.
3.可自定義父節點和子節點圖標,不設置采用系統默認
.
直接上源碼:
<?
xml version
=
"
1.0
"
encoding
=
"
utf-8
"
?>
<
mx:Application xmlns:mx
=
"
http://www.adobe.com/2006/mxml
"
fontFamily
=
"
simsun
"
fontSize
=
"
12
"
layout
=
"
absolute
"
creationComplete
=
"
menu.send();
"
width
=
"
242
"
height
=
"
442
"
initialize
=
"
init()
"
>
<
mx:Script
>
<!
[CDATA[
import
mx.controls.Alert;
import
mx.events.ListEvent;
import
mx.collections.ArrayCollection;
import
mx.rpc.events.ResultEvent;
[Bindable]
private
var strUrl:String
=
"
TreeMenus.xml
"
;
[Bindable]
private
var menus:XML;
[Bindable]
[Embed(
"
open.gif
"
)]
public
var openicon:Class;
[Bindable]
[Embed(
"
close.gif
"
)]
public
var closeicon:Class;
[Bindable]
[Embed(
"
leaf.gif
"
)]
public
var leaficon:Class;
private
function init():
void
{
this
.strUrl
=
this
.parameters.url;
}
private
function LoadMenu(event:ResultEvent):
void
{
menus
=
XML(event.result);
var results:XMLList
=
menus.node;
tree1.dataProvider
=
results;
}
//
菜單圖標設置
private
function treeIcon(item:Object):Class
{
var node:XML
=
XML(item);
trace(
'
icon:
'
+
node.@icon);
var str : String
=
node.@icon;
//
已經設置圖標
if
(node.hasOwnProperty(
"
@icon
"
))
{
if
(node.@icon
==
'
openicon
'
)
{
return
openicon;
}
if
(node.@icon
==
'
closeicon
'
)
{
return
closeicon;
}
if
(node.@icon
==
'
leaficon
'
)
{
return
leaficon;
}
}
else
{
//
如果沒定義icon就直接用默認的
if
(
!
tree1.dataDescriptor.isBranch(item))
{
return
tree1.getStyle(
"
defaultLeafIcon
"
);
}
if
(tree1.isItemOpen(item))
{
return
tree1.getStyle(
"
folderOpenIcon
"
);
}
else
{
return
tree1.getStyle(
"
folderClosedIcon
"
);
}
}
return
null
;
}
/** */
/**
* 菜單樹單項點擊事件
*
*/
private
function itemClickHandler(evt:ListEvent):
void
{
var item:Object
=
Tree(evt.currentTarget).selectedItem;
if
(tree1.dataDescriptor.isBranch(item))
{
//
tree1.expandItem(item, !groupTree.isItemOpen(item), true);
}
else
{
//
得到節點對象
var node:XML
=
XML(item);
//
如果有屬性href
if
(node.hasOwnProperty(
"
@href
"
)
&&
node.hasOwnProperty(
"
@target
"
))
{
openURL(node.@href,node.@target);
}
if
(node.hasOwnProperty(
"
@href
"
)
&&
(node.hasOwnProperty(
"
@target
"
)
==
false
))
{
//
沒有指定target默認在新窗口中打開
openURL(node.@href,
"
_blank
"
);
}
}
}
//
頁面跳轉的方法
private
function openURL(url:String ,target:String):
void
{
var request:URLRequest
=
new
URLRequest(url);
navigateToURL(request,target);
}
]]
>
</
mx:Script
>
<
mx:HTTPService url
=
"
{strUrl}
"
id
=
"
menu
"
useProxy
=
"
false
"
showBusyCursor
=
"
true
"
result
=
"
LoadMenu(event)
"
resultFormat
=
"
xml
"
/>
<
mx:Tree iconFunction
=
"
treeIcon
"
id
=
"
tree1
"
width
=
"
100%
"
height
=
"
100%
"
labelField
=
"
@label
"
itemClick
=
"
itemClickHandler(event)
"
/>
</
mx:Application
>
調用的時候在flashvars里面加上url=xxx
<
object
classid
="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id
="tree"
width
="242"
height
="442"
codebase
="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"
>
<
param
name
="movie"
value
="${ctx}/js/as/menu.swf"
/>
<
param
name
="quality"
value
="high"
/>
<
param
name
="bgcolor"
value
="#869ca7"
/>
<
param
name
="allowScriptAccess"
value
="sameDomain"
/>
<!--
指定菜單的數據源
-->
<
param
name
="flashvars"
value
="url=${ctx}/user/user!renderMenu.do?id=${user.usid}"
/>
<
embed
src
="tree.swf"
quality
="high"
bgcolor
="#869ca7"
width
="242"
height
="442"
name
="tree"
align
="middle"
play
="true"
loop
="false"
quality
="high"
allowScriptAccess
="sameDomain"
type
="application/x-shockwave-flash"
pluginspage
="http://www.adobe.com/go/getflashplayer"
>
</
embed
>
</
object
>
其中url可以指定xml文件的位置或者render的鏈接
示例文件xml:
<?
xml version='1.0' encoding='utf-8'
?>
<
menus
>
<
node
label
='系統管理'
icon
="openicon"
>
<
node
label
='用戶管理'
icon
="closeicon"
href
='/main/user/user-list.jsp'
target
='mainFrame'
/>
<
node
label
='權限管理'
href
='/main/user/action-list.jsp'
target
='mainFrame'
/>
<
node
label
='角色管理'
href
='/main/user/role-list.jsp'
target
='mainFrame'
/>
<
node
label
='域管理'
href
='/main/user/user-list.jsp'
target
='mainFrame'
/>
<
node
label
='測試'>
<node label
='sub
folder' href
=''
target
='mainFrame'
/>
</
node
>
</
node
>
<
node
label
='客服'>
<node label
='終端信息查詢'
href
=''
target
='mainFrame'
/>
<
node
label
='客服問題-解答記錄'
href
=''
target
='mainFrame'
/>
</
node
>
</
menus
>
源碼下載
posted on 2009-05-07 17:34
々上善若水々
閱讀(2333)
評論(2)
編輯
收藏
評論
#
re: Flex 基于數據源的Menu Tree
回復
更多評論
恩
2009-05-08 10:19 |
張氏兄弟
#
re: Flex 基于數據源的Menu Tree
回復
更多評論
請問一下,這里的Object聲明部分應該加在哪里?什么文件的里面?
還有“調用的時候在flashvars里面加上url=xxx”是什么意思? <param name="flashvars url=xxx" value="url=${ctx}/user/user!renderMenu.do?id=${user.usid}" /> 這樣嗎?
2011-03-21 21:45 |
xyza
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © 々上善若水々
主站蜘蛛池模板:
扎兰屯市
|
城口县
|
米易县
|
黔江区
|
礼泉县
|
海口市
|
迁安市
|
宝应县
|
中江县
|
广南县
|
岢岚县
|
牙克石市
|
上高县
|
永春县
|
青阳县
|
九江县
|
长丰县
|
龙口市
|
绥化市
|
通州区
|
达孜县
|
新干县
|
舟曲县
|
舞阳县
|
星座
|
玉门市
|
祁门县
|
碌曲县
|
肥东县
|
曲松县
|
朔州市
|
化州市
|
阿图什市
|
武冈市
|
吴堡县
|
女性
|
保德县
|
安达市
|
静乐县
|
万全县
|
顺昌县
|