Help With my first SmartFoxServer Prog

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

Moderators: Lapo, Bax

jt3w
Posts: 5
Joined: 17 Sep 2009, 22:21

Help With my first SmartFoxServer Prog

Postby jt3w » 17 Sep 2009, 22:42

Ok I have been trying to figure out how to wright a program using this to connect to my server. My server works I tryed it will all the samples and such. Now I am pretty good with As3.0 so that is what I have been trying to wright my stuff in.

1. What do i need to do to get this to work. I tryed to use the template for as3.0 that came with it and i tryed to run it and got this error

/////////////////////////////////////////////////////////////////////////////////
SecurityError: Error #2010: Local-with-filesystem SWF files are not permitted to use sockets.
at flash.net::Socket/internalConnect()
at flash.net::Socket/connect()
at it.gotoandplay.smartfoxserver::SmartFoxClient/connect()
at it.gotoandplay.smartfoxserver::SmartFoxClient/onConfigLoadSuccess()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
//////////////////////////////////////////////////////////////////////////////////

Then I tryed wrighting my own code with out the template just to connect to my sever and this is what happend. If i had the SmartFoxClinet.as file in the same folder I got an error like this

////////////////////////////////////////////////////////////////////////////////////
5007: An ActionScript file must have at least one externally visible definition.
/////////////////////////////////////////////////////////////////////////////////////

And if i did not have that file in there I got these errors

/////////////////////////////////////////////////////////////////////////////////////
1120: Access of undefined property ip.
1120: Access of undefined property port.
1120: Access of undefined property zone.
1120: Access of undefined property smartfox.
1180: Call to a possibly undefined method SmartFoxClient.
1120: Access of undefined property smartfox.
1120: Access of undefined property smartfox.
1120: Access of undefined property ip.
1120: Access of undefined property port.
1172: Definition it.gotoandplay.smartfoxserver could not be found.

/////////////////////////////////////////////////////////////////////////////////////

Now here is my code

/////////////////////////////////////////////////////////////////////////////////////
package {
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.media.Sound;
import flash.media.SoundChannel;
import it.gotoandplay.smartfoxserver.*;

public class Main extends MovieClip {


//Main
public function Main() {
init();
}

//startscreen
public function init() {
ip="24.233.97.55";
port=9339;
zone= "First Connect"
smartfox = new SmartFoxClient();
smartfox.onConnection=handleConnection;
smartfox.connect(ip, port);
trace(handleConnection);

function handleConnection(success) {

if (success) {

status_txt.text="Connection succesfull!";

} else {

status_txt.text="Can't connect!";

}

}
}
}
}
/////////////////////////////////////////////////////////////////////////////////////
Now that is in a AS file called Main.as. I all put the document Class as Main. So it can recognize the Main.as file. I was wondering if any one could help me. so I can run any thing I make online. the main goal of this Is i am going to school for game programming and I am trying to figure this out before my final project so I can make an Online Mulitplayer game. Thanks so much for all the help.
jt3w
Posts: 5
Joined: 17 Sep 2009, 22:21

Postby jt3w » 18 Sep 2009, 20:43

Does any one have any Idea please help me.
paintbrush
Posts: 19
Joined: 06 Mar 2008, 07:12

Postby paintbrush » 18 Sep 2009, 21:00

Since you're testing on your local filesystem, flash will not allow you to make socket connections unless you explicitly set its security to allow your swf file, or the folder that your swf file is in, to do so.

go to:
http://www.macromedia.com/support/docum ... ger04.html

to add your swf or folder to this list to give it permission to connect.
jt3w
Posts: 5
Joined: 17 Sep 2009, 22:21

Postby jt3w » 18 Sep 2009, 21:49

Thanks now how do I set up a program. Say I was going to write a brand new program can you tell me step by step on what to do and what files to link and what not?
jt3w
Posts: 5
Joined: 17 Sep 2009, 22:21

Postby jt3w » 19 Sep 2009, 15:41

jt3w wrote:Thanks now how do I set up a program. Say I was going to write a brand new program can you tell me step by step on what to do and what files to link and what not?


