Adobe Flex 2.0 training day 5

FLEX 2.0On this last day of the Flex 2.0 training we started using the Flex Message Service. This is actually the basis to send real time messages to clients. This FMS is based on two MXML tags

  • consumer : receives data
  • producer : sends data

To use the FMS we also need a destination. Therefore we have to define two things:

  1. message adapter : server part
    1. JMS  class:  adapter between java applets and flex
    2. Actionscript adapter
  2. protocol to use
    1. RTMP : in real time pushing data to clients (needed a port to be opened).
    2. Polled AMF : not real time but based on a polling mechanism.

Both of those  can be made secure !

The difference with HTTP is that we now have an open channel the whole time. To publish messages we use the AsyncMessage class. We create objects out of that class (headers en body property). The consumer the need to be told to start listening by using the subscribe method. Every time when a message is received, the consumer will fire an event and we can use an eventHandler to get the AsyncMessage that contains the data that is sended. To filter those data we can use the selector property.

Next part was the use of the Flex Data Management services.

The FDM services add some kind of abstraction layer: you only need to worry about the data on the client side. It works exactly the same way as FMS (destination > channel and all info goes into a configuration XML file). An adapter here is a class that manages the data. And there is also some fall back mechanism:  if you have two channels specified and 1 fails to connect then automatically the other will be used; so it falls back to the other. You only have to define on the server what (eg) java classes has to be used abd the server know how to handle the data. That java class has several methods defined that defines how to retrieve data and send it to Flex. In Flex we just use the fill method and we actually do not know where the data came from. We only ask to give data ! So the architecture of the DMS is that a value object in AS 3.0 is linked to a value object in eg Java. But do not forget to set the remoteclassmanaged” in stead of bindable because we want to leave it to the FDM services.

If you want more control in the client side application we can set the autocommit option to false and handle it ourself when data has to be sended. There is in commit method to manually send data (write record back to server). When you are changing data there is also made a set of pending changes till you manually ask to send by using that commit method. If you want to delete that set of pending changes you can use the revertChanges method to delete all of the pending changes or just a specific one. Also cool is that a property commitRequired is set to exactly know when a set of pending changes has been filled. Eg to use to set a save button enabled when there are pending changes. When something goes wrong you can also detect it by using the conflict and fault event. The server sends out a resultEvent and faultEvent. Another more advanced Data Management Service  feature is a paging mechanism but you can find some interesting information in the product documentation.

The next unit we talked about controlling XML using the E4X ECMA standard.(W3C). If you ask me I would say directly that it is easier then working with arrays of objects ===> VERY COOL !! It is also a more consistent way of working with XML data. (no firstChild, lastChild,…anymore) It uses a standard syntax as working with AS data. The two things you need are:

  • XML class
  • XMLList class (eg fragments of XML )

There  are a few cool operators you can use with E4X:

  • dot operator
  • paranthesis operator : ___.____.(girl==’Brigitte’) ==> select all data where girl has Value Brigitte (returns XMLList)
  • descendent accessor = kick *ss operator 🙂
    • ___.___. .girl ==> just all nodes with name “girl”  on all levels ! 

Offcourse you can use them all together to do some very fast filtering of the XML data !You can also use a Tree control to simply visualize that XML data. A tree view consists of branches (folder icon) and nodes (file icon). A branch can have nodes or other branches and a node is always an endpoint. With the use of the XMLListCollection we can automatically displays changes so monitoring is really better.

The last unit of today and even of this 5day training was on uploading files to a server. As you know the Flash Player runs in a security sandbox but we can upload some files to a server using a backend (PHP, ASP, Coldfusion,…) to do the work. The frontend can be made in Flex.  Therefore we need to instantiate the filereference class. You can browse the user’s file system by using the browse method and upload a specific file with the upload method. To send it with to the server we use an URLRequest; it holds information about the server and the page (PHP, ASP,…) we have to call to upload the file to the server.

And then then… the training was over 😦 :-(. I will miss all of the 15 students who followed the course and hope to see you all again on maybe a next training or in professional life.

Most of all I want to thank Simon Slooten, our superior trainer who let us discover the world of Flex 2.0 in a very enthousiastic and practical way ! Now it is our turn to put all this knowledge in practice and make some really cool Flex applications starting… tomorrow :-).

Brigitte Maenhout (TasteItTV.com) and myself

Advertisements

5 responses to “Adobe Flex 2.0 training day 5

  1. Joeri 11 November , 2006 at 2:12 am

    Thanks for your daily effort to put your course experience online 😉

  2. Stefan Richter 15 November , 2006 at 10:38 am

    thanks for the posts. Sounds liek an excellent course.

    BTW who are the geeks in the photo? 😉

  3. Koen 15 November , 2006 at 12:17 pm

    just two Math.random() people 🙂

  4. Stef Andries 22 November , 2006 at 11:10 am

    Nice training indeed, and… even better… a great opportunity to meet a bunch a great people.

    May the Flex be with you,

    Stef

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s