myService = gateway_conn.getService("my.service", this); } 在这个例子中,使用setDefaultGatewayUrl函数在flash电影中指定了falshRemoting所有服务通信的URL。一旦使用setDefaultGatewayURL函数,就不需要再为每一个createGatewayConnection函数提供URL,这对于在FlashMX创作环境中进行开发时特别有用的。建立服务连接对象后,你就像下面的例子一样同应用服务器通信。 myService.remoteServiceMethodName(param1, "param2");
3、 flashs应用服务网关URL是指向我服务器中目录上的什么地方? Flash Remoting服务网关的url(如:"http://localhost:8100/flashservices/gateway")是不存在的,仅仅是一个映射而已。不要花心思去寻找 wwwroot下面的指向目录。
4、怎样处理服务器上返回的数据? 调用服务对象中的函数,使用服务对象名后跟随一个函数名,如下例: myService.getTemperature("New York"); 在这个例子中,getTemperaturn函数作为一个公开的方法或者应用程序页面存在于应用服务器中,该函数传递了一个字符串参数,“New York”,要传递多个参数到Service函数,需要包含一个Service函数调用的逗号分割值的列表,例如: server.getTemperature("New York", 1998, "average"); 在这个例子里,service函数传递了三个参数,城市(“New York”),年(1998)以及指令(“average”)。 注意:参数必须按照service函数要求的顺序出现。
5、怎样在FLASHMX UI组件上显示服务器返回的数据结果? 要容易地显示记录集对象的内容,使用 Flash MX用户界面( UI)组件ListBox和ComboBox。对任一UI组件,使用DataGlue函数,包括bindformatstrings和bindformatfunction。 DataGlue函数绑定一个数据提供者到一个数据用户,比如绑定记录集对象到combobox组件。 数据作为标准的label/data配对出现。 DataGlue函数并不对原始数据提供者的数据进行复制,不过,数据是在数据用户需要时从原始数据供应者处取出, 该数据用户可以使用数据像任何其他的参数。每个记录的标签是用来显示纪录的文本,每个记录的data是由该数据用户的getValue函数返回的value,bindFormatStrings函数让你格式化在函数调用中的数据。 例如∶DataGlue.bindFormatStrings(myComboBox, myRecordSet, "#parkname# ?(#parktype#)", "#city#, #state# #zipcode#"); 在这个例子中, myComboBox表示Flash电影中的一个combobox组件, myRecordSet表示RecordSet对象。 parkname, parktype, city, state,和zipcode变量表示记录字段名称。 Flash电影显示了parkname和parktype变量。 city, state,和zipcode变量在用户选择该记录的时候返回。 你可以使用getValue函数回送这些变量值。 bindformatstrings函数让你调用一个函数去格式化数据。 你可以如下例所示创建该函数: function myFormatFunction ( record ) { // the label is the parkname record field, translated to lower case var theLabel = record.parkname.toLowerCase();
// the data is the length of the parkname record field var theData = record.parkname.length;
// return the label and value to the caller return {label: theLabel, data: theData}; } //call the bindFormatFunction DataGlue.bindFormatFunction(dataView2, result, myFormatFunction); 在这个例子中, record表示一记录集对象, dataview2表示Flash电影中的用户界面组件上一页 [1] [2] 图片" onclick="javascript:window.open(this.src);" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/>
[]
|