惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - goodvify

电费查询网_电费网上查询 气候数据订制 天气后报 第二架遥控飞机又飞丢了,囧! 外贸业务可以分为多个工作阶段来管理 也许许多企业管理软件的设计出发点就错了 在Linux下的绘流程图工具yEd “学而不思则罔,思而不学则殆”在实施工作中的思考 Ubuntu Server安装 准备测试使用Ubuntu的Server版 不使用“DataSourceControl DataSource”的情况下如何分页和排序 [转]利用.NET中的反射机制实现IList到DataTable的转换 [转]PetShop 4架构分析 VS2008 快捷键大全 ASP.NET2.0网页的生命周期 MySql远程连接的问题 vc7中的ClassWizard [javascript]判断email地址的有效性 Windows Socket API函数解说
在Flex中用xml做数据源的界面操作的测试
goodvify · 2010-02-20 · via 博客园 - goodvify

主要解决:

1、xml外部数据的引用,可以用固定xml文件编写测试,之后可以用webservices引用后台数据。

2、对xml数据和界面控件的绑定和操作。

数据源,同在src目录下

data/invoices.xml内容:

<?xml version="1.0"?>
<invoices>
  <invoice>
    <customer>
      <firstname>Maria</firstname>
      <lastname>Smith</lastname>
    </customer>
    <items>
      <lineitem price="21.41" quantity="4">Widget</lineitem>
      <lineitem price="2.11" quantity="14">Mouse</lineitem>
      <lineitem price="8.88" quantity="3">Wrench</lineitem>
    </items>
  </invoice>
  <invoice>
    <customer>
      <firstname>John</firstname>
      <lastname>Jones</lastname>
    </customer>
    <items>
      <lineitem price="7.41" quantity="84">Mouse</lineitem>
      <lineitem price="0.91" quantity="184">Mousepad</lineitem>
    </items>
  </invoice>
</invoices>

--------------------------------------------

界面操作程序

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="intoApp()">
 <mx:Button x="46" y="32" label="getxml"  click="show()"/>
 <mx:Script>
  <![CDATA[
   import mx.collections.XMLListCollection;
  
   import mx.rpc.events.ResultEvent;
   [Bindable]
   private var testxml:XML;
   
   [Bindable]
   private var myx:XML=<customer><firstname></firstname><lastname></lastname></customer>;
   
   [Bindable]
   private var customer:XMLListCollection;
   
   private function intoApp():void{

    xml1.send();//引入外部xml文件
    
   }
   
   private function resultHandle(event:ResultEvent):void{
    testxml=event.result as XML;
   }
   private function show():void{
    //showxml.text=testxml.toString();
    customer=new XMLListCollection(testxml..customer);
    showxml.text=customer.toString();
   }
   private function rxml():void{
    showxml.text=testxml.toString();
   }
   private function add():void{
    
    if (myx.firstname!="") {
    customer.addItem(myx.copy());
    }
   }
   private function del():void{
    if (showgrid.selectedIndex!=-1) {
    customer.removeItemAt(showgrid.selectedIndex);
    }
   }
  ]]>
 </mx:Script>
 
 <mx:HTTPService id="xml1" url="data/invoices.xml" resultFormat="e4x" result="resultHandle(event)"/>
 <mx:TextArea height="182" width="649" id="showxml" right="10" top="43"/>
 <mx:DataGrid id="showgrid" x="46" y="257" dataProvider="{customer}" editable="true">
  <mx:columns>
   <mx:DataGridColumn headerText="FirstName" dataField="firstname" />
   <mx:DataGridColumn headerText="LastName" dataField="lastname"/>
   
  </mx:columns>
 </mx:DataGrid>
 <mx:Button x="46" y="78" label="regetxml" id="bt2" click="{rxml()}"/>
 <mx:TextInput x="319" y="289" text="{testxml.invoice[0].customer[0].firstname}"  id="mytxt">
  <mx:focusOut>testxml.invoice[0].customer[0].firstname=mytxt.text</mx:focusOut>
 </mx:TextInput>
  

 <mx:Button x="46" y="173" label="add" id="btAdd" click="{add()}"/>
 <mx:Button x="46" y="122" label="delete" click="del()"/>
 <mx:TextInput x="46" y="225" width="102" id="t1" text="{myx.firstname}" change="myx.firstname=t1.text"/>
 <mx:TextInput x="187" y="225" width="109" id="t2" text="{myx.lastname}" change="myx.lastname=t2.text"/>
 <mx:Label x="46" y="205" text="FirstName"/>
 <mx:Label x="187" y="205" text="LastName"/>
 <mx:Label x="319" y="261" text="第一条记录FirstName"/>
 <mx:Label x="134" y="124" text="删除选择的记录"/>
 <mx:Label x="139" y="80" text="查看更新的xml文件"/>
 <mx:Label x="125" y="34" text="获取xml文件"/>
 <mx:Label x="104" y="175" text="将下面的记录添加到记录中"/>
 <mx:Label x="365" y="22" text="查看xml"/>
</mx:Application>

-----------------------------------------------------------