Fluorine is an excellent open source project for .net developers as an alternative to Adobe’s commercial remoting tool. I have noticed there isn’t too much documentation out there for .net users wishing to get into remoting as opposed to the php offering amfphp so thought i’d contribute.
What is Fluorine?
Fluorine is an open source solution for achieving remoting on the .net platform created by Zoltan Csibi. More info at http://fluorine.thesilentgroup.com. There is the download, a mailing list and some useful documentation. Another resource that I hope to be adding to over the coming weeks is at osflash
Installing the remoting components
If you’ve never developed for flash remoting in the past you’ll need to install the Flash Remoting components, these don’t come installed as standard in either the standard or pro versions of Flash mx2004 or Flash8. you can download the components here: http://www.adobe.com/products/flashremoting/downloads/components/ which should be a simple case of double click installation. Included in these components are the following:
NetConnection Debugger – very useful swf that displays requests between application and server
Service Browser – another swf used for browsing available remoting services and methods that are available
Remoting help files – F1 to view
Remoting libraries – within the flash IDE click Window, Other Panels, Common Libraries, Remoting. Within this library are two compiled clips that need to be in the library of any remoting movie.
Installing Fluorine is very easy. Simply download the latest version from fluorine.thesilentgroup.com and extract it to your usual visual studio projects folder. That’s it!
Now an introduction tutorial wouldn’t be an introduction tutorial without a hello world example would it? Within Visual Studio create new c# web application and call it “FluorineTest”
Right click the project in the solution explorer and select “add reference”
in the .net tab click browse and navigate to [downloadedFluorineFolder]\com.TheSilentGroup.Fluorine\bin\Debug\com.TheSilentGroup.Fluorine.dll and OK back.
Next add the following lines to web.config within the <system.web> tags:
Add a new class to the project and call it “HelloWorld”, copy and paste the following code:
public class HelloWorld
//Constructor – does nothing
public string serverFunction(string sMessage)
return “our server received and returned: ” + sMessage;
Add new blank webform to project and call it “Gateway.aspx”
Thats our service created, we can now build the project!
Now for our flash application create a new flash document
Go into Window, Other Panels, Common Libraries, Remoting and drag RemotingClasses and RemotingDebugClasses onto the stage.
Next copy and paste the following code on the first frame of the movie:
var _service:Service = new Service(“http://localhost/FluorineTest/Gateway.aspx”, null, ‘FluorineTest.HelloWorld’, null , null);
var pc:PendingCall = _service.serverFunction(“Hello World!”);
pc.responder = new RelayResponder(this, “handleResult”, “handleError”);
trace(‘The result is: ‘ + re.result);
trace(‘There has been an error’);