Category Archives: Rich Internet Applications

Flash Remoting and C# Assemblies error?

Using Flash Remoting and C# Assemblies? Getting an error like this?

Status (object #2)
…..code: “SERVER.PROCESSING”
…..description: “No Such Service com.yourpackage.YourClass with function yourMethod”
…..details: ” at FlashGateway.Delegates.ServiceCommander.InvokeAdapter(ActionContext flashContext)

Make sure that you don’t have the method marked as “static” in your C# class. I spent a couple hours yesterday trying to figure out why Flash Remoting couldn’t find the assemblies that were so obivously in the right spot. Obviously it was my fault for thinking too much (ie: Flash wouldn’t first get an instance of an object and then call a method on that instance, would it? doesn’t it make sense that it would be calling static methods?), but the documentation doesn’t use static methods… so slap my wrist.

.NET Flash Remoting: ASP.NET, ADO.NET, Webservices or Assemblies?

Spent some quality time with SQL Server 2000, .NET Assemblies, Flash Remoting and the DataGrid Component last night and this morning. My current project at work involves setting up a Flash client (which I won’t be writing), to talk to .NET via Flash Remoting. We’ll also be using ASP for other clients so the business logic that lives in multiple stored procedures on the database server can be accessed by both ASP and C#.

Anyway, last week I spent a couple hours getting up to speed on setting up .NET Remoting, specifically I wanted to know which .NET technology would be best suited to the job (you can use ADO.NET, ASP.NET pages, Web Services and Assemblies). If you download Flash Remoting for .NET and then install the Flash Remoting executable, you’ll get a subdirectory off of inetpub\wwwroot\ called ‘flashremoting’, which contains an example of the first three options mentioned above written in VB and C#. Long story short, using ADO.NET, ASP.NET pages or ASP Webservices didn’t strike me as the ‘best’. The ADO.NET version requires that you use register the flashgateway dll within your ASP.NET page like so:

<%@ Register TagPrefix=”Macromedia” Namespace=”FlashGateway” Assembly=”flashgateway” %>

and the code behind for the above page also is tightly coupled to Flash:

public class CustomerInfo : System.Web.UI.Page
  {
    //Define Objects needed for CustomerInto Class
    protected FlashGateway.Flash Flash;

The ASP.NET page looks like this:

<%@ Register TagPrefix=”Macromedia” Namespace=”FlashGateway” Assembly=”flashgateway” %>
<%@ Page language=”c#” debug=”true” %>
This line is available only when the page is viewed through a web browser.
<Macromedia:Flash ID=”Flash” runat=”server”>

The Webservice example doesn’t presupposed it’s going to be used by Flash, which IMNSHO is a good thing. And while a Webservice is an excellent way of exposing your business logic to various non human clients, performance will never be as fast as a non-webservice call, which leaves us with Assemblies. Why didn’t Macromedia offer an Assembly example? 🙂

An assembly lives in the {applicationroot}/bin folder off your website and can be used by any other client. It doesn’t presuppose that it will be used with Flash (which means I have loose coupling of my apps and I can probably reuse this business logic anywhere else I want) and performance will be markedly better than a webservice (when not using the Flash Remoting client, which doesn’t *really* make a SOAP call to the Webservice). Anyway, for my own sake, here are my .NET Flash Remoting setup notes (which came from http://www.jasonmperry.com/articles/YahooQuoteTicker.aspx:

1) download and install .NET Flash Remoting

2) download and install Flash Remoting Components

3) copy the flashgateway.dll (which was probably installed into \inetpub\wwwroot\flashremoting\bin\) into the site you’re working on: \wwwroot\yourapplication\bin\

NOTE: /yourapplication/ must be marked as an ‘application’ within IIS

4) add
<httpModules>
  <add name=”GatewayController” type=”FlashGateway.Controller.GatewayController,flashgateway” />
</httpModules>

to your web.config file in /yourapplication/

5) create an empty file called ‘gateway.aspx’ in /yourapplication/

<%@ Page %>
<!– This file is intentionally blank. –>

6) write your Assembly in C#/VB.NET, compile and then publish it to the /yourapplication/bin folder where it should be happily co-existing along w/ the flashgateway.dll file you copied to this folder in step 3.

7) Open up FlashMX, do your dee-sign thing and then include something like in the Flash movie:

#include “NetServices.as”

////////////////////////////////////////////
// Inits Web Service
////////////////////////////////////////////

