首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex与靠山交互的4种方法

2012-10-29 
Flex与后台交互的4种方法一、HTTPService 程序代码:private function initializeHandler(event:Event):void

Flex与后台交互的4种方法
一、HTTPService 程序代码:

private function initializeHandler(event:Event):void {

countriesService.send();

}

private function changeHandler(event:Event):void {

statesService.send();

}

]]-->

{country.value}

控件接收的内容提供,并且由这个ComboBox控制着第二个ComboBox所要显示的内容 -->

二、URLLoader

程序代码:

private var _countriesService:URLLoader;

private var _statesService:URLLoader;

private function initializeHandler(event:Event):void {

_countriesService = new URLLoader();

_countriesService.addEventListener(Event.COMPLETE, countriesCompleteHandler);

_countriesService.load(new URLRequest("http://www.rightactionscript.com/states/xml/countries.xml"));

_statesService = new URLLoader();

_statesService.addEventListener(Event.COMPLETE, statesCompleteHandler);

XML.ignoreWhitespace = true;

}

private function countriesCompleteHandler(event:Event):void {

var xml:XML = new XML(_countriesService.data);

country.dataProvider = xml.children();

}

private function statesCompleteHandler(event:Event):void {

var xml:XML = new XML(_statesService.data);

state.dataProvider = xml.children();

}

private function changeHandler(event:Event):void {

var request:URLRequest = new URLRequest("http://www.rightactionscript.com/states/xml/states.php");

var parameters:URLVariables = new URLVariables();

parameters.country = country.value;

request.data = parameters;

_statesService.load(request);

}

]]-->

三、WebService 方法一 程序代码:

private function initializeHandler(event:Event):void {

statesService.getCountries();

}

private function changeHandler(event:Event):void {

statesService.getStates(country.value);

}

]]-->

wsdl="http://www.rightactionscript.com/states/webservice/StatesService.php?wsdl">

dataProvider="{statesService.getCountries.lastResult}" change="changeHandler(event)" />

四、WebService 方法二

程序代码:

private function initializeHandler(event:Event):void {

statesService.getCountries.send( );

}

private function changeHandler(event:Event):void {

statesService.getStates.send( );

}

]]-->

{country.value}

dataProvider="{statesService.getCountries.lastResult}" change="changeHandler(event)" />

热点排行