a few questions from newbies.

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

kain
Posts: 4
Joined: 10 Aug 2005, 02:40

a few questions from newbies.

Postby kain » 10 Aug 2005, 03:09

hi Lapo,

I'm learning to write some multi-user application using the SFS socket server. Your documents is good and easy to understand, but when I tried to wrote some simplest code I found it didn't work. can you help me to see where is the mistake I've written?


// setting variables
move = new Object();
move.px = 100;
move.py = 200;

// action on a buttons called test_btn
on (release) {
smartfox.sendObject(move)
}

// receive object event
// there are 2 dynamic texts called test_text_x , test_text_y
// and a mc called test_mc
smartFox.onObjectReceived = function(obj:Object, user:User)
{
test_text_x.text = user.getVariable("px")
test_text_y.text = user.getVariable("py")
test_mc._x = user.getVariable("px")
test_mc._y = user.getVariable("py")
trace("User: " + obj.getName() + " is now located at " + px + ", " + py)
}


as you can see, most of the codes are copied from your tutorial.
I added these codes to the pro_smartFoxTris.fla game scene.
I opened 2 swf to test put the functions
as a result, when I pressed the button, the output windows trace something have been sent or recieved, but the texts and the postion of test_mc didn't moved. what's wrong with my code?

==============================================

also, I'm trying to put the application inside a website. Is it possible to get the login and password from the database so that it don't need to login in again after I login to the website?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Aug 2005, 07:48

Quickly:

1) you use both smartfox and smartFox for the same variable... that can be a problem if you use Actionscript 2.0 and in general is a mistake. Please decide which way you want to call that variable and use just one name

2) Why do you use getVariable() in the function that handles the object?
The 1st obj parameter in the onObjectReceived function IS the object sent by the other user!

The code should look like this:

Code: Select all

smartFox.onObjectReceived = function(obj:Object, user:User)
{
   test_text_x.text = obj.px
   test_text_y.text = obj.py
   test_mc._x = obj.px
   test_mc._y = obj.py
}


:)
Lapo
--
gotoAndPlay()
...addicted to flash games
kain
Posts: 4
Joined: 10 Aug 2005, 02:40

Postby kain » 10 Aug 2005, 08:27

thx lapo. after change the captial letter into lowercase
it works.

what about the login questions?

also, I'm trying to put the application inside a website. Is it possible to get the login and password from the database so that it don't need to login in again after I login to the website?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Aug 2005, 11:05

Yes of course.
If when you launch the chat/game you're already logged in the website, just send the user name automatically to SmartFoxServer instead of showing a login screen...

:)
Lapo

--

gotoAndPlay()

...addicted to flash games
kain
Posts: 4
Joined: 10 Aug 2005, 02:40

Postby kain » 12 Aug 2005, 06:00

thanks again for ur informations.

Now I've setuped the SFS on my server, going on to the applications.
I edited form the SimpleChat.fla. when I published it (with the server IP and port) and run the swf in my PC it functioned normally, but when I put the swf on the web, it could not be connected. I wonder if the file should place under a specific place?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Aug 2005, 08:58

This is the most common problem that arises when it's time to publish something on the web.

The flash player has security restrictions when used in the web browser and you should understand them.

Please read this post >> viewtopic.php?t=73

Also if you search for "player restriction" in this board you can find many discussion about this topic.

:)
Lapo

--

gotoAndPlay()

...addicted to flash games
sandwichs
Posts: 12
Joined: 26 Feb 2006, 04:08

Postby sandwichs » 11 Mar 2006, 21:19

whenI try to do that, I get a warning saying NULL value

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 50 guests