//creates connection to ASP.Net web service
//should never ever run more than once!!
if( init == null )
{
  //insures this code block is only run once
  init = true;

  // point flash to the flash remoting gateway
  NetServices.setDefaultGatewayURL(“http://localhost/yourapplication/gateway.aspx”);
  gatewayConnnection = NetServices.createGatewayConnection();

  // register your service w/ flash, substituting com.packagename.Classname for the package and name of the C#/VB.NET class you wrote and have installed to /yourapplication/bin/
  myService = gatewayConnnection.getService(“com.packagename.Classname”, this);

}

// call a method on the service you’re written
myService.getProducts();

….

Hope that helps someone!

Further resources:

Flash Remoting Docs: [source]
ASP.NET assemblies in Flash: [source]
Flash Remoting Sample Applications: [source]
Flash Remoting Development Center: [source] (where is the .NET category BTW? how about some more .NET examples MACR?!!?)
Viewing Flash Remoting log entries: Flash Remoting MX writes error messages to the flash.log file in the local assembly cache. You can change the log file settings in the Windows Registry. The Flash Remoting registry keys are located at HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\Flash Remoting\1\Registration.

Flash Remoting & ColdFusion example

As part of our development process at work, we extensively use a bug tracking application I built about 1.5 years ago. Commonly, our QA team will rake through a site during and after the development process, entering bugs into this application in a different browser window. Additionally, if a client encounters an error on their site, they can create a ‘ticket’ and view the status of tickets created in the past, again, all in a dedicated browser window. I thought it would be cool to be able to incorporate our bug tracking application into other applications, letting QA, development, and clients view and create tickets from their own site, which means either taking code from the bug tracking application and porting into each of our clients sites (written in Java, ColdFusion, ColdFusion MX, ASP, PHP…) *or* use Flash to call the bug tracking application remotely. So today and yesterday I spent some time working with Flash, specifically I used:

— Flash MX to parse an XML packet that came from …
— a web service built using .NET through …
ColdFusion MX remoting

Pretty fun.. some questions (for anyone reading):
— how does one effectively debug Flash applications?
— what books would you recommend for a programmer learning to utilize Flash, specifically Actionscripting?

And finally, here’s my code, most of which is pieced together from various tutorials or components I found online (minus the sensitive usernames/passwords/hostnames):

#include “NetServices.as”
#include “NetDebug.as”

// a utility function used to pad string s with repeating instances of character c
// on the right, until it is n characters long altogether
function padr(s, n, c) {
var nLen = s.length;
for (var i=nLen; i 11627
// 10/23/2002 10:32:00 AM
// testing AJ
// 2
// 4
// Low
// New
// First
ticketid = new XML();
ticketid = elementList[0];
datecreated = new XML();
datecreated = elementList[1];
title = new XML();
title = elementList[2];
sLabel = padr(ticketid.firstChild.nodeValue, 10, ” “);
sLabel += “\t” + padr(datecreated.firstChild.nodeValue, 25, ” “);
sLabel += “\t” + padr(title.firstChild.nodeValue, 55, ” ” );
lbBugs.addItem(sLabel);
}

}

lbBugs.setRowCount(18);
lbBugs.setWidth(560); // note: setSize would wipe out setRowCount

// set this style on all components in movie
globalStyleFormat.textFont = “Verdana”;
globalStyleFormat.textSize = 11;
globalStyleFormat.applyChanges();

// apply a monospace font to the listbox for an attempt at controlling column spacing
var monospaceStyle = new FStyleFormat( {textFont:”Courier”, textSize:9} );
monospaceStyle.addListener(lbBugs);

// format for pushbuttons only
// add listener to this when each pushbutton is attached
var centerFontStyle = new FStyleFormat( {textAlign:”center”} );

if (init == null)
{
init = true;

// set the default gateway URL (this is used only in authoring)
NetServices.setDefaultGatewayUrl(“http://localhost:8500/flashservices/gateway”);

// connect to the gateway
gateway_conn = NetServices.createGatewayConnection();

// get a reference to a service
myService = gateway_conn.getService(“http://yourHost/soap/tracker.asmx?WSDL”, this);
}

dataLoad();

stop();

Information Week on the rich internet

Information Week on the rich internet. Relevant quotes:

“‘We had a pretty strong sense that we were losing customers,’ says VP of IS Dennis Shockro (at Yankee Candle). The $380 million-a-year company also couldn’t tell how many customers bought products online or by telephone.” >> This is a rich internet problem? Sounds to me like you have a poorly designed server side software application, not a problem with the presentation layer.

More… “Forrester Research has coined the term “executable Internet” to describe these Web applications–largely based on Macromedia Inc.’s new line of Flash MX software–that harness computers’ local processing power. ‘HTML pages are extremely limited in functionality,’ says Harley Manning, a Forrester analyst. ‘The interactivity drops to almost none.'” >> Ironic that the web was originally christened as bringing interactivity to the consumer… we were supposed to be leaving the one way communication to the radio and television and living this new exciting ‘interactive’ revolution through the Web, but now that turns out to be false, at least according to Harley. I’ve been living a lie! The web isn’t interactive! We need Flash to have interactivity!

Most interesting though: “And sources say Microsoft is developing a new Windows user interface, code-named Avalon, based on vector graphics, and due in a future version of Windows code-named Longhorn.” If it’s cross platform, say goodbye to Flash. Course, is Avalon really all about vector graphics? This story makes it seem like it’s a different kind of UI, something entirely different than the ability to bring interactivity to the web browser… And this article portays it as “… a layer of plumbing that will extend the existing Win32 development platform at the heart of Windows by building in support for the Longhorn networking, storage, digital-rights-management and graphics enhancements that Microsoft plans to build into Longhorn.”

Jeremy’s video mail application

Jeremy’s put up a video mail application on his blog… Jim and I were talking about how cool it would be to send not just a Flash movie to a mail box, but to actually send a *live* Flash video to a mailbox. Would it be possible to send an email to a user w/ an embedded Flash movie which calls a remote server on open of the email… which then alerts let’s say a salesperson that so and so has opened the email… the salesperson could then start a dialog w/ the person via Flash MX Communication Server. Freaky (if someone could recognize that a) you opened an email from them and b) that they could then talk to you from your inbox), but cool.