LRlr11录制脚本为空一个CS模式的软件的脚本,使用remoting进行连接,...

Actio cript 3 Experiments and Flash Player love.
Making Flash Remoting easier in Flash CS3
by Thibault Imbert
Here is something I have just added into my
in the Flash Remoting chapter and wanted to share with you
As you may know, no wra er cla is embedded into Flash CS3 for your remoting calls, you have to use the raw
cla which is not very practical in a large project.
I wanted a simple cla to call some remote methods in Flash CS3 like the
cla does in Flex, and like the Service cla we had in Flash 8. I came acro which is very smooth, but noticed that it was not working the way I wanted it.
So I created a wra er around the NetCo ection object which behaves like the Service cla we used to have with a PendingCall a igned to each remote procedure.
Here is how you create the remote service :
// create a remote object (Singleton)
var service:Service = Service.getI tance();
// set the required infos
service.setRemoteInfos (http://www.bytearray.org/wp-content/projects/remotingservice/amfphp/gateway.ph am quot;,
org.bytearray.HelloWorld,
ObjectEncoding.AMF3 );
Then you call the remote method, this retur you a PendingCall object :
// call the remote method
var rpc:PendingCall = service.sayHello(Hello there ?);
The PendingCall object is di atching two events, ResultEvent.RESULT and FaultEvent.FAULT :
// call the remote method
var rpc:PendingCall = service.sayHello(Hello there ?);
// wait for the result event (everything is ok)
rpc.addEventListener ( ResultEvent.RESULT, succe );
// wait for the fault event (an error occured)
rpc.addEventListener ( FaultEvent.FAULT, error );
// get the result
function succe ( pEvt:ResultEvent ):void
// output : you said : Hello there ?
trace( pEvt.result )
// get the result
function error ( pEvt:FaultEvent ):void
trace( pEvt.fault.description )
You can change the service or gateway at any time :
service.service = org.bytearray.AnotherService&am quot service.gatewayURL = http://www.myserver.org/amfphp/myOtherGateway.ph am quot Or authenticate yourself with some credentials :
service.setRemoteCredentials (, groove);
Sources and file examples available
Update (05/04/09) : Version 0.2 : Changed the Service implementation as a Singleton.
Comments
wrote::
Nice one Jimmy !
Thursday, January 24, 2008
2:47 pm
Thibault Imbert
wrote::
haha you’re welcome froggy
Thursday, January 24, 2008
2:54 pm
wrote::
fu y i thought the same about the as3 lightweight remoting framework (mi ing listeners on calls) and just as i started to write my own implementation i found the SSR (super simple remoting
). it works as expected and saved some time. but thanks for your implementation none the le *gg*
Thursday, January 24, 2008
3:10 pm
wrote::
whoo , the link:
Thursday, January 24, 2008
3:10 pm
wrote::
Can timeout interval be adjusted?
Thursday, January 24, 2008
6:43 pm
William from Lagos
wrote::
What’ the title of your book by the way?
Thursday, January 24, 2008
7:54 pm
Thibault Imbert
wrote::
Hi Mike,
yes such a feature can be added, I will add that
Hi William,
The book is called “Pratique d’ActionScript 3″ and is written in French. O’Reilly should tra late it after the release !
link to the book :
regards,
Thibault
Thursday, January 24, 2008
8:15 pm
Thibault Imbert
wrote::
Hi Marc,
very nice !
Maybe we could merge our two projects ?
What do you think ?
Thibault
Thursday, January 24, 2008
8:18 pm
wrote::
Hi Thibault, SSR was written by Aaron Smith (
) and not by me. I just use it
Thursday, January 24, 2008
10:30 pm
Thibault Imbert
wrote::
hehe ok Marc !
Thursday, January 24, 2008
10:42 pm
wrote::
Very nice,
I had started started to write my own remoting cla I’m going to try it
Friday, February 15, 2008
8:46 am
wrote::
Why not just import the rpc.swc from the Flex SDK, why reinvent the wheel here…
Interesting solution however.
Saturday, February 16, 2008
10:54 pm
Thibault Imbert
wrote::
Hi paul,
I saw quite complicated hacks to do that, did you try it ?
If it works smoothly, that would be nice
let me know
Sunday, February 17, 2008
12:05 am
wrote::
Hi Thibault,
thanks for sharing your solution with us. May I ask, under which licence you’re publishing the code? Am I allowed to use it in commercial projects and am I allowed to modify it to my ecial needs?
Wednesday, March 5, 2008
11:45 am
Thibault Imbert
wrote::
Hi Thomas,
There is no licence. You can modify the code and do whatever you want with it
cheers,
Thibault
Wednesday, March 5, 2008
12:05 pm
wrote::
Questio #8230;how can I make Flash remoting - ColdFusion secure?
It seems that you have to set a CFC to acce =”remote” but that allows anyone in the world to run it as well.
Monday, March 24, 2008
3:23 pm
gregpich
wrote::
Hi Thibault,
I’m looking for a french tutorial video that you have done, about AS3 and amfphp, but I ca #8217;t find it anymore on the web. May you please post the link?
Wednesday, March 26, 2008
5:37 pm
TrAvIkK
wrote::
First of all, I wanted to say, that you rock man
Waiting for your book to see it in English
Here is what i wanted to admit: In some way, FaultEvent is not di atched, or catched by event listener, in Flex 3.
Tuesday, April 15, 2008
9:36 am
SiggeLund
wrote::
I’m having problems getting this to work with query retur from ColdFusion.
var results:Object = pEvt.result;
var queryItems = results.item for (var queryIndex=0; queryIndexqueryItems.length; queryIndex++)
This i et wo #8217;t work since the items object is undefined. Anyone know how this should be done in AS3?
Saturday, September 6, 2008
8:00 pm
SiggeLund
wrote::
Figured it out. This code i et can be used to find the old style Recordset
Retur an array with objects, that works the same way as the results.items did in AS2.
Return events from AS3 Flash Remoting calls only contain one member when returning,
and it’ called “ erverInfo”. Pa that object to this method, and the normal array is then returned.
Stupid that Adobe has not implemented this themselve #8230;
Example:
function listEvents_Result( pEvt: ResultEvent ):void
var results = pEvt.result;
results["items"] = RemotingUtil.getRecordSet(results.serverInfo);
for (var queryIndex=0; queryIndexresults.items.length; queryIndex++)
var queryObj = results.items[queryIndex];
trace(queryObj.name);
trace(queryObj.date);
In this example we a ume that the recordset has the two colum “ ame” and “date”.
public static function getRecordSet(serverInfo:Object):Array
var queryItems = serverInfo.initialData;
var queryColum = serverInfo.columnName var retArray:Array = new Array();
for (var queryIndex=0; queryIndexqueryItems.length; queryIndex++)
var queryObj = new Object();
for (var j=0; jqueryColum .length; j++)
queryObj[queryColum [j]] = queryItems[queryIndex][j];
retArray.push(queryObj);
return retArray;
Sunday, September 7, 2008
11:38 am
Thibault Imbert
wrote::
Hi SiggeLund,
Yes, in Flash CS3 when you are receiving a query from the server you receive an objet with a serverInfo property that you have to parse the co truct an a ropriate RecordSet.
Adobe decided to remove the Flash Remoting components from Flash CS3 which is in my opinion a real mistake. Flash CS4 should solve that limitation
Sunday, September 7, 2008
12:55 pm
SiggeLund
wrote::
Thibault:
Tell me about it… Good thing that I found the tool ServiceCapture, would have been a bit confused otherwise.
Sunday, September 7, 2008
3:34 pm
Thibault Imbert
wrote::
Hi SiggeLund,
I ca ot talk about it for the moment
, but as soon as po ible I will post a tutorial here about the new capabilities offered by Flash CS4 in terms of Remoting.
Yes ServiceCapture is a must-have when it comes to Remoting debugging.
Thibault
Sunday, September 7, 2008
7:17 pm
SiggeLund
wrote::
Sounds great, I will look in from time to time to see what you’re cooking. =)
Sunday, September 7, 2008
10:09 pm
wrote::
Hi Thibault, we also implemented a remoting package in our as3 ope ource project (we are a commercial company) recently launched at
It also features built in su ort for recordsets which is a datatype i tead of a multidime ional array as presented in the example above.
It also tackles the problem you tackled with da y patterso #8217 implementation, which is that you can only call one method on one service. Both your and our solution fixed that by providing handlers/events for each method called on the service
Monday, October 6, 2008
8:48 pm
John Barrett
wrote::
Thanks for the post`-`
I have been going crazy trying to use flash remoting in CS3 with a cfc backend, and with no luck.
I am at school now, but I am going to try this when I get home.
Thursday, October 16, 2008
10:29 am
wrote::
thank you for sharing
Thursday, May 7, 2009
12:09 pm
wrote::
Thank you VERY MUCH.
I have been trying to get AMFPHP to work correctly using several tutorials, all with no luck, and I finally got this one to work!
Friday, July 17, 2009
4:51 am
Trackbacks/Pingbacks
Friday, January 25, 2008
1:22 pm
[...] check it [...] on
Friday, January 25, 2008
1:39 pm
[...] on
Monday, October 6, 2008
8:52 pm
[...] We also found another remoting implementation in as3 which is also cool, but lacking resultsets, on bytearray.org
AsUnit modification for asynchronous testing The Log and LogEvent cla es. [...] on
Tuesday, March 17, 2009
12:32 pm
[...] Flex中有RemoteObject类来实现Remoting,这个类无法在Flash IDE中使用。要在Flash CS3中实现Remoting,我们可以借助bytearray.org上面提供的一些类来完成。你可以在这个地址中下载相关的类文件和范例:
[...] on
Sunday, July 19, 2009
9:39 am
[...] ByteArray.org By: Thibault Imbert [...] About This Post
This was posted by
Thibault Imbert
Su cribe to the
for all comments on this post.
Filed Under
Post a Comment
Your email is
published nor shared. Required fields are marked
Sort comments by:
Date ASC
Date DESC
Name ASC
Name DESC
Disable Trackbacks
Remember Settings? *
* A lied after refresh
theme by
&am RSS:账号登录 | | | | |
找到您想要的开源软件,分享和交流
讨论区
Identity.cs
路径:
目 录
// System.Runtime.Remoting.Identity.cs
// Author: Lluis Sanchez Gual (lluis@ideary.com)
// (C) 2002, Lluis Sanchez Gual
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
// Permi ion is hereby granted, free of charge, to any person obtaining
// a copy of this software and a ociated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublice e, and/or sell copies of the Software, and to
// permit perso to whom the Software is furnished to do so, subject to
// the following conditio :
// The above copyright notice and this permi ion notice shall be
// included in all copies or su tantial portio of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CO***ACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Runtime.Remoting.Me aging;
using System.Runtime.Remoting.Proxie using System.Runtime.Remoting.Context using System.Runtime.Remoting.Lifetime;
name ace System.Runtime.Remoting
internal a tract cla Identity
// An Identity object holds remoting information about
// an object. It can be used to store client side information
// (information about how to reach the remote server),
// and also to store server side information (information
// about how to di atch me ages to the object in the server).
// URI of the object
protected string _objectUri;
// Me age sink to use to send a me age to the remote server
protected IMe ageSink _cha elSink = null;
protected IMe ageSink _envoySink = null;
DynamicPropertyCollection _clientDynamicPropertie DynamicPropertyCollection _serverDynamicPropertie // The ObjRef
protected ObjRef _objRef;
// This flag is set when the identity is removed from the uri table.
// It is needed because in some scenarios the runtime may try to
// di ose the identity twice.
bool _di osed = false;
public Identity(string objectUri)
_objectUri = objectUri;
public a tract ObjRef CreateObjRef (Type requestedType);
public bool IsFromThisA Domain
return (_cha elSink == null);
public IMe ageSink Cha elSink
get { return _cha elSink; }
set { _cha elSink = value; }
public IMe ageSink EnvoySink
get { return _envoySink; }
public string ObjectUri
get { return _objectUri; }
set { _objectUri = value; }
public bool IsCo ected
get { return _objectUri != null; }
public bool Di osed
get { return _di osed; }
set { _di osed = value; }
public DynamicPropertyCollection ClientDynamicProperties
if (_clientDynamicProperties == null) _clientDynamicProperties = new DynamicPropertyCollection();
return _clientDynamicPropertie }
public DynamicPropertyCollection ServerDynamicProperties
if (_serverDynamicProperties == null) _serverDynamicProperties = new DynamicPropertyCollection();
return _serverDynamicPropertie }
public bool HasClientDynamicSinks
get { return (_clientDynamicProperties != null &am am _clientDynamicProperties.HasProperties); }
public bool HasServerDynamicSinks
get { return (_serverDynamicProperties != null &am am _serverDynamicProperties.HasProperties); }
public void NotifyClientDynamicSinks
(bool start, IMe age req_msg, bool client_site, bool async)
if (_clientDynamicProperties != null &am am _clientDynamicProperties.HasProperties)
_clientDynamicProperties.NotifyMe age (start, req_msg, client_site, async);
public void NotifyServerDynamicSinks
(bool start, IMe age req_msg, bool client_site, bool async)
if (_serverDynamicProperties != null &am am _serverDynamicProperties.HasProperties)
_serverDynamicProperties.NotifyMe age (start, req_msg, client_site, async);
internal cla ClientIdentity : Identity
WeakReference _proxyReference;
public ClientIdentity (string objectUri, ObjRef objRef): base (objectUri)
_objRef = objRef;
_envoySink = (_objRef.EnvoyInfo != null) ? _objRef.EnvoyInfo.EnvoySinks : null;
public MarshalByRefObject ClientProxy
get { return (MarshalByRefObject) _proxyReference.Target; }
set { _proxyReference = new WeakReference (value); }
public override ObjRef CreateObjRef (Type requestedType)
return _objRef;
public string TargetUri
get { return _objRef.URI; }
开源中国社区(OsChina.NET) |
| 粤ICP备08124133号

参考资料

 

随机推荐