| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 网页制作 > Flash教程 > Flash特别应用 > 文章正文 用户登录
如何加入透明Flas
为新浪博客添加fl
flashget下载联盟
265联盟:“Flash
新易网络提供100M
龙太极/100m/asp/
无限网络提供50M 
霞光科技50M/Htm/
苏能科技100M/FTP
悠博科技50M/FTP/

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 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。