| flash mx 2004+xml+asp對菜單的應用 |
|
flash mx 2004+xml+asp對菜單的應用 |
| 作者:佚名 来源:闪吧 作者: 春秋风云 更新:2007-1-13 21:00:55 错误报告 我要投稿 |
說明: 本例是利用flash mx 2004+xml+asp對菜單的添加、刪除、脩改的應用。如果有不妥之處,希望閃吧的朋友們提齣一點建議,我們一起改進並學習,謝謝!

//製作:春秋風雲 //Stage.align = "TL"; //Stage.showMenu=false;// Stage.showMenu = false; Stage.scaleMode = "noBorder"; Stage.scaleMode = "noScale"; // System.useCodepage = true; import mx.controls.Alert; //===================== XmlRepley = new XML(); XmlRepley.onLoad = myRepleyAdd; function myRepleyAdd(success) { trace("sgxg"); if (success) { trace("sgxg"); ModiXML.load("Menu_first.xml"); ModiXML.onLoad = function(success) { if (success) { trace("ModiXML"); //======================================= type_list1.removeAll(); amount = ModiXML.childNodes[1].childNodes.length; for (i=0; i<amount; i++) { //trace(MenuFirstXML.childNodes[1].childNodes[i].attributes.name); names = ModiXML.childNodes[1].childNodes[i].attributes.info; Firstid = ModiXML.childNodes[1].childNodes[i].attributes.FirstId; type_list1.addItem(names, Firstid); } type_list1.text = "Please Select MenuName"; type_list1.rowCount = 3; type_list1.length = 200; //======================================= } }; MenuFirstXML.load("Menu_first.xml"); MenuFirstXML.onLoad = function(success) { if (success) { trace("MenuFirstXML"); //========================================= type_list.removeAll(); amount = MenuFirstXML.childNodes[1].childNodes.length; for (i=0; i<amount; i++) { //trace(MenuFirstXML.childNodes[1].childNodes[i].attributes.name); names = MenuFirstXML.childNodes[1].childNodes[i].attributes.info; Firstid = MenuFirstXML.childNodes[1].childNodes[i].attributes.FirstId; type_list.addItem(names, Firstid); } type_list.text = "Please Select MenuName"; type_list.rowCount = 3; type_list.length = 200; //======================================= //======================================= } }; Alert.show("Add Success!", "Message", Alert.OK); } else { Alert.show("Add Fail!", "Message", Alert.OK); } } //====================================================== //FirstAdd.Label="添加"; //FirstAdd.toggle = true; FirstMenu = new Object(); FirstMenu.click = function(Eve) { //trace("selected "+Eve.target); if (FirstText.text == "") { Alert.show("Please input MenuName!", "Message", Alert.OK); } else { FirstMenuXml = new XML(); //========================================== FirstElement = FirstMenuXml.createElement("FIRSTMENUTEXT"); FirstNode = FirstMenuXml.createTextNode("firstmenutext"); FirstNode.nodeValue = FirstText.text; FirstElement.appendChild(FirstNode); //======================================= FirstMenuXml.appendChild(FirstElement); //trace(FirstMenuXml) FirstMenuXml.sendAndLoad("http://192.168.6.65:8033/Menu/MenuFirstAdd_save.asp", XmlRepley); } }; FirstAdd.addEventListener("click", FirstMenu); //=================================================================================================================== //=================================================================================================================== //=================================================================================================================== //----------------------------------------------------一级文件删除---------------------------------------------------- //=================================================================================================================== //=================================================================================================================== //=================================================================================================================== var FirstId = null; //trace(FirstId); MenuFirstXML = new XML(); //MenuFirstXML.ignoreWhite = true; MenuFirstXML.load("Menu_first.xml"); MenuFirstXML.onLoad = function(success) { if (success) { //trace(MenuFirstXML); amount = MenuFirstXML.childNodes[1].childNodes.length; //trace(amount); for (i=0; i<amount; i++) { //trace(MenuFirstXML.childNodes[1].childNodes[i].attributes.name); names = MenuFirstXML.childNodes[1].childNodes[i].attributes.info; Firstid = MenuFirstXML.childNodes[1].childNodes[i].attributes.FirstId; type_list.addItem(names, Firstid); } type_list.text = "Select MenuName"; type_list.rowCount = 3; //type_list.dropdownWidth= 100; } }; obj = new Object(); obj.change = function() { FirstId = type_list.value; //取得一級菜單的firstId值 trace(FirstId); }; type_list.addEventListener("change", obj); //================================================ RepleyXML = new XML(); RepleyXML.onLoad = myRepley; function myRepley(success) { if (success) { //trace(RepleyXML); MenuFirstXML.load("Menu_first.xml"); MenuFirstXML.onLoad = function(success) { if (success) { //trace(MenuFirstXML); type_list.removeAll(); amount = MenuFirstXML.childNodes[1].childNodes.length; for (i=0; i<amount; i++) { names = MenuFirstXML.childNodes[1].childNodes[i].attributes.info; Firstid = MenuFirstXML.childNodes[1].childNodes[i].attributes.FirstId; type_list.addItem(names, Firstid); } type_list.text = "Select MenuName"; type_list.rowCount = 3; type_list.length = 200; } }; ModiXML.load("Menu_first.xml"); ModiXML.onLoad = function(success) { if (success) { trace("ModiXML"); //======================================= type_list1.removeAll(); amount = ModiXML.childNodes[1].childNodes.length; for (i=0; i<amount; i++) { //trace(MenuFirstXML.childNodes[1].childNodes[i].attributes.name); names = ModiXML.childNodes[1].childNodes[i].attributes.info; Firstid = ModiXML.childNodes[1].childNodes[i].attributes.FirstId; type_list1.addItem(names, Firstid); } type_list1.text = "Please Select MenuName"; type_list1.rowCount = 3; type_list1.length = 200; //======================================= } }; Alert.show("Delete Success!", "Message", Alert.OK); } else { Alert.show("Delete Fail!", "Message", Alert.OK); } } //============ FirstObj = new Object(); FirstObj.click = function() { //trace(FirstId); if (FirstId == null) { Alert.show("Please Select First Menu!", "Message", Alert.OK); } else { MenuFirstXML = new XML(); ElementRoot = MenuFirstXML.createElement("FIRSTMENU"); //================================= ElementFirstId = MenuFirstXML.createElement("FIRSTID"); FirstNode = MenuFirstXML.createTextNode("firstid"); FirstNode.nodeValue = FirstId; ElementFirstId.appendChild(FirstNode); //=========================================== //=========================================== ElementRoot.appendChild(ElementFirstId); MenuFirstXML.appendChild(ElementRoot); //trace(MenuFirstXML); MenuFirstXML.sendAndLoad("http://192.168.6.65:8033/Menu/MenuFirstDel_save.asp", RepleyXML); } }; MenuFirstDel.addEventListener("click", FirstObj); //=================================================================================================================== //=================================================================================================================== //============================================================================================================ //-----------------------------------------------修改一级菜单名称---------------------------------------------- //============================================================================================================ //============================================================================================================ //============================================================================================================ var firstId1 = null; ModiXML = new XML(); //MenuFirstXML.ignoreWhite = true; ModiXML.load("Menu_first.xml"); ModiXML.onLoad = function(success) { if (success) { //trace(MenuFirstXML); amount = ModiXML.childNodes[1].childNodes.length; //trace(amount); for (i=0; i<amount; i++) { //trace(MenuFirstXML.childNodes[1].childNodes[i].attributes.name); names = ModiXML.childNodes[1].childNodes[i].attributes.info; Firstid = ModiXML.childNodes[1].childNodes[i].attributes.FirstId; type_list1.addItem(names, Firstid); } type_list1.text = "Select MenuName"; type_list1.rowCount = 3; //type_list.dropdownWidth= 100; } }; objModi = new Object(); objModi.change = function() { firstId1 = type_list1.value; //取得一級菜單的firstId值 trace(firstId1); }; type_list1.addEventListener("change", objModi); //================================== //================================== ModiXML1 = new XML(); ModiXML1.onLoad = ModiRepley; function ModiRepley(success) { trace("dddddddd"); if (success) { //trace(RepleyXML); MenuFirstXML.load("Menu_first.xml"); MenuFirstXML.onLoad = function(success) { if (success) { //trace(MenuFirstXML); type_list.removeAll(); amount = MenuFirstXML.childNodes[1].childNodes.length; for (i=0; i<amount; i++) { names = MenuFirstXML.childNodes[1].childNodes[i].attributes.info; Firstid = MenuFirstXML.childNodes[1].childNodes[i].attributes.FirstId; type_list.addItem(names, Firstid); } type_list.text = "Select MenuName"; type_list.rowCount = 3; type_list.length = 200; } }; ModiXML.load("Menu_first.xml"); ModiXML.onLoad = function(success) { if (success) { trace("ModiXML"); //======================================= type_list1.removeAll(); amount = ModiXML.childNodes[1].childNodes.length; for (i=0; i<amount; i++) { //trace(MenuFirstXML.childNodes[1].childNodes[i].attributes.name); names = ModiXML.childNodes[1].childNodes[i].attributes.info; Firstid = ModiXML.childNodes[1].childNodes[i].attributes.FirstId; type_list1.addItem(names, Firstid); } type_list1.text = "Please Select MenuName"; type_list1.rowCount = 3; type_list1.length = 200; //======================================= } }; Alert.show("Modify Success!", "Message", Alert.OK); } else { Alert.show("Modify Fail!", "Message", Alert.OK); } } //]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] //==================================== ModiMenu = new Object(); ModiMenu.click = function(Eve) { //trace("selected "+Eve.target); if (firstId1 == null) { Alert.show("Please Select First Menu!", "Message", Alert.OK); return; } if (ModiText.text == "") { Alert.show("Please input MenuName!", "Message", Alert.OK); return; } else { ModiMenuXml = new XML(); ElementRoot = ModiMenuXml.createElement("ModiRoot"); //========================================== //========================================== IdElement = ModiMenuXml.createElement("FIRSTID"); IdNode = ModiMenuXml.createTextNode("idtext"); IdNode.nodeValue = firstId1; IdElement.appendChild(IdNode); //======================================= ModiElement = ModiMenuXml.createElement("FIRSTMENUTEXT"); ModiNode = ModiMenuXml.createTextNode("firstmenutext"); ModiNode.nodeValue = ModiText.text; ModiElement.appendChild(ModiNode); //======================================= ElementRoot.appendChild(IdElement); ElementRoot.appendChild(ModiElement); ModiMenuXml.appendChild(ElementRoot); trace(ModiMenuXml); ModiMenuXml.sendAndLoad("http://192.168.6.65:8033/Menu/MenuFirstModi_save.asp", ModiXML1); } }; MenuFirstMod.addEventListener("click", ModiMenu);
Menu_first.xml文件如下:
<?xml version="1.0" encoding="gb2312" ?> - <MenuFirst bgColor="0x9F9F80" textColor="0x000000" icon="icons/news.jpg" textSize="12" font="verdana" moveSpeed="3" lineHeight="1"> <MenuName FirstId="2" info="My Music" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="3" info="lay" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="6" info="春秋风云" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="7" info="在水一方" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="8" info="光明与黑暗" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="9" info="红与黑" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="10" info="爱屋及乌" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="20" info="东西南北" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="22" info="fsdf" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="23" info="bbb" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="24" info="iii" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="25" info="ccc" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> <MenuName FirstId="26" info="ggg" open="1" bgcolor="0x9F9F80" textSize="20" font="Arial" icon="icons/news.jpg" url="asfunction:myFun,12" targetWindow="rightFrame" /> </MenuFirst> 附上源代碼 (包括ASP源码) 点击浏览该文件
|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |