Welcome, Guest. Please login or register.
Did you miss your activation email?
02/08/12, 09:43
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)
| | |-+  AS (amfphp) function calling problem
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: AS (amfphp) function calling problem  (Read 1398 times)
Basu
Server what's that
*
Posts: 11



View Profile Email
« on: 08/10/04, 21:20 »

Hello,

I've spent 2 days trying to solve this, finally thought I would request the help of flash-db again.
I'm creating this chat application using Flash MX and PHP, MySQL and AMFPHP handling flash remoting.
As per the norm of AMFPHP I've one main function which has sub-functions, one of which takes care of verifying login information (successfully), one does some other updates and the third one is supposed to send and receive the actual messages from the server. This function (send_msg) should send the message and user information once the user enters text in the input window and presses the button or enter key.

The problem is I'm not able to call the function properly so that it sends all the required information. It is either getting called with blank msg before the user enters any information or it is not getting called at all.
I'm attaching the relevant AS code below:

 ....
 this.authenticate_Result = function(result){
   if(result == True) {
     service.updchatmaster();  // updates chat_h table
   }
   else {
     status_txt.text = "Connection Unsuccessful. Please try again";         
   }
 }
   
 this.updchatmaster_Result = function(result){
   if(result > 0) {
         chat_session_id = result;
         Selection.setFocus(input_txt);
     if (input_txt.text.length<1) {
       Selection.setFocus(input_txt);
         }
     else {
       submit_btn.onRelease = service.send_msg(chat_session_id, input_txt.text); // send msg
     }
    }
 }  

 this.send_msg_Result = function(result){
   if(result.length>0) {
     output_txt.text = output_txt.text + result + "\n";
     input_txt.text = "";
     Selection.setFocus(input_txt);
   }
 }
}
login_submit_btn.setClickHandler("login"); // main function

input_txt - textbox where people type their msg
output_txt - chat output window where msgs will be displayed
submit_btn - button which has to be clicked to send the user's msg to the server

I know the problem explanation is kind of long but I hope it is clear enough for people to understand. I would greatly appreciate any help to resolve this problem.
Logged
zee taher
Senior Programmer
****
Posts: 302



View Profile Email
« Reply #1 on: 08/12/04, 09:22 »

try making a function out of the submit_bt.on realease
and trace something to the screen
make sure the that is working.  and then put in the code you need instead of the trace.
Logged
Basu
Server what's that
*
Posts: 11



View Profile Email
« Reply #2 on: 08/12/04, 20:02 »

Yes, I did try putting trace calls but the problem still is if the trace calls are made outside the if loop, then only it's called. But if I put the send_msg function outside if, then it is called before the user gets a chance to type anything in the chat input box. And the send_msg call inside the if loop is never getting called at all inspite of mouse clicks and enter keypress.

Selection.setFocus(input_txt);
trace("before if");
    if (input_txt.text.length<1) {
      Selection.setFocus(input_txt);
         }
    else {
      trace("inside else");
      submit_btn.onRelease = service.send_msg(chat_session_id, input_txt.text); // send msg
    }

Thanks for your suggestion anyways. I would appreciate more suggestions to solve the issue.
Logged
Basu
Server what's that
*
Posts: 11



View Profile Email
« Reply #3 on: 08/15/04, 20:49 »

Ok, I finally solved the problem  Smiley and thought I would post it here if someone else gets stuck with the same issue.

I simply called the amfphp function inside a mouse event function:

submit_btn.onPress = function() {
 service.send_msg(chat_session_id, user_id_txt.text, nick_name_txt.text, input_txt.text);
 if (input_txt.text.length<1) {
     Selection.setFocus(input_txt);
 }
}
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6162


View Profile WWW Email
« Reply #4 on: 08/23/04, 14:41 »

If you put youre code blank into a frame, it is called, whenever the frame pointer comes by.

After all these functions, and everything else we are programing, is event driven, you have to find the right event to trigger youre calls.
Logged

happy flashing
Cool
Ronald
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!