- Flash application will call gateway.aspx at the asp.net website with some parameters in the request and name of class which is remotely invoked
- gateway.aspx will create an instance of the class described by the service parameter and passes all the request params to constructor as a collection
- The FACADE class then reads the parameters and decides which method to call, and it calls that method from business logic layer and returns the output to flash application
This story works nicely as a theory and practical for us, and I was satisfied with the way it was working.
There is almost a year passed after that, and today morning i came across an open source project AMF.NET which is an open source version of flash remoting. I was just reading the documentation and wondering if i can implement the thing again. I was surpriced that i get through this also.
Initially, i started implementing it and i was not quite getting it, then i came across an article on http://codebetter.com/blogs/karlseguin/archive/2006/04/13/142770.aspx which has some links about the documentation. I didn't quite get some good documentation but a comment on the post also helped me.
Using Sample code:
- Extract zip file and open the project.
- Add a blank Default.aspx page and run it.
- the url looks like http://localhost:3434/AMF/Default.aspx
- Now open the facade.fla in flash 8. Also open util.as
- In Util.as, line 12, you will require a service url as a first parameter, replace the with gateway.aspx of your application url, for example, http://localhost:3434/AMF/gateway.aspx.
- gateway.aspx will be available in the dll in the bin directory.
- That's it, run your AMF project and be in the debug mode, place breakpoint at getUser method of the User.cs in the app_code.
- Run your flash application and enter username and password, and click on button. If everything goes well, you will be redirected to scene 2 and will see label over there.
After some days of writing this article, I got a comment from a user who pointed me to yet another flash remoting open source library. This one is a simple to understand. You can find the library on codeplex at http://dotnetflex.codeplex.com/ the source code is available. This library gives some better implementation of flash remoting because its much more simpler to understand than AMF. I downloaded the library from the source code section of the site and try my hand on it. I got it working in almost an hour. So hopefully developers will simply get a quick start with this. The wiki on the site provides some implementation details from asp.net side, but there is no source code sample for flash, I just tried same file as i used in the AMF.NET with some minor changes and its working nicely. Hope you all find it helpful.
You can download the file from here. You can also find a link in DOWNLOAD section of this blog also. To test the code, follow the same step described in AMF.NET section. Sample Application description:
- Flash application displays a Login page with username and password and a login button
clicking on login will calls a method getUser(HashTable ht) of an asp.net application from flash side
- after getting a successfull return value, it redirects to scene2
Enhancements that can be applied at Flash Side:
- I don't even know how to create a password textbox in flash, and i want to display a username returned from asp.net in scene2.
- I'm working on this but if anybody can help, it would be appriciated.
Please note that I don't know flash as well as action scripts, But I'm good at learning, and i have good experience on developing asp.net applications.
Thanks and happy coding. :)