Groups | Blog | Home
all groups > macromedia flash flash remoting > august 2004 >

macromedia flash flash remoting : New vs. Old UI Components?


Xtort
8/20/2004 2:01:53 PM
I am reading the Oreilly book "Programming ColdFusion MX 6.2" by Rob
Brooks-Bilson. I have been programming CF for a few years, but I am new to the
Remoting Model. I updated my Flash 2004, and I am having trouble following the
examples in the book. My UI components don't operate in the same manor as the
ones in the book. THey even look different. For example, I am creating two
dynamic drop down boxes, when you select a name in the first box, it populates
the second box. Then you click on a pushbutton to retrieve all the user
information. Here is the code.

#include "NetServices.as"
#include "DataGlue.as"
#include "NetDebug.as"

// --------------------------------------------------
// Application initialization
// --------------------------------------------------
if (inited == null) {
// do this code only once
var inited = true;

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

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

// get a reference to a service
var myService = gateway_conn.getService("programmingcf.ch28.employee", this);
}

// --------------------------------------------------
// cb1 combo box
// --------------------------------------------------
//call the getDepartments() method
myService.getDepartments();

//Bind the results to the cb1 combo box using data glue
function getDepartments_Result (result) {
DataGlue.bindFormatStrings(cb1, result, "#Department#", "#Department#");
}

// --------------------------------------------------
// cb2 combo box
// --------------------------------------------------
// When a selection in the first combo box is made, call showEmployees()
cb1.setChangeHandler("showEmployees");

function showEmployees(component){
cb2.removeAll( );
myService.getEmployees(cb1.getSelectedItem( ).data);
cb2.addItem("loading...","");
}

function getEmployees_Result(result) {
cb2.removeAll();
for (var i = 0;i < result.items.length;i++) {
cb2.addItem(result.items.Name,result.items.ID);
}
}

// --------------------------------------------------
// Button handler and full record get/display
// --------------------------------------------------
// Retrieve the full employee record based on the employee selected
function employeeHandler(){
myService.getEmployee(cb2.getSelectedItem( ).data);
}

// Display the full employee record
function getEmployee_Result(result) {
dName.text = result.items[0].Name;
dTitle.text = result.items[0].Title;
dDepartment.text = result.items[0].Department;
dEmail.text = result.items[0].Email;
dPhoneExt.text = result.items[0].phoneExt;
}
stop();

