Since the DisplayWindow class is linked to a movie clip symbol, it will need to inherit from the Sprite class.

public class DisplayWindow extends Sprite {

Declare the following variables to store information coming from the MindSet

// Public Properties:
public var attention:uint;
public var meditation:uint;
public var poorSignal:uint;

attention will contain the user's measured attention level, measured on the scale from 1 to 100 where 1 is the lowest and 100 is the highest level of attention. meditation will contain the user's measured mediation level on the same scale as attention. poorSignal will contain the signal strength on a scale of 0 to 200. A poorSignal value of 200 indicates that the MindSet is off the user's head and a poorSignal value of 0 indicated the MindSet is getting good signal. Now create a socket object.

// Private Properties:
private var thinkGearSocket : Socket;

The thinkGearSocket object will connect to the ThinkGear Connector. Your code should now look like this:

thinkGearSocket handles all the communication between your flash program and the ThinkGear Connector. By adding an event listener, thinkGearSocket does not need to be polled constantly for new data.
Next, open the socket connection by calling the connect function.

thinkGearSocket.connect("127.0.0.1", 13854);

By default, the ThinkGear Connector sends data in a binary packet format. To change the output to JSON format, add the following code.

Note that the event listener added has dataHanlder as a listener function. The event listener will call dataHandler whenever the socket receives data. This function must accept an Event object as its only parameter and must return nothing. Add this function under the DisplayWindow() function.

When the application is connected to the ThinkGear Connector, this function will retrieve and handle all data from the MindSet. The attention, meditation, and poorSignal variables will be constantly updated through this function.

Save DisplayWindow.as. If you have the ThinkGear Connector running, click the Test Project button in the Project inspector and test out your program. If your application compiles correctly and is connected to a MindSet, you should see something like this:

Appendix

Running a local SWF file

In order to run the HelloEEG SWF file locally, you must change Adobe Flash's Global Security Settings. Open the Global Security Settings panel here. Click on the Edit locations… drop-down box and select Add location… Choose Browse for folder… and select your HelloEEG project folder.

Support

About NeuroSky

NeuroSky technologies enable the most insightful and easy-to-understand health and wellness biometrics for mobile solutions, wearable devices, and service providers. The company’s proprietary, market-leading biosensor technologies provide a foundation for analyzing biometric data in a way that’s never before been practical. NeuroSky-enabled solutions deliver unique insights into body and mind health and wellness that can motivate people to make better lifestyle choices.