PDA

View Full Version : Flash Remoting AMFPHP double connection to service.


usa_hodson
03-09-2005, 10:33 PM
I previously asked a remoting question which noone seemed able to help me with - hopefully this time someone with some remoting experience will be lurking on the forum.

I'm writing a somewhat enormous program in Actionscript which is an extension course for the teaching of Financial Management in English secondary schools. I have chosen to interact with a MySQL database comprising 21 tables through PHP by using the AMFPHP tools.

The very first screen when the movie has been loaded is a login screen which is supposed to load a list of schools for the user to choose from into a combobox. The user chooses his / her school, enters their username and password and clicks submit.

Usually I do my work by placing code within frames or on buttons. This time all of my code is within an external .as file which I include on the login screen in an actions layer to make it simpler to manage:

# "enterprise.as"

However, I want the combobox to be filled when the frame is entered - the simplest way seeming to make a connection to the appropriate service separately in my 'actions' layer in the movie itself, and calling the function from there. This leaves me with two defined connections to the same php file in the same movie I think:

// Stop the movie from proceeding past the login screen
stop();
//Remove the menu on right click from appearing
Stage.showMenu = false;
// Include files necessary for Remoting debugging and coding
//#include "NetDebug.as"
#include "NetServices.as"
#include "enterprise.as" //Another connection is defined within this...

// Establish connection to PHP Remoting
NetServices.setDefaultGatewayUrl("http://www.getwithit.info/enterprise/gateway.php");
conn = NetServices.createGatewayConnection("http://www.getwithit.info/enterprise/gateway.php");

// Retrieve service (login service, defined in ./services/login.php)
svc = conn.getService("login", this);

//Set the combobox to display a loading message
loginSchoolChooser.addItem("Loading ...")

//////////////////////////////////////////////////////////
// We need to fill the combobox on the login screen with
// a list of schools from the database. We will use the
// results from the 'getSchools' method.
//////////////////////////////////////////////////////////

svc.getSchools();

//define the result handler for 'getSchools'
getSchools_Result = function(rsData){
//trace(rsData) //tests for reply from php file
cant = rsData.length //number of data to insert
loginSchoolChooser.removeAll() //clear loading message
//Pass data to the combobox
for(var i=0; i<cant; i++){ //Loops through results
loginSchoolChooser.addItem(rsData.getItemAt(i).sna mes)
}
}



The net result of this, is that my combobox.text displays 'Loading...' but doesn't load anything.

I'm having some other problems too - in fact I've written 2,500 lines of code and currently nothing happens. I think that I have some problems with addEventListener definitions within the .as file executing - but I'll try and get this first hurdle sorted before attempting to explain others.

Thankyou very much for any help you can give me - I've spent the last 24 hours straight trying hundreds of alterations and searching websites for some answers,

Sincerely,

James.