Therese got to be some one out there that can do this for me :(
User avatar
mariana
Posts: 77
Joined: 26 Mar 2007, 11:15
Location: Buenos Aires, Argentina

Postby mariana » 02 Aug 2010, 14:39

As suggested by "paintbrush", I went to

http://www.macromedia.com/support/docum ... ger04.html

and set the security on my .swf file to "always allow"

I also noticed that I had an old version of the "it" folder (SmartFoxClient ver 1.4.0), so I replaced it by a newer one (@version 1.5.4).

I still get:
5007: An ActionScript file must have at least one externally visible definition


when I try to compile/run my swf file locally. :(

please help!

Mariana
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 02 Aug 2010, 20:49

Hey Mariana,

I believe that error isn't related to SmartFoxServer.

It has something to do with your external Actionscript file missing a class definition. I'm sure there'll be answers online elsewhere.
Smartfox's forum is my daily newspaper.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Aug 2010, 21:01

mariana
In your init method you are referencing variables that are not declared in the body of the class.
If you are not too familiar with AS3 Classes and OOP you should take a look at a few generic tutorials on the subject.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
mariana
Posts: 77
Joined: 26 Mar 2007, 11:15
Location: Buenos Aires, Argentina

Postby mariana » 03 Aug 2010, 16:20

Lapo:

the problem is caused by Room.as, line 1, which is part of the SFS AS3 API.

Up to now, I'd been using the AS2 API, so maybe that's why I hadn't found this error before.

But now I'm trying to convert my old AS2 swfs to AS3, and I don't know how to get around this.

Again, the error is

5007: An Actionscript file must have at least one externally visible definition


Thank you

Mariana
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 03 Aug 2010, 20:42

Make sure you're using SmartFox's Actionscript 3.0 Client API not AS 2.0 Client API which may caused the error you're seeing.
Smartfox's forum is my daily newspaper.
User avatar
mariana
Posts: 77
Joined: 26 Mar 2007, 11:15
Location: Buenos Aires, Argentina

Postby mariana » 04 Aug 2010, 14:01

Big Fish:

I had an old version of the "it" folder (SmartFoxClient ver 1.4.0), so I replaced it by a newer one (@version 1.5.4), which I downloaded from the Linux SFS server (which sits in a server farm, and is version 1.6.6); I am working on a Mac with Flash CS5 (maybe this is a problem?)

I think i am instantiating the SFS Client and the SFS Room correctly:

Code: Select all

var smartfox:SmartFoxClient = new SmartFoxClient()
var regRoom:Room = new Room()
var room:Room = new Room()

Some things that I noticed are:

1. if I use the downloaded classes as they are, I get the error 5007 in line 1 of Room.as ("import mx.utils.Delegate"), so I comment the line out and try again to compile, and I get the error 5007 in line 1 of SmartFoxClient.as, (also "import mx.utils.Delegate")

2. I don't have a package anywhere, just a folder structure, it/gotoandplay/smartfoxserver, with the .as files inside it. I look in the documentation for the AS3 API (http://www.smartfoxserver.com/docs/docP ... index.html) and it refers to a package: "it.gotoandplay.smartfoxserver.data". How can I download the latest Mac version of this package to the client so I can get my fla files to compile? and what about the Linux server, will the .swf files work there? I also need to keep some old AS2 .swf files still working.

Thank you....

Mariana
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 04 Aug 2010, 19:51

Yea, that could be the problem. Try using the MacOS X version of client API from here: http://www.smartfoxserver.com/products/pro.php

Yes, .swf file is cross-platform-able. So even if you compiled the .swf on Mac, it should work on Windows/Linux
Smartfox's forum is my daily newspaper.
User avatar
mariana
Posts: 77
Joined: 26 Mar 2007, 11:15
Location: Buenos Aires, Argentina

Postby mariana » 05 Aug 2010, 19:58

BigFish:

I downloaded the SFS PRO server to my Mac client, took the "it" folder and placed it next to my .fla files (where I had the old one).

I also placed the "com" folder in the folder /ActionScript/Flash API/Actionscript 3.0/ and set the path (using menu File/ActionScript Settings) to /ActionScript/Flash API/Actionscript 3.0/com/adobe

I tried to compile and got these errors:

..../SmartFoxClient.as, Line 2049 1120: Access of undefined property JSON
..../SmartFoxClient.as, Line 2680 1120: Access of undefined property JSON
..../SmartFoxClient.as, Line 17 1172: Definition com.adobe.serialization.json:JSON could not be found

I am certain I'm doing something wrong with the paths and/or the placing of the folders. Can you please tell me how I should this set up so that it will find all the classes?

Thank you,

Mariana
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 05 Aug 2010, 20:06

Hello there,

You should select the entire AS3 API folder (that contains both smartfox and adobe package). There is no need to move the API folders around, just simply add the path to that AS3 folder (directly via {your SFS installation path}\Flash API\)

the SFS AS3 API was looking for com.adobe.serialization inside the path you chosen, but couldn't find it - because in theory it was searching in this path com\adobe\com\adobe\serialization
Smartfox's forum is my daily newspaper.
User avatar
mariana
Posts: 77
Joined: 26 Mar 2007, 11:15
Location: Buenos Aires, Argentina

Postby mariana » 06 Aug 2010, 12:53

BigFish:

I did as you suggested, placed the entire Flash Api folder in folder Actionscript/ and pointed the path to it.

and ...... I got 57 errors!

so I tried placing the "it" folder next to where all my .fla and .swf files are (as I have always done) and the I got only the three errors I listed above:

..../SmartFoxClient.as, Line 2049 1120: Access of undefined property JSON
..../SmartFoxClient.as, Line 2680 1120: Access of undefined property JSON
..../SmartFoxClient.as, Line 17 1172: Definition com.adobe.serialization.json:JSON could not be found

please remember, this is in the CLIENT, I am just trying to produce a .swf file to send to the server and test it, and have been unable to do so fo the last 4 days!

Thank you

Mariana

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 45 guests