Page 1 of 1

Error: SFSEvent not found

Posted: 01 Jun 2015, 16:46
by Sevil
I'm using FlashDevelop. I created a new project and connect it to a file connector.as who took the example. Added the sfs2x_api_as3.swc library. But when i try to compile this project, i get a "Type was not found or was not a compile-time constant: SFSEvent".
For example, here:
private function onConnection(evt:SFSEvent):void
{
if (evt.params.success)
{
dTrace("Connection Success!")
}
else
{
dTrace("Connection Failure: " + evt.params.errorMessage)
}
}

Has anyone encountered this problem?

Re: Error: SFSEvent not found

Posted: 02 Jun 2015, 07:45
by Lapo
Did you import the class in your code?

Thanks

Re: Error: SFSEvent not found

Posted: 02 Jun 2015, 10:52
by Sevil
yes. Here are the contents of the file Main.as:

Code: Select all

package
{
	import flash.display.Sprite;
	import flash.events.Event;

	public class Main extends Sprite 
	{
		private var con:Connector = new Connector();

		public function Main() 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			addChild(con);
		}

	}

}
the class Connector.as is taken from the example:

Code: Select all

/**
* SmartFoxServer 2X Examples: Connector
* 
* (c) 2009 - 2011 gotoAndPlay()
*/
package
{
	import com.smartfoxserver.v2.SmartFox
	import com.smartfoxserver.v2.core.SFSEvent
	import com.smartfoxserver.v2.entities.*
	import com.smartfoxserver.v2.entities.data.*
	import com.smartfoxserver.v2.requests.*
	
	import flash.display.*
	import flash.events.*
	import flash.system.Security
	
	public class Connector extends Sprite
	{	
		private var sfs:SmartFox
		
		public function Connector()
		{
			// Create an instance of the SmartFox class
		 	sfs = new SmartFox()
		
			// Turn on the debug feature
			sfs.debug = true
			
			// Add SFS2X event listeners
			sfs.addEventListener(SFSEvent.CONNECTION, onConnection)
			sfs.addEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost)
			sfs.addEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, onConfigLoadSuccess)
			sfs.addEventListener(SFSEvent.CONFIG_LOAD_FAILURE, onConfigLoadFailure)
			
			
			sfs.loadConfig()
		}	
		
		
		//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// SFS2X event handlers
		//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		private function onConnection(evt:SFSEvent):void
		{
			if (evt.params.success)
			{
				dTrace("Connection Success!")
			}
			else
			{
				dTrace("Connection Failure: " + evt.params.errorMessage)
			}
		}
		
		private function onConnectionLost(evt:SFSEvent):void
		{
			dTrace("Connection was lost. Reason: " + evt.params.reason)
		}
		
		private function onConfigLoadSuccess(evt:SFSEvent):void
		{
			dTrace("Config load success!")
			dTrace("Server settings: " + sfs.config.host + ":" + sfs.config.port)
		}
		
		private function onConfigLoadFailure(evt:SFSEvent):void
		{
			dTrace("Config load failure!!!")
		}

		//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// Utility methods
		//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::		
		private function dTrace(msg:String):void
		{
			trace("--> " + msg);
		}
	}
}
the only change is that sfs.loadConfig() called immediately, rather than clicking on the button
sfs2x_api_as3.swc added to the library

Re: Error: SFSEvent not found

Posted: 02 Jun 2015, 18:59
by Lapo
Since this is a compile time problem I would suggest to download the latest API from here:
http://www.smartfoxserver.com/download/sfs2x#p=client

and try again. It sounds like your SWC might be corrupted.

Thanks
ps. = I've haven't used FlashDevelop in a long time but I recall it allowed to inspect the content of imported SWCs.
Once you have downloaded the API you can double check that FD sees the classes correctly.

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 00:17
by Sevil
When connected a new version of the API error occurs in the SWC library: "Error: version required to extract this entry not supported (788)".

Here in the forum I have found a solution to this problem related to the fact that in the new version included a library and documentation If you change the extension to .zip, and then back up again, and change the extension to the .swc, the error will go away. (http://forums.smartfoxserver.com/viewto ... 19&t=13538)

It is true, the error disappears and classes are available, but the previous error: "Type was not found or was not a compile-time constant: SFSEvent" remains

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 07:51
by Lapo
Maybe Flash Develop doesn't work well with SWC files containing the doc?

If you want I can send you the SWC without any doc. Do you want me to use the email in your User profile?

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 08:03
by Sevil
Yes please. I would be grateful. Thank you.

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 08:13
by Lapo
Sent,
let us know if it helps.

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 08:36
by Sevil
Thank you, but unfortunately it did not help :(

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 09:15
by Lapo
Sounds very odd.
I would try installing a fresh copy of Flash Develop, possibly on a different machine, and try there.

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 09:36
by Sevil
I have is the latest version FlashDevelop. The most interesting thing is that the problem arises when you try to create a class SFS2X (in my case the "Сonnector"). If not created it, then the project is started normally. If instead of SFS2X use SFS Pro, the project is started again normal. :?

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 10:39
by Sevil
The problem was solved updating sdk and Flash Player :idea: Thank you for helping :)

Re: Error: SFSEvent not found

Posted: 03 Jun 2015, 11:06
by Lapo
How weird :shock:
Well... good to know. Cheers!