How to use OpenSpace with FlashDevelop ?

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

User avatar
kotbegemot
Posts: 82
Joined: 21 Nov 2010, 05:05
Location: Saint-Petersburg

How to use OpenSpace with FlashDevelop ?

Postby kotbegemot » 01 Aug 2011, 10:56

How to use OpenSpace with FlashDevelop, i mean without mxml?


Code: Select all

package
{
   import com.smartfoxserver.openspace.components.flex.OpenSpace;
   import flash.display.Sprite;
   import flash.events.Event;
   
   import it.gotoandplay.smartfoxserver.SmartFoxClient;
   import it.gotoandplay.smartfoxserver.SFSEvent;
      
   
   import com.smartfoxserver.openspace.engine.control.events.OpenSpaceEvent;
   import com.smartfoxserver.openspace.shared.control.events.LoggerEvent;
   
   /**
    * ...
    * @author Levashkin Konstantin
    */
   public class Main extends Sprite
   {
      
      private var server:SmartFoxClient;
      
      private var openSpaceComp:OpenSpace;//Визуальный компонент OpenSpace
      
      
      public function Main():void
      {
         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
         
         server = new SmartFoxClient(true);         
         server.addEventListener(SFSEvent.onConnection, onConnection);
         server.addEventListener(SFSEvent.onConnectionLost, onConnectionLost);
         server.addEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdate);
         server.addEventListener(SFSEvent.onJoinRoom, onJoinRoom);
         server.addEventListener(SFSEvent.onJoinRoomError, onJoinRoomError);
         server.addEventListener(SFSEvent.onLogin, onLogin);
         
         server.connect("127.0.0.1", 9339);
         
         openSpaceComp = new OpenSpace(); //Визуальный OpenSpace
         addChild(openSpaceComp);
         openSpaceComp.x = 0; openSpaceComp.y = 0;
         //openSpaceComp.co
         
      }
            
      //************************ SMARTFOXSERVER EVENTS ******************************//
      private function onRoomListUpdate(e:SFSEvent):void
      {
         trace("* ORoomListUpdate *");
         //server.autoJoin();
         initializeOpenSpace();
      }
            
      private function onLogin(e:SFSEvent):void
      {
         trace("* OnLogin *");
            
      }
      
      private function onJoinRoomError(e:SFSEvent):void
      {
         trace("OnJoinRoomError");
      }
      
      private function onJoinRoom(e:SFSEvent):void
      {
         trace("OnJoinRoom");
      }
      
      private function onConnectionLost(e:SFSEvent):void
      {
         trace("OnConnectionLost");
      }
      
      private function onConnection(e:SFSEvent):void
      {
         trace("* OnConnection *");
         server.login("openSpaceExample", "testName", "")
      }
      //******************************************************************************//
      
      
      //================================= OPENSPACE ==================================//
      /**
       * OpenSpace initialization.
       * Before calling the init method we have to add all the necessary event listeners.
       * NOTE: many listeners have been added by the managers created during application initialization.
       */
      private function initializeOpenSpace():void
      {
         trace("# Initialize OpenSpace #");
         openSpaceComp.addEventListener(OpenSpaceEvent.INITIALIZED, onOpenSpaceInitialized)
         openSpaceComp.addEventListener(OpenSpaceEvent.RESET, onOpenSpaceReset)
         
         openSpaceComp.addEventListener(LoggerEvent.INFO, onLoggerEvent)
         openSpaceComp.addEventListener(LoggerEvent.WARNING, onLoggerEvent)
         openSpaceComp.addEventListener(LoggerEvent.ERROR, onLoggerEvent)
               
         openSpaceComp.init(server, null);
      }
      
      private function onLoggerEvent(e:LoggerEvent):void
      {
         trace("[" + e.type.toUpperCase() + "] " + e.params.message + (e.params.code != undefined ? " (" + e.params.code + ")" : ""))
      }
      
      private function onOpenSpaceReset(e:OpenSpaceEvent):void
      {
         trace("onOpenSpaceReset");
      }
      
      private function onOpenSpaceInitialized(e:OpenSpaceEvent):void
      {
         trace("onOpenSpaceInitialized");
      }
            
      //================================================================================//
      
   }
   
}


I try to use this code? but nothing happened
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 11 Aug 2011, 12:37

Please pay attention to the forum in which you are posting. This is related to OpenSpace, not SmartFoxBits.

We are not familiar with FlashDevelop, sorry.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 51 guests