AS 2.0 Remoting Classes "'Gotcha!"

In incorporating the new AS 2.0 remoting classes into the Ariaware RIA Platform, I ran into a very simple gotcha that others may have come across but which I haven't seen discussed in our neck of the blogosphere:

In order to use the AS 2.0 API, you need to drag one or two components on the Stage -- you can't just import the classes and start using them. The classes are distributed as compiled clips within a library.

This is actually documented in the Help that comes with the new API. From the Flash Remoting Help; Using Flash Remoting MX 2004 -> Flash Remoting application structure overview:

1. From the Window menu in Flash, select Other Panels > Common Libraries > Remoting. 2. From the Library panel, drag the RemotingClasses library onto the Stage. 3. To use the NetDebug class and the NetConnection Debugger, you must also drag the RemotingDebugClasses library to the Stage.

4. In the Actions panel, import the ActionScript Flash Remoting classes.

I had skipped points 1-3 and of course got an error stating that the classes (which do not exist in source form in the default classpath) could not be found. This lead me to initially believe that the installation had failed somehow until Peter (Hall) suggested that I look under the Common Libraries folder.

I have to say that this is not an entirely intuitive way of distributing or using classes. I would much prefer it if I didn't have to drag classes on to the Stage and could just import them in code.

It might also be helpful if the otherwise excellent Trio Service Manager tutorial would explicitly state this requirement on Page 5, wherein we are instructed to open a ready-made FLA which, I am assuming, already contains the RemotingClasses component/library.

Update: Richard Leggett just emailed to remind me that the source for the AS2 remoting classes is available for download from Macromedia. In contrast to the size of the installer (which includes quite a bit of help as well as the connector component), the source weighs in at a modest 60k or so.

You should unzip the source and copy it to your First Run\Classes directory and restart Flash.

It would be nice if the installer could be updated so that this is handled automatically.

Comments