This works great if I use the example provided with the book (the code
downloaded from oreilly's website). But the drop down box looks different than
the one I have. I have two lists in the Components window "Flash UI Components
Set 2" and "UI Components". I am pulling them from the "UI Components" section.

Something I have noticed is that in my combo boxes, I can change the options
in the Component Inspector, but not in theirs. It is as if they are using an
older version of the boxes. That's fine, but how do I get the data to work with
mine? When I run the .swf file in Flash, they are blank, I don't even get the
drop down arrow. Clearly it is not bound to something it needs to be, right?

As always, thank you for educating me!

Pauly
Matt Voerman (TMM)
8/21/2004 12:21:04 PM
Hey Pauly,
With the release of FMX2004 Macromedia released a completely revised set
of components that use ActionScript 2.0 (rather than ActionScript 1.0).

They new components do look (and behave) lightly differently than the
older ones (in FMX).

You can still use V1 components in FMX04 but Macromedia recommends
against this. The reason being that that V1 components haven't been
optimised to run under FMX04 and as such can produce unpredictable
results/errors. They may work fine...but then again they might not.

I suggest you just stick with the V2 components in FMX04 and you should
be ok.


Cheers
Matt Voerman - TMM Member

[quoted text, click to view]
Xtort
8/24/2004 12:20:43 AM
By looking at the code, can you help me figure out how to get it to work with
the new components? Shouldn't it still work? The code on the CFC does a simple
query and then returns the response, but it doesn't populate the list. WHat am
I doing wrong?
Xtort
8/24/2004 3:12:12 AM
Matt Voerman (TMM)
8/24/2004 8:52:42 AM
It doesn't have anything to do with the bindings. V1 components use
ActionScript 1.0 where as V2 components use...you guessed it
ActionScript 2.0.

My suggestion would be to start form scratch using only the V2
componentns in FMX04.



[quoted text, click to view]
chimeran
9/6/2004 9:59:13 PM
xtort,

i'm facing exactly the same problem as you do. i can easily populate my
dropdown box with myDropDownBox.setDateProvider(recordSet) but fail to do it by
dataglue.bindFormatStrings(myDropDownBox, recordSet, "#text#", "#ID#").
did you find out how to code this properly using AS2.0?
cheers
Xtort
9/6/2004 10:24:34 PM
I haven't gotten back to look at it yet. I have been working on the CFML code
first. Strange thing is that if I use the old components it works fine, but I
can't find the old components in 2004. Is there a way I can upload the old UI
components for use in the Flash 2004 environment?

axcfalr';ql
9/6/2004 11:23:22 PM
v1, v2, AS1, AS2, MX, MX2004 ... whew! It's tough keeping up and trying to
sort all of this stuff out.

At the following URL there are 3 different links:
http://www.macromedia.com/software/flashremoting/downloads/components/

The 3 links are for:
* Macromedia Flash Remoting for Flash MX 2004 ActionScript 2.0
* Flash Remoting Components ActionScript 1.0 for Flash MX 2004 and Flash
MX Professional 2004
* Flash Remoting Components for Flash MX

One of them will probably meet your requirements.
Xtort
9/6/2004 11:36:25 PM
Originally posted by: axcfalr';ql
v1, v2, AS1, AS2, MX, MX2004 ... whew! It's tough keeping up and trying to
sort all of this stuff out.

At the following URL there are 3 different links:
http://www.macromedia.com/software/flashremoting/downloads/components/

The 3 links are for:
* Macromedia Flash Remoting for Flash MX 2004 ActionScript 2.0
* Flash Remoting Components ActionScript 1.0 for Flash MX 2004 and Flash
MX Professional 2004
* Flash Remoting Components for Flash MX

One of them will probably meet your requirements.



No kidding! Especially if you are new to this arena, coming from ColdFusion.
:) I will check out the URL, thanks!
jeffcg2
9/6/2004 11:44:43 PM
http://www.macromedia.com/devnet/mx/trio/articles/trio_widget2004_print.html

Take a look at this sample. It has the beginnings of a decent example using
the AS 2 components.
The code is in there for populating a dropdown.

If you look at the included workorders.cfc it looks like he intends to build
on the example for something helpful.
You could look at the thread I start right now its just below this one for my
ramblings.
axcfalr';ql
9/6/2004 11:58:49 PM
fyi ... though MX 2004 and AS2 were released Sept '03, it wasn't until June '04
that Macromedia released "Remoting for Flash MX 2004 ActionScript 2.0" ... thus
there currently is scant little published about using Remoting for Flash MX
2004 ... and certainly NOT in any of the books currenlty in the stores ...

If you want to go with the latest and greatest (as Matt Voerman suggested
earlier), you can by going straight to the source with these links at
Macromedia.com:
http://livedocs.macromedia.com/flashremoting/mx2004/index.html

http://download.macromedia.com/pub/documentation/en/flash_remoting/mx2004/usingf
lashremoting_en.pdf
http://www.macromedia.com/devnet/mx/trio/articles/trio_widget2004.html

As one cf'er to another, I hth ...
axcfalr';ql
9/7/2004 12:33:14 AM
btw ... Flash offers an alternative to Remoting --> WebServiceConnector &
WebServices API

for a very brief overview (6 paragraphs) go to
Differences Between the WebServiceConnector, WebServices API, and Flash
Remoting
http://www.macromedia.com/devnet/mx/flash/articles/flmxpro_webservices_04.html

For a more involved overview see
Choosing Between XML, Web Services, and Remoting for Rich Internet Applications
http://www.macromedia.com/devnet/mx/flash/articles/ria_dataservices.html

On the ColdFusion side, both Remoting and WebServices can call the same CFC.
It is only different how things are handled on the Flash side.

Again, hth ...
Xtort
9/7/2004 1:13:47 AM
Awesome! Thanks I really appreciate the heads up. I have the entire program
running in CFM using CFC's and DHTML, but I wanted to make a flashier front end
for the actual end product. I will read the pages you sent, and again thanks.

Pauly
AddThis Social Bookmark Button