Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 08:50
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  Flash Remoting with AMF (Moderators: Flash-db, Musicman, Jorge Solis, papachan, nothingGrinder)
| | |-+  Duplicate function problem with the loading dynamic data
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Duplicate function problem with the loading dynamic data  (Read 3683 times)
neas
Server what's that
*
Posts: 3


View Profile Email
« on: 05/02/09, 21:33 »

Im getting the duplicate function error and I cant seem to get around it. The duplicate function is the onFault. When I remove one, or try to rename it, it comlpetely bugs out.

On one frame.
Code:
stop();
var myServiceUser = new NetConnection();
myServiceUser.connect("http://localhost.com/amfphp/gateway.php");
var responder=new Responder(getUsers_Result,onFault);
myServiceUser.call("Users.getUsers", responder);
//Result handlers
function getUsers_Result(rs:Object) {
//for(var i in rs.serverInfo) trace(i+":"+rs.serverInfo[i])     
var cant:Number=rs.serverInfo.totalCount;
//how many rows are in our recordset?   
for (var i=0; i<cant; i++) {
userinfo.text=rs.serverInfo.initialData[0];
}
}
function onFault(f:Object ) {
//trace("There was a problem: " + f.description);
}

On a different frame.

Code:
var myServiceAcc = new NetConnection();
myServiceAcc.connect("http://localhost.com/amfphp/gateway.php");
var responder=new Responder(getUsers_Result,onFault);
myServiceAcc.call("Users.getUsers", responder);
//Result handlers
function getAcc_Result(rs:Object) {
//for(var i in rs.serverInfo) trace(i+":"+rs.serverInfo[i])     
var cant:Number=rs.serverInfo.totalCount;
//how many rows are in our recordset?     
for (var i=0; i<cant; i++) {
acctinfo.text=rs.serverInfo.initialData[1];
}
}
function onFault(f:Object ) {
//trace("There was a problem: " + f.description);
}

Anyway I can use both? I need them both for flash remoting user information on to the stage.
Thanks,
neas
« Last Edit: 05/04/09, 07:57 by Jorge Solis » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #1 on: 05/03/09, 03:13 »

fact is - you cannot have the same function name in a single movieclip.

you either change the name, or you reorganize it in any other way.

For a clean code management, you should use the complete code in the same frame (frame 0).

If you need frame dependant code, you can call a function.

Be aware, reentering the frame with code means reinitialisation and reinstantiation of objects. This makes things more complex than they need to be Wink
Logged

happy flashing
Cool
Ronald
neas
Server what's that
*
Posts: 3


View Profile Email
« Reply #2 on: 05/03/09, 13:10 »

Thanks, I managed to figure it out. But I get errors on this code trying to make a little online store.
var responder=new Responder(insertHotdog_Result);
insertHotdog_Result = function(msg){

and so on for the others....

Code.


Code:
import flash.net.NetConnection;
import flash.net.Responder;

var myService = new NetConnection();
myService.connect("http://localhost.com/amfphp/gateway.php");


hotdog_btn.addEventListener("mouseDown", insertHotdog);
beer_btn.addEventListener("mouseDown", insertBeer);
lite_btn.addEventListener("mouseDown", insertLite);
cs_btn.addEventListener("mouseDown", insertCS);
pop_btn.addEventListener("mouseDown", insertPop);
soda_btn.addEventListener("mouseDown", insertSoda);

//Result handlers


function insertHotdog(evt:MouseEvent) {
var responder=new Responder(insertHotdog_Result);
//Call the insert titles function
myService.call("Purchase.insertPurchase", responder, "", "n", "n", "101", "1", "1", "4", "Hot Dog");

}

function insertBeer(evt:MouseEvent) {
var responder=new Responder(insertBeer_Result);
//Call the insert titles function
myService.call("Purchase.insertPurchase", responder, "", "n", "n", "101", "1", "1", "6", "Beer");
}

function insertLite(evt:MouseEvent) {
var responder=new Responder(insertLite_Result);
//Call the insert titles function
myService.call("Purchase.insertPurchase", responder, "", "n", "n", "101", "1", "1", "6", "Lite Beer");
}

function insertSoda(evt:MouseEvent) {
var responder=new Responder(insertSoda_Result);
//Call the insert titles function
myService.call("Purchase.insertPurchase", responder, "", "n", "n", "101", "1", "1", "5", "Soda");
}

function insertCS(evt:MouseEvent) {
var responder=new Responder(insertCS_Result);
//Call the insert titles function
myService.call("Purchase.insertPurchase", responder, "", "n", "n", "101", "1", "1", "7", "Cheesesteak");
}

function insertPop(evt:MouseEvent) {
var responder=new Responder(insertPop_Result);
//Call the insert titles function
myService.call("Purchase.insertPurchase", responder, "", "n", "n", "101", "1", "1", "5", "Pop Corn");
}


//Service request handler
insertTitles_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(2)
  }  else gotoAndStop(3)
}
insertBeer_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(1)
  }  else gotoAndStop(3)
};

insertHotdog_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(1)
  }  else gotoAndStop(3)
};

insertLite_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(1)
  }  else gotoAndStop(3)
};

insertSoda_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(1)
  }  else gotoAndStop(3)
};

insertCS_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(1)
  }  else gotoAndStop(3)
};

insertPop_Result = function(msg){
  if(msg=="Ok") {
  gotoAndStop(1)
  }  else gotoAndStop(3)
};

stop();

It works in a seperate swf, but not my main project where I do have the above functions in waiting for the user information to be pulled in

Thanks,
neas
« Last Edit: 05/03/09, 13:12 by neas » Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything