Archive for April, 2002

ServerSide ActionScript Info

There have been some questions about documentation and examples for ServerSide ActionScript (included with ColdFusion MX to be used with Flash Remoting). There are five chapters on ServerSide ActionScript (SSAS) included with CFMX, and they are available from the main doc page. If you are running CF MX as a standalone server, you can access the documentation here (if CFMX is running), and here (as a pdf).
I have also put together a couple of simple examples of using ServerSide ActionScript


You might also want to check out the Rhino documentation since that is what the SSAS is built upon.

Example : loading data from a data base into Flash MX with Flash Remoting and ServerSide ActionScript

First, view the following tutorial / example:
Example : loading data from a data base into Flash MX with Flash Remoting and CF MX
we will use the same Flash MX code in that example, and just change the server side code.
Instead of creating a ColdFusion component called DbTest.cfc, create a file called DbTest.asr. Make sure that you rename the DbTest.cfc to something else if you did the first tutorial.
Add the following to the DbTest.asr file:

function getData()
{
 /**create an object to hold our parameters**/
 var queryData = new Object();
 
 /**set the DSN name pointing to the database**/
 queryData.datasource = “CompanyInfo”;
 /**setup our SQL Query**/
 queryData.sql = “select * from Employee”;
 /**Execute the query, and store the results in a variable**/
 var rs = CF.query(queryData);
 
 /**return the RecordSet to flash**/
 return rs;
}

You don’t need to change anything in the Flash code. Create the Flash movie according to the directions in the tutorial and test your movie.

Flash Player Detection : Moock FPI

This will be old news for some, but it is so useful i thought i would post it here. If you need some JavaScript code to do Flash player version detection, check out the the Moock FPI (Flash Player Inspector) that Colin Moock has put together. This is the best JavaScript Flash detection code I have seen.
Note : I am planning to integrate it into my site, but had some problems with Radio inserting HTML markup into my JavaScript. If anyone has any solutions, post them in the comments.
Update : Dave Winer sent me this link, which describes how to fix the problem with Radio inserting HTML markup whenever it see JavaScript comments.

Macromedia XML Resource Feed News

Check out the new  DWTeam DesDev Dreamweaver MX extension. It makes it ridiculously simple to add information from the Macromedia XML Resource Feed to web pages when creating them with Macromedia Dreamweaver MX. Simply open the panel, check the data you want to display, and you are done.
I also wanted to point out the Harnessing XML with Custom Tags or ColdFusion components articles at the ColdFusion MX Developers center. This uses the Macromedia XML Resource feed to show how to manipulate XML in ColdFusion MX.
Btw, there are still over two weeks to submit entries in the Macromedia XML Resource Feed contest. We have gotten some really cool entries thus far, but none that use ColdFusion MX.

Interview with Jeremy Allaire : Part 2

On a Future Macromedia Communications Server:
We’ll be introducing a new communications server later this year. It’s codenamed Tincan, and it allows you to build these communications applications.
You can do real-time shared audio and video. You can do real-time shared text. But more importantly you can do what’s called shared objects. Shared objects allow you take any object in a client in your application, a data object, or a user-interface object, and share that across a connected client. So I could have a collaborative application where multiple users are interacting with the data and the user interface. They may also be doing communications, they may also be speaking to one another and so on, but they may just be collaboratively interacting with a user interface and the data in it.
Lots of other interesting information in the interview including, Soap and WDDX, Soap interoperability issues, and ColdFusion MX and .NET.
[ITWriting.com]

Flash Remoting and PHP

I have been seeing a lot of questions about support for PHP with Flash Remoting. Currently, Flash Remoting doesn’t support PHP. As far as future support, we haven’t made any announcements concerning this, but we will be making some more announcements related to Flash Remoting in the near future.
Hope that helps…

Server Side ActionScript Tutorial

There is a new tutorial on Server Side ActionScript at Macromedia.com. Here is the description:
Building a Database Query Application with Server-Side ActionScript
In this module, you can learn how to build an application that searches a database using parameters provided by the user and displays the results in a rich Macromedia Flash user interface. It demonstrates two key features of ColdFusion MX: the built-in Macromedia Flash Remoting service and new support for Server-side ActionScript.

This was written by Christian Cantrell who will be speaking about Flash Remoting at FlashForward NYC.

Database data into Flash MX via Flash Remoting and ColdFusion MX

Ton of content today. I have put together a quick example showing how to use Flash Remoting and ColdFusion MX to load data from a database into Flash MX.
You can view it here.
Btw, I will be posting a ServerSide ActionScript example sometime tomorrow.

Example loading data from a data base into Flash MX with Flash Remoting and CF MX

Below is sample code that shows how to load data from a data base from Flash MX using Flash Remoting and ColdFusion components.
Download and install the ColdFusion MX preview release.
Download and install the Flash Remoting Addons for Flash MX.
You can download the files here.
First create a new ColdFusion component, name it DbTest.cfc and save it in wwwroot\com\macromedia\dbtest
Here is the component code:

<cfcomponent>
 <cffunction name=”getData” access=”remote” returntype=”query”>
  <!– CompanyInfo is a DSN name for an example DB that CFMX sets up by default –>
  <cfquery datasource=”CompanyInfo” name=”result”>
    select * from Employee
  </cfquery>
  <cfreturn result />
 </cffunction>
</cfcomponent>

Open Flash, and place a Combo Box component on the stage, and give it an instance name of “dataBox”
add the following ActionScript to the first frame of the Flash movie:
#include “NetServices.as”
#include “NetDebug.as”
/** we will use an instance of the Result class to capture
 the data from the server **/
Result = function()
{
}
/** onResult is called when data is loaded from the server.
 In this case, a RecordSet object will be passed to it **/
Result.prototype.onResult = function(rs)
{
 trace(“Data Received : ” + rs.getLength() + ” rows.”);
 
 //data box is a simple combo box on the stage.
 dataBox.setDataProvider(rs);
}
/** onStatus is called if any errors occur when communicating
 with the server **/
Result.prototype.onStatus = function(error)
{
 trace(“Error : ” + error.description);
}
/** set the location of the Flash Remoting gateway **/
NetServices.setDefaultGatewayURL(“http://localhost:8500/flashservices/gateway“);
var gw = NetServices.createGatewayConnection();
/** get a reference to the service on the server
 First param is the path to the service on the server
 Second param is the object to send the server response too **/
var server = gw.getService(“com.macromedia.dbtest.DbTest”, new Result());
/** call the remote method **/
server.getData();


Save your Flash movie, and test. You should see all of the data displayed in the combo box. If it is formatted weird, then make the combo box wider.
If you get any errors, open the NetConnection Debugger (Windows > NetConnection Debugger) and then retest your movie. This will show all of the communication between Flash and the server.
This is just a simple example, but shows how easy it is to do some pretty complex stuff in Flash MX with Flash Remoting.

Web Services, Optional Parameters and Flash MX and ColdFusion MX

If you are playing around with calling web services from Flash Remoting or ColdFusion MX, you have to pass all parameters to the web service even if they are not required.
From what i understand, this is an issue with the Axis code that CFMX uses for communicating with web services.