Forum General about addMessageHandler

Any issues or discussions relating to Flash development are welcome here.

about addMessageHandler

Postby lombee » September 27th, 2013, 10:58 am

Hi all,

Im trying to add some value to the handler but i can't seem to get it.
this is its default values

Code: Select all
connection.addMessageHandler("start", function(m:Message, userid:String, username:String, x:int, y:int)

Code: Select all
connection.send("start", mouseX, mouseY)


and this is what i did to get that value added

Code: Select all
connection.addMessageHandler("start", function(m:Message, userid:String, username:String, x:int, y:int, example:String)

Code: Select all
connection.send("start", mouseX, mouseY, example)


as you can see i added value "example" to the arguements and this is what the error says
ArgumentError: Error #1063: Argument count mismatch on MethodInfo-396(). Expected 6, got 5.
at Function/http://adobe.com/AS3/2006/builtin::apply()
at bridge::Connection/handleMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at bridge.utils::BinarySerializer/onMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at MessageBuilder/AddValue()
at bridge.utils::BinarySerializer/onValue()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at TokenBuilder/AddByte()
at bridge.utils::BinarySerializer/AddByte()
at <anonymous>()


i totally get the idea of expected arguements but am i doing it right? or am i missing something?

P.S.: maybe im posting it in the wrong thread, feel free to move it, thanks :D
lombee
 
Posts: 3
Joined: September 18th, 2013, 3:49 am

Re: about addMessageHandler

Postby lombee » October 1st, 2013, 10:39 am

why is everybody just viewing it? :( :( :(
lombee
 
Posts: 3
Joined: September 18th, 2013, 3:49 am

Re: about addMessageHandler

Postby mindbogglegames » October 1st, 2013, 6:36 pm

the function being invoked only takes one argument Message

in the message you can get all the parameters that are sent from server

example
_connection.addMessageHandler("tutorialItemGiven", onTutorialItemGiven);

private function onTutorialItemGiven(m:Message):void
{
var itemUId:String = m.getString(0);


}


So your example should look more like this

connection.addMessageHandler("start", function(m:Message)
{

var userid:String = m.getString(0);
var username:String = m.getString(1);
var x:int = m.getInt(2);
var y:int = m.getInt(3);
var example:String = m.getString(4);

});
mindbogglegames
Paid Member
 
Posts: 38
Joined: December 19th, 2011, 6:51 pm

Re: about addMessageHandler

Postby lombee » October 2nd, 2013, 6:36 am

thanks for replying, i will surely try it soon
lombee
 
Posts: 3
Joined: September 18th, 2013, 3:49 am


Return to General



cron