How To: Using Remoting AS 2.0 with the client2 example!

Leif Wells <[email protected]>
Newsgroups gmane.comp.java.openamf.user
Message-ID <[email protected]>
Just in case anyone is interested, here are some very simple steps in
getting the Flash Remoting for Flash MX 2004 Actionscript 2.0
components to work with older Actionscript 1.0 files.

This won't cover every situation, but it will give you an idea of how
to deal with the new components. For most of you, I'd expect that this
may be unnecessary, but I thought that it might be nice to have saved
in this forum in case someone asked. These instructions are
purposefully brief due to their email delivery, and assume a certain
level of familiarity with OpenAMF.

This "tutorial" assumes that you have installed Flash MX 2004
Professional and have downloaded and installed Flash Remoting for
Flash MX 2004 Actionscript 2.0
(http://www.macromedia.com/software/flashremoting/downloads/components/#flr_as2)

Step 1: Create New Example Files

Locate your example files. Copy and rename your "client2.fla" and
"client2.as" files something catchy like "client2v2".

Step 2: Create new files.

Open "client2v2.fla". Select "File" > "Publish Settings..." and select
the "Flash" tab. Open the "Version" drop-down and select "Flash Player
7".

Open the "Actionscript Version" drop-down and select "Actionscript 2.0".

Select "OK"

Step 3: Change the ".as" file reference.

In the Timeline Panel, locate and select the Actionscript layer
labeled "actions". Open the Actions Panel. Change

#include "client2.as"

to

#include "client2v2.as"

Step 4: Add the New Classes

For whatever reason, Macromedia made the new Flash Remoting code
install differently than most people expected. The Class files are not
part of the program's paths like all the other Class files. And these
"components" are not located in your Components Panel. Macromedia
chose to make these files available in a Library, which, logically
makes sense (after all, these items are a library of remoting classes)
although almost everyone I know was tripped up by trying compile
without taking this step first.

Let's keep organized. In your Timeline, create a new layer and label
it "remoting".

Open the Remoting Library Panel by selecting "Windows" > "Other
Panels" > "Common Libraries" > "Remoting".

Select the two items in the library and drag them to the stage.

While I normally place them "off screen" for organizational purposes,
these components are not visible at run-time.

Step 5: Save the file.

When Flash says that you are saving in a different version, select "OK".

Step 6: Reference the new Remoting Classes.

Locate and open the "client2v2.as" file.

We need to change the code in the first two lines to reflect the use
of the new Remoting Classes.

In line 1 replace

#include "NetServices.as"

with

import mx.remoting.NetServices;

In line 2 replace

#include "NetDebug.as"

with

import mx.remoting.debug.NetDebug;

Step 7: Correct Capitalization Problem

Find line 68 where the code reads:

NetServices.setDefaultGatewayURL(this.gatewayPath);

Please note that Flash MX 2004 is case sensitive. Correct the Method
call's "URL" with this:

NetServices.setDefaultGatewayUrl(this.gatewayPath);

Step 8: Compile!

You should now be able to compile your new example file.

There is one bug in this example file that can be found when switching
between the "Get with Name" and "Get with Zip" that we are attempting
to put our fingers on. We have good ways to avoid the problem, but
we'd like to find and solve the problem.

I have a brand new example file that I presented last night that is
based on the "client2" example. I hope to have it properly completed
along with a similar "article" soon.

Questions? Corrections? Suggestions? Let me know.

Leif Wells
Manager, Atlanta Macromedia User Group
Director of Multimedia, Roundbox Media

[email protected] <mailto:[email protected]>
[email protected]


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.