| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Apr 2003
Posts: 1
|
hey
I posted this problem other places but it seems no one knows. Hopefull someone here can help I am having a problem with the registerClass method of the Application object. I searched numerous resources and found nothing that helped. Right now I'm just going by the Macromedia documentation and it's pretty unclear(to me anyways). I'm not having a problem accessing properties of an object I pass from the client to server. In fact, it doesn't even appear that I have to register the class with the application object for this to work. The problem is, everytime I try to call a method of an object passed from the client to the server I get "TypeError: class_obj.set_id is not a function". here is the code I'm using on the client side _________________________________________ #include "netdebug.as" stop(); client=new NetConnection(); client.onStatus=function(info){ for(var i in info){ trace(i + ": " + info[i]); } }; client.ahole=function(cobj){ trace("Bam"); trace(cobj.class_id); }; a=new my_class(); a.class_id=6; client.connect("rtmp:/RegisterClass"); client.call("test_class", null, a, client); function my_class(){ this.class_id=null; } my_class.prototype.set_id=function(new_id){ this.class_id=new_id; }; _______________________________________________ and here is the code I'm using in the main.asc file _______________________________________________ function my_class(){ this.class_id=null; } my_class.prototype.set_id=function(new_id){ this.class_id=new_id; } application.onAppStart=function(){ trace("Starting App"); } application.onConnect=function(new_client){ this.acceptConnection(new_client); } Client.prototype.test_class=function(class_obj){ class_obj.set_id(5); this.call("ahole", null, class_obj); } __________________________________________________ __ Hopefully someone has done this succesfully before and can point me in the right direction. Thanks in advance for any help. cfm |
|
|
|
|
|
#2 |
|
Registered User
|
Hey, dude...
I've read your code for a while, I think I can understand what you wanna do, but I have a question to make: Why do you want to use this: ActionScript Code:
I would do it in another way: ActionScript Code:
I think it would make the same effect as you're expecting, no? There's one more thing I could see in your code: In your client side script, you've used a call function client.call("test_class", null, a, client); but in your server side, you got this function with wrong numbers of parameters: Client.prototype.test_class=function(class_obj){ class_obj.set_id(5); this.call("ahole", null, class_obj); } your call at client sends two parameters, and your server side script expects just one, right? I think it won't run. anyway, I didn't test anything... I'm just telling what I think would help... like you, I can't find nobody to help me with comm server questions. I hope that helps. Ah... there's one more thing! server side scripting is case sensitive... client side isn't... it's a big damn thing! C ya! Zerooito |
|
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|