Help With my first SmartFoxServer Prog
Posted: 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.
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.