alanteigne
07-21-2005, 05:23 PM
Hello, this is my first post here so I hope it works out. I am building a rather complex Flash App that uses various classes. Some of the classes have remoting calls in them to populate their data. For example, the WorkOrder class looks something like this (this is simplified for relevance, so ignore syntax errors or illogical stuff):
import mx.remoting.*
import mx.remoting.rpc.*
import mx.rpc.*
class WorkOrder {
private var woWO:String;
private var woType:String;
private var woStatus:String;
private var woDate:Date;
private var woDateDue:Date;
private var woCloseDate:Date;
private var woCloseReason:String;
private var woData:Object;
private var woDetails:Object;
private var projectDB;
public function WO(dbConn){
projectDB = dbConn;
}
public function getWOBasics(woNum, serviceID){
trace(projectDB);
var myWOBasics:PendingCall = projectDB.getWOBasics(woNum, serviceID);
myWOBasics.responder = new RelayResponder(this, "myWOBasics_Result", "myWOBasics_Fault");
}
private function myWOBasics_Result(re:ResultEvent){
trace("WO Basics remoting succeeded");
setWOData(re.result);
}
private function myWOBasics_Fault(re:FaultEvent){
trace("WO Basics remoting Failed");
}
public function setWOData(woResult:Object){
trace("setWOData "+woResult);
woData = woResult;
woWO = woResult.getItemAt(1);
woType = woResult.getItemAt(2);
woStatus = woResult.getItemAt(3);
woDate = woResult.getItemAt(4);
woDateDue = woResult.getItemAt(5);
woCloseDate = woResult.getItemAt(6);
woCloseReason = woResult.getItemAt(7);
}
public function getWOData():Object{
//trace("returning: "+uaRFSData);
return woData;
}
public function getWoWO():String{
trace("returning: "+woWO);
return woWO;
}
public function getWoType():String{
trace("returning: "+woType);
return woType;
}
public function getWoStatus():String{
trace("returning: "+woStatus);
return woStatus;
}
public function getWoDate():Date{
trace("returning: "+woDate);
return woDate;
}
public function getWoDateDue():Date{
trace("returning: "+woDateDue);
return woDateDue;
}
public function getWoCloseDate():Date{
trace("returning: "+woCloseDate);
return woCloseDate;
}
public function getWoCloseReason():String{
trace("returning: "+woCloseReason);
return woCloseReason;
}
To create an instance of this class, I use the following syntax:
var theWorkOrder:WorkOrder = new WorkOrder(myDbConnection);
theWorkOrder.getWOBasics(woNum, serviceID);
It works great. This creates and instance of a WorkOrder class, calls in "theWorkOrder", and invokes the method "getWOBasics" from the class, which uses remoting and a CFC to get the data from the DB.
All of this I understand. What I need help with is this:
I am using the data called via remoting to populate a datagrid and set up event handlers for clicking on the datagrid. How can I setup a function in the main timeline to run ONLY after the remoting call is finished? I don't want to call it from the actual class file under the remoting result, like:
private function myWOBasics_Result(re:ResultEvent){
trace("WO Basics remoting succeeded");
_root.callWhateverFunction();
setWOData(re.result);
}
...because I don't necessarily want the function every time that call is made. Can someone give me advice on how to do this? If I could invent something to do it, it would probably look something like this:
in the remoting result in the class file:
private function myWOBasics_Result(re:ResultEvent){
trace("WO Basics remoting succeeded");
_root.myWOBasicsComplete = true;
setWOData(re.result);
}
in the main timeline on a frame where I want the function to run:
var myWOBasicsComplete:Boolean;
myWOBasicsComplete.addListener("change", whatever);
whatever.change = function() {
trace("the data has been received, now do whatever with it");
}
then remove the listener when i didn't want the function to run when the remoting call is complete.
I'm pretty sure that's not possible, cause you can't have a listener on a boolean. I hope I've explained my plight reasonably well. Anyone have any ideas for me?
Thanks in advance,
Alan
import mx.remoting.*
import mx.remoting.rpc.*
import mx.rpc.*
class WorkOrder {
private var woWO:String;
private var woType:String;
private var woStatus:String;
private var woDate:Date;
private var woDateDue:Date;
private var woCloseDate:Date;
private var woCloseReason:String;
private var woData:Object;
private var woDetails:Object;
private var projectDB;
public function WO(dbConn){
projectDB = dbConn;
}
public function getWOBasics(woNum, serviceID){
trace(projectDB);
var myWOBasics:PendingCall = projectDB.getWOBasics(woNum, serviceID);
myWOBasics.responder = new RelayResponder(this, "myWOBasics_Result", "myWOBasics_Fault");
}
private function myWOBasics_Result(re:ResultEvent){
trace("WO Basics remoting succeeded");
setWOData(re.result);
}
private function myWOBasics_Fault(re:FaultEvent){
trace("WO Basics remoting Failed");
}
public function setWOData(woResult:Object){
trace("setWOData "+woResult);
woData = woResult;
woWO = woResult.getItemAt(1);
woType = woResult.getItemAt(2);
woStatus = woResult.getItemAt(3);
woDate = woResult.getItemAt(4);
woDateDue = woResult.getItemAt(5);
woCloseDate = woResult.getItemAt(6);
woCloseReason = woResult.getItemAt(7);
}
public function getWOData():Object{
//trace("returning: "+uaRFSData);
return woData;
}
public function getWoWO():String{
trace("returning: "+woWO);
return woWO;
}
public function getWoType():String{
trace("returning: "+woType);
return woType;
}
public function getWoStatus():String{
trace("returning: "+woStatus);
return woStatus;
}
public function getWoDate():Date{
trace("returning: "+woDate);
return woDate;
}
public function getWoDateDue():Date{
trace("returning: "+woDateDue);
return woDateDue;
}
public function getWoCloseDate():Date{
trace("returning: "+woCloseDate);
return woCloseDate;
}
public function getWoCloseReason():String{
trace("returning: "+woCloseReason);
return woCloseReason;
}
To create an instance of this class, I use the following syntax:
var theWorkOrder:WorkOrder = new WorkOrder(myDbConnection);
theWorkOrder.getWOBasics(woNum, serviceID);
It works great. This creates and instance of a WorkOrder class, calls in "theWorkOrder", and invokes the method "getWOBasics" from the class, which uses remoting and a CFC to get the data from the DB.
All of this I understand. What I need help with is this:
I am using the data called via remoting to populate a datagrid and set up event handlers for clicking on the datagrid. How can I setup a function in the main timeline to run ONLY after the remoting call is finished? I don't want to call it from the actual class file under the remoting result, like:
private function myWOBasics_Result(re:ResultEvent){
trace("WO Basics remoting succeeded");
_root.callWhateverFunction();
setWOData(re.result);
}
...because I don't necessarily want the function every time that call is made. Can someone give me advice on how to do this? If I could invent something to do it, it would probably look something like this:
in the remoting result in the class file:
private function myWOBasics_Result(re:ResultEvent){
trace("WO Basics remoting succeeded");
_root.myWOBasicsComplete = true;
setWOData(re.result);
}
in the main timeline on a frame where I want the function to run:
var myWOBasicsComplete:Boolean;
myWOBasicsComplete.addListener("change", whatever);
whatever.change = function() {
trace("the data has been received, now do whatever with it");
}
then remove the listener when i didn't want the function to run when the remoting call is complete.
I'm pretty sure that's not possible, cause you can't have a listener on a boolean. I hope I've explained my plight reasonably well. Anyone have any ideas for me?
Thanks in advance,
Alan