- 浏览: 99627 次
- 性别:
- 来自: 大连
文章分类
最新评论
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
public const xmlUrl:String = "config.xml";
[Bindable] private var colors1:ArrayCollection;
[Bindable] private var colors2:XML;
private function init():void{
//方法一:通过HTTPService
var service:HTTPService = new HTTPService();
service.url = xmlUrl;
service.addEventListener(ResultEvent.RESULT, resultHandler);
service.send();
//方法二:通过URLLoader
var request:URLRequest = new URLRequest(xmlUrl);
var loader:URLLoader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
}
private function resultHandler(event:ResultEvent):void{
colors1 = event.result.colors.color;
}
private function loaderCompleteHandler(event:Event):void{
colors2 = new XML(event.target.data);
}
]]>
</mx:Script>
<mx:List x="100" y="150" dataProvider="{colors1}" labelField="name">
</mx:List>
<mx:List x="300" y="150" dataProvider="{colors2.color}" labelField="@name">
</mx:List>
</mx:Application>
config.xml文件
Java代码 收藏代码
<colors>
<color name="LightGrey" value="#D3D3D3"/>
<color name="Silver" value="#C0C0C0"/>
<color name="DarkGray" value="#A9A9A9"/>
<color name="Gray" value="#808080"/>
<color name="DimGray" value="#696969"/>
<color name="Black" value="#000000"/>
</colors>
实例:
登录
Java代码 收藏代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import flash.net.navigateToURL;
private function goLogin():void{
login.send();
}
private function resultHandler(event:ResultEvent):void{
var entry:String = event.result.users.a.toString();
if(entry == 'ok'){
}else{
Alert.show('Username or Password is/are wrong !');
}
}
]]>
</mx:Script>
<mx:HTTPService id="login" method="POST" showBusyCursor="true" url="flexlogin.php" result="resultHandler(event)">
<mx:request xmlns="">
<mx:username> {username.text} </mx:username>
<mx:userpwd> {userpwd.text} </mx:userpwd>
</mx:request>
</mx:HTTPService>
<mx:Panel width="310" height="265" layout="absolute" title="登录" fontSize="12" fontWeight="normal">
<mx:TextInput x="93" y="51" id="username" fontSize="12"/>
<mx:TextInput x="92" y="95" id="userpwd" fontSize="12" displayAsPassword="true"/>
<mx:Button x="73" y="154" label="登录" id="btn1" click="goLogin()" fontWeight="normal" fontSize="12"/>
<mx:Label x="32" y="53" text="用户名:" fontSize="12"/>
<mx:Label x="43" y="97" text="密码:" fontSize="12"/>
<mx:Button x="154" y="154" label="注册" fontSize="12" fontWeight="normal" id="btn2"/>
<mx:Label x="10" y="10" text="测试用 用户名 User 密码 123456" fontSize="12" width="243"/>
</mx:Panel>
</mx:Application>
flexlogin.php
Php代码 收藏代码
<?php
$return="";
if(isset($_POST[username]) && isset($_POST[userpwd])){
if ("User"==$_POST[username] && "123456"==$_POST[userpwd])
$return="ok";
else
$return="error";
}
$xml_return = '<users>';
$xml_return.= '<a>'.$return.'</a>';
$xml_return.= '</users>';
echo $xml_return;
实例:
rss
Java代码 收藏代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="feedRequest.send()">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
]]>
</mx:Script>
<!-- 利用flex获取并显示数据2 -->
<mx:HTTPService id="feedRequest" url="flexXml.xml" useProxy="false"/>
<mx:Panel x="10" y="10" width="475" height="400" layout="absolute" title="{feedRequest.lastResult.rss.channel.title}" >
<mx:DataGrid x="10" y="10" id="dgPosts" width="400" dataProvider="{feedRequest.lastResult.rss.channel.item}">
<mx:columns>
<mx:DataGridColumn headerText="Posts" dataField="title"/>
<mx:DataGridColumn headerText="Date" dataField="pubDate" width="150"/>
</mx:columns>
</mx:DataGrid>
<mx:LinkButton x="10" y="225" label="Read full part" click="navigateToURL(new URLRequest(dgPosts.selectedItem.link));"/>
<mx:TextArea x="10" y="175" width="400" htmlText="{dgPosts.selectedItem.description}"/>
</mx:Panel>
</mx:Application>
flexXml.xml
Java代码 收藏代码
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<!-- 该文件放到tomcat的root目录 -->
<channel>
<title>你好,flex获取并显示数据</title>
<item>
<title>hello world</title>
<description> this is a best exanple in flex,you can do it with me ,and may you hava a wanderful future </description>
<link>http://hi.baidu.com/shiryu963</link>
<guid>http://hi.baidu.com/shiryu963</guid>
<category>general</category>
<pubDate>2009.6.8 12:17:11</pubDate>
</item>
<item>
<title>hello kava</title>
<description> best wishs to me,this is a best exanple in flex,you can do it with me ,and may you hava a wanderful future </description>
<link>http://hi.baidu.com/shiryu963</link>
<guid>gech.com</guid>
<category>general</category>
<pubDate>2009.8.8 6:20:11</pubDate>
</item>
<item>
<title>hello shiryu</title>
<description> i hava a best wish to you,this is a best exanple in flex,you can do it with me ,and may you hava a wanderful future </description>
<link>http://hi.baidu.com/shiryu963</link>
<guid>hahahhahhahahah</guid>
<category>improtant</category>
<pubDate>2009.4.22 6:20:11</pubDate>
</item>
</channel>
</rss>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
public const xmlUrl:String = "config.xml";
[Bindable] private var colors1:ArrayCollection;
[Bindable] private var colors2:XML;
private function init():void{
//方法一:通过HTTPService
var service:HTTPService = new HTTPService();
service.url = xmlUrl;
service.addEventListener(ResultEvent.RESULT, resultHandler);
service.send();
//方法二:通过URLLoader
var request:URLRequest = new URLRequest(xmlUrl);
var loader:URLLoader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
}
private function resultHandler(event:ResultEvent):void{
colors1 = event.result.colors.color;
}
private function loaderCompleteHandler(event:Event):void{
colors2 = new XML(event.target.data);
}
]]>
</mx:Script>
<mx:List x="100" y="150" dataProvider="{colors1}" labelField="name">
</mx:List>
<mx:List x="300" y="150" dataProvider="{colors2.color}" labelField="@name">
</mx:List>
</mx:Application>
config.xml文件
Java代码 收藏代码
<colors>
<color name="LightGrey" value="#D3D3D3"/>
<color name="Silver" value="#C0C0C0"/>
<color name="DarkGray" value="#A9A9A9"/>
<color name="Gray" value="#808080"/>
<color name="DimGray" value="#696969"/>
<color name="Black" value="#000000"/>
</colors>
实例:
登录
Java代码 收藏代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import flash.net.navigateToURL;
private function goLogin():void{
login.send();
}
private function resultHandler(event:ResultEvent):void{
var entry:String = event.result.users.a.toString();
if(entry == 'ok'){
}else{
Alert.show('Username or Password is/are wrong !');
}
}
]]>
</mx:Script>
<mx:HTTPService id="login" method="POST" showBusyCursor="true" url="flexlogin.php" result="resultHandler(event)">
<mx:request xmlns="">
<mx:username> {username.text} </mx:username>
<mx:userpwd> {userpwd.text} </mx:userpwd>
</mx:request>
</mx:HTTPService>
<mx:Panel width="310" height="265" layout="absolute" title="登录" fontSize="12" fontWeight="normal">
<mx:TextInput x="93" y="51" id="username" fontSize="12"/>
<mx:TextInput x="92" y="95" id="userpwd" fontSize="12" displayAsPassword="true"/>
<mx:Button x="73" y="154" label="登录" id="btn1" click="goLogin()" fontWeight="normal" fontSize="12"/>
<mx:Label x="32" y="53" text="用户名:" fontSize="12"/>
<mx:Label x="43" y="97" text="密码:" fontSize="12"/>
<mx:Button x="154" y="154" label="注册" fontSize="12" fontWeight="normal" id="btn2"/>
<mx:Label x="10" y="10" text="测试用 用户名 User 密码 123456" fontSize="12" width="243"/>
</mx:Panel>
</mx:Application>
flexlogin.php
Php代码 收藏代码
<?php
$return="";
if(isset($_POST[username]) && isset($_POST[userpwd])){
if ("User"==$_POST[username] && "123456"==$_POST[userpwd])
$return="ok";
else
$return="error";
}
$xml_return = '<users>';
$xml_return.= '<a>'.$return.'</a>';
$xml_return.= '</users>';
echo $xml_return;
实例:
rss
Java代码 收藏代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="feedRequest.send()">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
]]>
</mx:Script>
<!-- 利用flex获取并显示数据2 -->
<mx:HTTPService id="feedRequest" url="flexXml.xml" useProxy="false"/>
<mx:Panel x="10" y="10" width="475" height="400" layout="absolute" title="{feedRequest.lastResult.rss.channel.title}" >
<mx:DataGrid x="10" y="10" id="dgPosts" width="400" dataProvider="{feedRequest.lastResult.rss.channel.item}">
<mx:columns>
<mx:DataGridColumn headerText="Posts" dataField="title"/>
<mx:DataGridColumn headerText="Date" dataField="pubDate" width="150"/>
</mx:columns>
</mx:DataGrid>
<mx:LinkButton x="10" y="225" label="Read full part" click="navigateToURL(new URLRequest(dgPosts.selectedItem.link));"/>
<mx:TextArea x="10" y="175" width="400" htmlText="{dgPosts.selectedItem.description}"/>
</mx:Panel>
</mx:Application>
flexXml.xml
Java代码 收藏代码
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<!-- 该文件放到tomcat的root目录 -->
<channel>
<title>你好,flex获取并显示数据</title>
<item>
<title>hello world</title>
<description> this is a best exanple in flex,you can do it with me ,and may you hava a wanderful future </description>
<link>http://hi.baidu.com/shiryu963</link>
<guid>http://hi.baidu.com/shiryu963</guid>
<category>general</category>
<pubDate>2009.6.8 12:17:11</pubDate>
</item>
<item>
<title>hello kava</title>
<description> best wishs to me,this is a best exanple in flex,you can do it with me ,and may you hava a wanderful future </description>
<link>http://hi.baidu.com/shiryu963</link>
<guid>gech.com</guid>
<category>general</category>
<pubDate>2009.8.8 6:20:11</pubDate>
</item>
<item>
<title>hello shiryu</title>
<description> i hava a best wish to you,this is a best exanple in flex,you can do it with me ,and may you hava a wanderful future </description>
<link>http://hi.baidu.com/shiryu963</link>
<guid>hahahhahhahahah</guid>
<category>improtant</category>
<pubDate>2009.4.22 6:20:11</pubDate>
</item>
</channel>
</rss>
发表评论
-
Adobe Flash Builder 4.6破解方法
2012-12-16 20:08 7C:\Program Files (x86)\Adobe\Ad ... -
FluorineFx 配置支持纯AS3工程!
2012-11-30 13:45 0FluorineFx 配置支持纯AS3工程! 由于自己用的纯 ... -
Flex中ArrayCollection的复制
2012-11-30 13:39 0lex中ArrayCollection的复制 2011- ... -
Flex的array和arrayCollection的应用实例
2012-11-30 13:34 0ArrayCollection是flex中的数组集合类,它是很 ... -
Flex air 中调用com组件的方法
2012-11-30 11:45 0air中直接调用com组件是很难做到的,但我们可以通过Fl ... -
FluorineFx 之 DateFeed,既服务端的数据推送服务
2012-11-30 11:29 0在开发如股票客户端的软件,客户端的数据在实时刷新,是由于服务端 ... -
收藏 flex+fluorinefx+asp.net c#后台如何接收arraycollection 并转换处理
2012-11-30 11:25 0flex,在.NET环境下通过FluorineFx传送Arra ... -
特殊符号收集大全
2012-11-27 19:06 875愛心符號 愛心符號怎 ... -
TextFormat设置中文字体font属性注意的问题
2012-11-27 19:05 2370如果要设置的字体为中文名称,则一定要使用对应的英文名称来设置才 ... -
flex国际化的问题
2012-11-27 18:52 6991、如果是简单项目,一般采用的是类似struts的bundle ... -
flex textfield中文字体
2012-11-27 17:14 924由于flex的图文混排总是有问题,而且效率实在有点低。所以最近 ... -
FLEX如何设置发光字体
2012-11-27 16:35 677<mx:Text id="bulletin&q ... -
Flex实现全屏源代码示例
2012-11-12 10:18 581stage.displayState = (stage.dis ... -
flex4.5组件:如何自定义VideoPlayer的全屏行为
2012-11-12 09:41 850Flex4中增加了一个视频播放组件:VideoPlayer,相 ... -
Flex+java+spring 上传和下载文件AIR
2012-11-09 10:50 812什么都别说附上代码 UploadFile.java ... -
FluorineFX初学者之最初配置 Flex4与.NET结合 .
2012-11-09 09:43 863FluorineFX整个架构和BlazeDs差不多,只是最开始 ... -
Flex 绑定/双向绑定
2012-11-08 11:39 6451.什么是数据绑定? Data binding is ... -
Flex ArrayCollection 之排序
2012-11-07 15:59 651利用ArrayCollection的sort属性 & ... -
FLEX中使用FLVPlayback控件
2012-11-07 08:58 785即swc文件的导入,使用问题. FLVPlaybackAS ... -
VideoPlayer
2012-11-06 15:59 1981/** * VERSION: 1.0 * DATE: 20 ...
相关推荐
Flex读取xml文件 几种方法Flex读取xml文件 几种方法Flex读取xml文件 几种方法
flex读取xml文件的数据的三种方式及其比较
Flex读取XML不刷新问题
flex读取xml乱码的解决方法
flex 解析xml文件,利用httpservice读取xml文件,按要求过滤字符串,获取对应的值
用flex读取xml然后循环生成buttoon
flex 读XML 写XML 并保存为xml文件,由图生成Xml文件,由XMl文件生成图
Flex 读取xml文件的多种方法小结,大家可以根据需要自己选择。
flex外部读取xml
flex解析xml实例,可读取xml标签来获取信息,并附表情
Flex ssh 读取xml json Flex ssh 读取xml json
flex 通过读取xml文件 实现动态DataGrid数据列表
通过Httpserver与读取本地XML文件
flex通过httpService读取xml数据到datagird中,通过读取远程URL的XML数据(这里保存到本地),保存到ArrayCollection中,然后在将ArrayCollection绑定到datagird上 环境:flex3.0 可直接运行
这个flex工程实现了将xml读入,并能将其内容转化成一张考卷,用户可填入答案并提交,系统可判断正确与否。
用httpservice和urlloader方法读xml里的数据
这个小例子是使用Java作为服务端、Flex做前台,对一个xml文件的读取和写入。 环境:MyEclipse6.0.1+Flex3插件版,jdk1.6,tomcat6.0,dom4j1.6.1,lcds.war, 使用技术:1.Java+flex,及其对象的转换。 2.Java方面...
flex中经常需要xml格式的文件。通过后台asp.net的处理可以将数据库中读取的文件转化为xml格式。这是再传递给前端的flex中的tree控件作为数据源。
1.下载解压 2.导入到MyEclipse 3.右键直接运行bin-debug/main.mxml文件
as3.0读取外部xml,使用与flex flash as3.0