Differences
This shows you the differences between two versions of the page.
| Previous revision | |||
| — | helloeeg_part_2 [2026/08/13 08:17] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== HelloEEG! Part 2 ====== | ||
| + | ====== Features ====== | ||
| + | * Build upon [[helloeeg_adobe_flash_tutorial|HelloEEG!]] Tutorial 1 | ||
| + | * Animate an object using ActionScript | ||
| + | * Using other data supplied from the MindSet | ||
| + | ====== Required Materials | ||
| + | This tutorial requires the following materials: | ||
| + | * [[http:// | ||
| + | * [[thinkgear_connector_tgc|ThinkGear Connector]] | ||
| + | * Adobe Flash CS4 Professional | ||
| + | * as3corelib | ||
| + | ====== Recommended Reading ====== | ||
| + | * {{: | ||
| + | * {{: | ||
| + | * as3corelib API Documentation (JSON class only) | ||
| + | |||
| + | ====== Prerequisite Steps ====== | ||
| + | * Complete HelloEEG Tutorial 1 | ||
| + | ====== Animation with eSense ====== | ||
| + | |||
| + | Now that you have connected to the ThinkGear Connector and you are now reading data from the MindSet, lets expand the Hello EEG! application further. Going back to " | ||
| + | < | ||
| + | import fl.transitions.*; | ||
| + | import fl.transitions.easing.*; | ||
| + | </ | ||
| + | Next, create the ball that will be controlled by eSense by adding a Sprite to the '' | ||
| + | < | ||
| + | //Private Properties | ||
| + | private var thinkGearSocket : Socket; | ||
| + | private var circle: | ||
| + | </ | ||
| + | In the '' | ||
| + | < | ||
| + | public function DisplayWindow() { | ||
| + | | ||
| + | circle = new Sprite(); | ||
| + | circle.graphics.beginFill(0xFF0000); | ||
| + | circle.graphics.drawCircle(275, | ||
| + | circle.graphics.endFill(); | ||
| + | addChild(circle); | ||
| + | </ | ||
| + | Your code should now look like this. | ||
| + | < | ||
| + | package | ||
| + | import flash.display.*; | ||
| + | import flash.events.*; | ||
| + | import flash.net.Socket; | ||
| + | import com.adobe.serialization.json.* | ||
| + | import fl.transitions.*; | ||
| + | import fl.transitions.easing.*; | ||
| + | |||
| + | public class DisplayWindow extends Sprite { | ||
| + | |||
| + | // Constants: | ||
| + | // Public Properties: | ||
| + | public var attention: | ||
| + | public var meditation: | ||
| + | public var poorSignal: | ||
| + | |||
| + | // Private Properties: | ||
| + | private var thinkGearSocket : Socket; | ||
| + | private var circle: | ||
| + | |||
| + | // Initialization: | ||
| + | public function DisplayWindow() { | ||
| + | | ||
| + | circle = new Sprite(); | ||
| + | circle.graphics.beginFill(0xFF0000); | ||
| + | circle.graphics.drawCircle(275, | ||
| + | circle.graphics.endFill(); | ||
| + | addChild(circle); | ||
| + | | ||
| + | thinkGearSocket = new Socket(); | ||
| + | thinkGearSocket.addEventListener(ProgressEvent.SOCKET_DATA, | ||
| + | thinkGearSocket.connect(" | ||
| + | </ | ||
| + | Now in the '' | ||
| + | < | ||
| + | poorSignal = data[" | ||
| + | var yTween: | ||
| + | if(poorSignal == 0) { | ||
| + | </ | ||
| + | After receiving eSense data, the ball can now be updated by using a tween animation. Using tween allows Flash to do all the animation work for you. | ||
| + | < | ||
| + | if(data[" | ||
| + | poorSignal = data[" | ||
| + | var yTween: | ||
| + | if(poorSignal == 0) { | ||
| + | attention = data[" | ||
| + | meditation = data[" | ||
| + | | ||
| + | var newPos:int = 350 - (attention * 3.5); //calculate new position of ball | ||
| + | yTween = new Tween(circle, | ||
| + | } | ||
| + | else { | ||
| + | if(poorSignal == 200) { | ||
| + | attention = 0; | ||
| + | meditation = 0; | ||
| + | yTween = new Tween(circle, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | Now you can test your application. If everything is correct, you should see something like this.\\ | ||
| + | {{: | ||