Hi,
This may be a bit off topic but here goes...
I'm converting a Director project from the MUS to Smartfox. I'm able to open up these [Obj obj] black boxes on the Flash side, and construct arrays to be sent to Director, but it's clunky. I'd rather have Director grab objects from the Flash sprite and then open them up on the Director side. The problem is that I can't find the lingo equivelent of:
for (var i in lUsersObj) {
//Get each user from the userlist
luser = (lUsersObj[i]);
Lname = luser["name"]+"";
id = luser["id"]+"";
}
specifically, what is th elingo equivelent of:
for (var i in lUsersObj) {
???
I can get the Flash object in, and some of them I can get properties for if I know the structure, but with a userlists I can't get the length of the array using userlist.length, or count(userlist) because it's like a property list using the pID number, which can be anything from 0 to a million....
I hope this makes sense. Any ideas?
Using [Obj obj] in Director
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Contact:
to do this
in lingo you do this
This is when you have a list (lUserObj) structured like this
[[#name:"Bill", #age:12], [#name: "Fred", #age: 99], [#name: "frank", #age: 118]]
(and you can have objects instread of propLists in that list)
Its worse if lUserOj is an Object instead of an list.
Then you will have to do something like this i think.
it might work with "repeat with x in y" on objects as well. That you will have to test.
Good Luck!
Code: Select all
for (var i in lUsersObj) {
luser = (lUsersObj[i]);
trace(luser["name"])
}
in lingo you do this
Code: Select all
repeat with luser in lUserObj
put luser.name
end repeat
This is when you have a list (lUserObj) structured like this
[[#name:"Bill", #age:12], [#name: "Fred", #age: 99], [#name: "frank", #age: 118]]
(and you can have objects instread of propLists in that list)
Its worse if lUserOj is an Object instead of an list.
Then you will have to do something like this i think.
Code: Select all
repeat with i = 1 to lUserObj.count
tKey = lUserObj.getPropAt(i)
tValue = luserObj[i]
end repeat
it might work with "repeat with x in y" on objects as well. That you will have to test.
Good Luck!
Nisse Bergman
Raketspel
Raketspel
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Contact:
Thank you so much
That was a head scratcher for me. This will make my code cleaner and more flexible. Thanks!
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Contact:
Actually....
I'm having a hard time.
I tried:
gRoomObj= sprite(gSFSprt).getVariable("gRoomObj", false)
gUsers = gRoomObj.getUserList()
put gUsers.ilk
repeat with user in gUsers
put "user=" && user.name
end repeat
end repeat
The gRoomObj comes in fine. The getUserList() function seems to work fine ; I don't get an error for that and gUsers.ilk= #FlashObject.
But I don't get any results from the repeat loop; it seems like it doesn't iterate through even once, so the "user in gUsers" isn't working.
User is another object. gRoomObj contains a userlist object that contains an object for each user.
Also, count(gUser) and gUser.length both come out <void> so that won't work.
gRoomObj.getUserCount() does work for seeign how many users are in the room.
-Carl
I tried:
gRoomObj= sprite(gSFSprt).getVariable("gRoomObj", false)
gUsers = gRoomObj.getUserList()
put gUsers.ilk
repeat with user in gUsers
put "user=" && user.name
end repeat
end repeat
The gRoomObj comes in fine. The getUserList() function seems to work fine ; I don't get an error for that and gUsers.ilk= #FlashObject.
But I don't get any results from the repeat loop; it seems like it doesn't iterate through even once, so the "user in gUsers" isn't working.
User is another object. gRoomObj contains a userlist object that contains an object for each user.
Also, count(gUser) and gUser.length both come out <void> so that won't work.
gRoomObj.getUserCount() does work for seeign how many users are in the room.
-Carl
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Contact:
Doesn't work
Oh well, that doesn't work. For now I'll go back to what I was doing before, which was extracting each user from the userlist on the Flash side and arranging them in a sensible linear list that I can then grab on the Director side and iterate through in a normal way...
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Contact:
Yes...
Yes, and we should talk about you doing an article on using SF in Director for
Shockwaveserver.com
I imagine you're the top expert on that, and it's a very specialized topic that is hard to find information on.
Shockwaveserver.com
I imagine you're the top expert on that, and it's a very specialized topic that is hard to find information on.
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 81 guests