As of late 2021, we are in the process of updating Stencylpedia and fixing up outdated & broken content. Thanks for your patience!
Disclaimer: Stencyl does NOT support online multiplayer games. A few years, an end user used a third party library (Electrotank) to create a multiplayer game. Word got out about this, and we still get questions about it.
If you'd like to talk with the original author, the forum topic is located here.
If you'd like to talk with the original author, the forum topic is located here.
Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game,
please ask a question on the forums. Thanks!
9 Comments
snake13
What is this code:
package scripts
{
import com.electrotank.electroserver5.api. CreateRoomRequest;
import com.electrotank.electroserver5.api. JoinRoomEvent;
import com.electrotank.electroserver5.api. LoginResponse;
import com.electrotank.electroserver5.api. PublicMessageEvent;
import com.electrotank.electroserver5.api. PublicMessageRequest;
import com.electrotank.electroserver5.api. UserUpdateAction;
import com.electrotank.electroserver5.api. UserUpdateEvent;
import com.electrotank.electroserver5.util .ES5TraceAdapter;
import com.electrotank.electroserver5.zone .Room;
//import flash.display.Sprite;
//import flash.events.Event;
//ElectroServer imports
import com.electrotank.electroserver5.api. ConnectionResponse;
import com.electrotank.electroserver5.api. LoginRequest;
//import com.electrotank.electroserver5.api. LoginResponse;
import com.electrotank.electroserver5.api. MessageType;
import com.electrotank.electroserver5.Elec troServer;
//import com.electrotank.electroserver5.util .ES5TraceAdapter;
//Logger imports
import com.electrotank.logging.adapter.Log ;
import com.electrotank.logging.adapter.ILo gger;
import flash.events.*;
import flash.net.*;
import flash.filters.*;
import flash.display.BitmapData;
import Box2DAS.Collision.*;
import Box2DAS.Collision.Shapes.*;
import Box2DAS.Common.*;
import Box2DAS.Dynamics.*;
import Box2DAS.Dynamics.Contacts.*;
import Box2DAS.Dynamics.Joints.*;
import stencyl.api.data.*;
import stencyl.api.engine.*;
import stencyl.api.engine.actor.*;
import stencyl.api.engine.behavior.*;
import stencyl.api.engine.bg.*;
import stencyl.api.engine.font.*;
import stencyl.api.engine.scene.*;
import stencyl.api.engine.sound.*;
import stencyl.api.engine.tile.*;
import stencyl.api.engine.utils.*;
import org.flixel.*;
public dynamic class ConnectToES5 extends SceneScript
{
//Expose your attributes to Stencyl like this
[Attribute(id="1", name="Display Name", desc="An Attribute")]
public var attributeName:String;
//Then in the constructor or init(), add it to the nameMap like this
//nameMap["Display Name"] = "attributeName";
//This lets API calls using attribute names to use the display name
//add this so we can see the logs get traced
Log.setLogAdapter(new ES5TraceAdapter);
private var _room:Room;
//create a new ElectroSerserver instance to gain access to the API
private var _es:ElectroServer = new ElectroServer();
//Do all actor initialization here
override public function init():void
{
//load settings file and connect
_es.loadAndConnect("settings.x ml");
//listen to key events to know when a connection has succeeded (or failed), and when login has succeeded (or failed)
_es.engine.addEventListener(Message Type.ConnectionResponse.name, onConnectionResponse);
_es.engine.addEventListener(Message Type.LoginResponse.name, onLoginResponse);
_es.engine.addEventListener(Message Type.JoinRoomEvent.name, onJoinRoomRequest);
_es.engine.addEventListener(Message Type.PublicMessageEvent.name, onP
-1
What is this code:
package scripts
{
import com.electrotank.electroserver5.api. CreateRoomRequest;
import com.electrotank.electroserver5.api. JoinRoomEvent;
import com.electrotank.electroserver5.api. LoginResponse;
import com.electrotank.electroserver5.api. PublicMessageEvent;
import com.electrotank.electroserver5.api. PublicMessageRequest;
import com.electrotank.electroserver5.api. UserUpdateAction;
import com.electrotank.electroserver5.api. UserUpdateEvent;
import com.electrotank.electroserver5.util .ES5TraceAdapter;
import com.electrotank.electroserver5.zone .Room;
//import flash.display.Sprite;
//import flash.events.Event;
//ElectroServer imports
import com.electrotank.electroserver5.api. ConnectionResponse;
import com.electrotank.electroserver5.api. LoginRequest;
//import com.electrotank.electroserver5.api. LoginResponse;
import com.electrotank.electroserver5.api. MessageType;
import com.electrotank.electroserver5.Elec troServer;
//import com.electrotank.electroserver5.util .ES5TraceAdapter;
//Logger imports
import com.electrotank.logging.adapter.Log ;
import com.electrotank.logging.adapter.ILo gger;
import flash.events.*;
import flash.net.*;
import flash.filters.*;
import flash.display.BitmapData;
import Box2DAS.Collision.*;
import Box2DAS.Collision.Shapes.*;
import Box2DAS.Common.*;
import Box2DAS.Dynamics.*;
import Box2DAS.Dynamics.Contacts.*;
import Box2DAS.Dynamics.Joints.*;
import stencyl.api.data.*;
import stencyl.api.engine.*;
import stencyl.api.engine.actor.*;
import stencyl.api.engine.behavior.*;
import stencyl.api.engine.bg.*;
import stencyl.api.engine.font.*;
import stencyl.api.engine.scene.*;
import stencyl.api.engine.sound.*;
import stencyl.api.engine.tile.*;
import stencyl.api.engine.utils.*;
import org.flixel.*;
public dynamic class ConnectToES5 extends SceneScript
{
//Expose your attributes to Stencyl like this
[Attribute(id="1", name="Display Name", desc="An Attribute")]
public var attributeName:String;
//Then in the constructor or init(), add it to the nameMap like this
//nameMap["Display Name"] = "attributeName";
//This lets API calls using attribute names to use the display name
//add this so we can see the logs get traced
Log.setLogAdapter(new ES5TraceAdapter);
private var _room:Room;
//create a new ElectroSerserver instance to gain access to the API
private var _es:ElectroServer = new ElectroServer();
//Do all actor initialization here
override public function init():void
{
//load settings file and connect
_es.loadAndConnect("settings.x ml");
//listen to key events to know when a connection has succeeded (or failed), and when login has succeeded (or failed)
_es.engine.addEventListener(Message Type.ConnectionResponse.name, onConnectionResponse);
_es.engine.addEventListener(Message Type.LoginResponse.name, onLoginResponse);
_es.engine.addEventListener(Message Type.JoinRoomEvent.name, onJoinRoomRequest);
_es.engine.addEventListener(Message Type.PublicMessageEvent.name, onP
-1
snake13
In the section where it says "How can I get a socket server is it free" you don't tell if it is free. Is it free.
-1
In the section where it says "How can I get a socket server is it free" you don't tell if it is free. Is it free.
-1
iggyvolz
Where exactly does this script go? I tried attatching it to my scene, but it gave to my console:
flixel v2.32 [release]
----------------------------------- ------------------------
Loading Scene 0
Start Fade In
Loading Scene: -1
Simple Test Scene
Error #1065
Could not load: electroserver
Could not initialize Script for Behavior: electroserver
FINISHED Entering...
0
Where exactly does this script go? I tried attatching it to my scene, but it gave to my console:
flixel v2.32 [release]
----------------------------------- ------------------------
Loading Scene 0
Start Fade In
Loading Scene: -1
Simple Test Scene
Error #1065
Could not load: electroserver
Could not initialize Script for Behavior: electroserver
FINISHED Entering...
0
niccosw
Note that with the release of Stencyl 1.2, there is a much easier way to import SWC files.
0
Note that with the release of Stencyl 1.2, there is a much easier way to import SWC files.
0
niccosw
Also: the "install a SWC file" link should point to http://www.stencyl.com/help/viewArt icle/84
0
Also: the "install a SWC file" link should point to http://www.stencyl.com/help/viewArt icle/84
0
niccosw
Thanks for uploading my Stencylpedia article! However, I think the Level should be Expert, not Beginner.
0
Thanks for uploading my Stencylpedia article! However, I think the Level should be Expert, not Beginner.
0