今天做一个电子杂志的时候用到了flash的scrollpane组件。经过钻研,把Flash调用XML配合组件的核心程序用最简单的语法整理出来了,简单的例子整合了最关键的语法。

================Tree的外观=======================
myTree.setStyle("indentation",10); //缩进
//myTree.setStyle("backgroundColor", 0xffffcc); //背景色
//myTree.setStyle("rollOverColor", 0xF7EAEA); //鼠标Rollover时的颜色.
//myTree.setStyle("selectionColor", 0xF7EAEA); //鼠标点击的颜色
//myTree.setStyle("disclosureOpenIcon", "mc");
myTree.setStyle("fontFamily", "微软雅黑");
//myTree.setStyle("fontWeight", "bold"); //可识别的值为 normal 和 bold。

//myTree.setStyle("disclosureClosedIcon", "mc"); //这个就是每个有扩展内容的结点前的那个三角形图标.分别对应打开还是关闭
//myTree.setStyle("borderStyle", "none"); //设置没有边框
//tip.setStyle("borderStyle", "none"); //设置没有边框
tip.setStyle("backgroundColor", 0xffffcc); //背景色
myTree.vScrollPolicy = "auto";//这个是设置竖滚动条的显示状态
//myTree.hScrollPolicy = "auto";//这个是设置横滚动条的显示状态

=================my_dg的外观==============================
//my_dg.setSize(140, 100);
//my_dg.rowCount = 5;
//my_dg.vScrollPolicy = "off";
//my_dg._width = 180;
//my_dg.resizableColumns = false;// 不允许调整列大小。

===========================================================
System.useCodepage = true;          //防止乱码
myTreeXML = new XML();              //建立一个xml对象
myTreeXML.ignoreWhite = true;      //忽略其中的空格
myTreeXML.load("xml.xml");        //载入要编辑的xml文件
myTreeXML.onLoad = function(success)
{
    if (success)                    //如果载入成功,为tree组件指定数据源
        {myTree.dataProvider = myTreeXML;}
    else
        {trace("No success!!");}
};

======================监视Tree==========================
myTreeListener = new Object();
myTreeListener.change = function(tree)
{
    var xnode=tree.target.selectedItem;

    //trace(ClickURL);

    //if(xnode.attributes.url != null)  //如果"地址"列为空,就不添加,否则就添加数据
    //{my_dg.addItem({ID:tree.target.selectedIndex,标题:xnode.attributes.label, 地址:xnode.attributes.url});};
    my_dg.addItem({ID:tree.target.selectedIndex,标题:xnode.attributes.label, 地址:xnode.attributes.url});
    trace(tree.target.selectedIndex + " / " + xnode.attributes.label + " / " + xnode.attributes.url);
   
    pic1.contentPath=xnode.attributes.url;//载入图片
    tip.text=tree.target.selectedIndex + " / " + xnode.attributes.label + " / " + xnode.attributes.url
};
myTree.addEventListener("change", myTreeListener);//监听,必须保留   

===============================

System.useCodepage = true;
var view_xml:XML = new XML();
view_xml.ignoreWhite = true;
view_xml.onLoad = function() {
my_mb.dataProvider = this.firstChild;
};
view_xml.load("menu_xml.xml");
var myListener:Object = new Object();
myListener.change = function(evtObj:Object) {
url = evtObj.menuItem.attributes.url;
//getURL(url);
//tip.text=evtObj.menuItem.attributes.label + " / " + url
pic1.contentPath=evtObj.menuItem.attributes.url;//载入图片
tip.text= evtObj.menuItem.attributes.label + " / " + evtObj.menuItem.attributes.url
};
my_mb.addEventListener("change", myListener);