I'm trying to convert my game to AS3 for a while now and haven't had any problems with SFS so far (basically because everything is so much clear on AS3). Well til now
When I got to the buddy variables I kept having this error during runtime:
Code: Select all
TypeError: Error #1034: Type Coercion failed: cannot convert Object@363dfb01 to Array
at ederon_tw_fla::MainTimeline/onJoinRoom()
at flash.events::
.........
After using this which is very similar to what described on the online docs for AS3 (Which was also pretty similar to what I had on AS2):
Code: Select all
var bVars:Object = new Object()
bVars["chatRoom"] = "1"
bVars["inGame"] = "0"
smartFox.setBuddyVariables(bVars)
Then after some search I found this on the advancedBuddyList example:
Code: Select all
var vars:Array = []
vars[tf_varKey.text] = tf_varValue.text
sfs.setBuddyVariables( vars )
which converted to my needs looked like this:
Code: Select all
var sendBObj:Array = [];
sendBObj["chatRoom"] = "1";
sendBObj["inGame"] = "0";
sfs.setBuddyVariables(sendBObj);
Both advancedBuddyList and my game now works without triggering a SFS runtime error.
After that I kinda felt a bit lost on all my learning progress lol. What exactly is the difference between them, and following the same line of thought, whats the difference between
var myArr:Array = new Array()
and
var myArr:Array = []
And why does SFS only understands the second one?