Error: SFSEvent not found

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Error: SFSEvent not found

Post 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?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: SFSEvent not found

Post by Lapo »

Did you import the class in your code?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Re: Error: SFSEvent not found

Post 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
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: SFSEvent not found

Post 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.
Lapo
--
gotoAndPlay()
...addicted to flash games
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Re: Error: SFSEvent not found

Post 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
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: SFSEvent not found

Post 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?
Lapo
--
gotoAndPlay()
...addicted to flash games
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Re: Error: SFSEvent not found

Post by Sevil »

Yes please. I would be grateful. Thank you.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: SFSEvent not found

Post by Lapo »

Sent,
let us know if it helps.
Lapo
--
gotoAndPlay()
...addicted to flash games
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Re: Error: SFSEvent not found

Post by Sevil »

Thank you, but unfortunately it did not help :(
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: SFSEvent not found

Post by Lapo »

Sounds very odd.
I would try installing a fresh copy of Flash Develop, possibly on a different machine, and try there.
Lapo
--
gotoAndPlay()
...addicted to flash games
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Re: Error: SFSEvent not found

Post 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. :?
Sevil
Posts: 15
Joined: 29 May 2015, 20:38

Re: Error: SFSEvent not found

Post by Sevil »

The problem was solved updating sdk and Flash Player :idea: Thank you for helping :)
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: SFSEvent not found

Post by Lapo »

How weird :shock:
Well... good to know. Cheers!
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply