Flex 3 : FluorineFx : .NET

25 01 2008

Right, I might be sold on this setup I’ve got here.

So, I’m running Flex 3 Beta 3, the new open source remoting tool from the Silent Group called FluorineFx and .NET 2.0 (under Visual Studio 2008). Now, I’d been reading through online docs, and was struggling with persistent remote objects. Basically, I had assumed that after one call to some method in a remote object, the subsequent call would be to the same object, thereby any changes made in the first call would be noticed in the second.

HOWEVER, it turns out (thanku Zoli from the Fluorine mailing list) that by default, services have a “request” scope. If you want to change this, you must modify the remoting config file in the Fluorine .NET gateway.

The code below works as intended when you change the above remote file to include “<scope>session</scope>” under the destination tag of id “fluorine”… interesting…

Note: the code below is a modification of an example by Mark Piller from the Adobe docs on Flex and .NET (pg. 6).

C# Code


using System;


namespace FlexInterop


    public class City


        // The class uses public fields for brevity.

        // It could work with the public properties too

        public String name;

        public String country;

        public long population;


        // Public constructor is required so instances of

        // City can be created when the arrive from Flex

        public City()




        public City(String name, String country, long population)


            this.name = name;

            this.country = country;

            this.population = population;








using System;

using System.Collections.Generic;

using FluorineFx;


namespace FlexInterop



    [RemotingService(“Fluorine city service.”)]

    public class CityService


        public List<City> cities;


        public CityService()


            cities = new List<City>();

            cities.Add(new City(“Dallas”, “USA”, 1248816));

            cities.Add(new City(“Chicago”, “USA”, 2873790));

            cities.Add(new City(“Tokyo”, “Japan”, 12570000));




        public void addCity(City newCity)


            foreach (City city in cities)

                if (city.name.Equals(newCity.name))

                    throw new Exception(“City with name “ + newCity.name + ” already exists”);






        public List<City> getCities()


            return cities;






ActionScript 3.0 Code


package com.interop


 [RemoteClass( alias=“FlexInterop.City”)]

 public class City


  public var name:String;

  public var country:String;

  public var population:Number;







<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application creationComplete=”init()” xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute>




                  import com.interop.City;

                  import mx.rpc.events.FaultEvent;

                  import mx.rpc.events.ResultEvent;

                  import mx.controls.Alert;

                  import mx.rpc.remoting.RemoteObject;




                  private var cityService:RemoteObject;


                  public function init():void


                        cityService = new RemoteObject( “fluorine” );

                        cityService.source = “FlexInterop.CityService”;

                        cityService.addEventListener( FaultEvent.FAULT, gotFault );

                        cityService.addCity.addEventListener( ResultEvent.RESULT, cityAdded );

                        cityService.getCities.addEventListener( ResultEvent.RESULT, gotCities );








                  private function gotFault( evt:FaultEvent ):void


                   Alert.show( “Server reported an error – “ + evt.fault.faultString + evt.fault.faultDetail );



                  private function addCity():void


                   var city:City = new City();

                   city.name = “London”;

                   city.country = “UK”;

                   city.population = 10000000;

                   cityService.addCity( city );



                  private function cityAdded( evt:ResultEvent ):void


                   trace( “city added, refreshing cities list” );




                  private function getCities():void


                   trace( “getting all cities” );




                  private function gotCities( evt:ResultEvent ):void


                   trace( “received all cities” );

                   // display in a data grid

                   cities.dataProvider = evt.result;





      <mx:DataGrid id=”cities/>




One response

30 01 2008

Hi Justin,
in the original sample you can read

public class CityService

The scope element does exactly the same in the “flex way”. Older versions of Fluorine also supported activation attributes but that was removed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: