summaryrefslogtreecommitdiff
path: root/tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'tutorial')
-rwxr-xr-xtutorial/Makefile.am1
-rw-r--r--tutorial/as3/build.xml50
-rw-r--r--tutorial/as3/src/CalculatorUI.as142
3 files changed, 0 insertions, 193 deletions
diff --git a/tutorial/Makefile.am b/tutorial/Makefile.am
index 484b485ee..12b3eb56d 100755
--- a/tutorial/Makefile.am
+++ b/tutorial/Makefile.am
@@ -104,7 +104,6 @@ endif
# Any folders or files not listed above being added to SUBDIR need to be placed here in
# EXTRA_DIST to be included in the release
EXTRA_DIST = \
- as3 \
d \
delphi \
erl \
diff --git a/tutorial/as3/build.xml b/tutorial/as3/build.xml
deleted file mode 100644
index f7ed32d04..000000000
--- a/tutorial/as3/build.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<project name="tutorial" default="dist" basedir=".">
-
- <description>Thrift actionscript 3.0 tutorial.</description>
-
- <property name="gen" location="gen-as3" />
- <property name="src" location="src" />
- <property name="thrift.src" location="../../lib/as3/src/" />
- <property name="dist" location="dist" />
-
- <property name="final.name" value="as3-tutorial" />
- <property name="swf.name" value="${dist}/${final.name}.swf" />
-
- <target name="flex.check" unless="FLEX_HOME">
- <fail message='You must set the FLEX_HOME property pointing to your flex SDK, eg. ant -DFLEX_HOME="/Applications/Adobe Flex Builder 3/sdks/3.2.0"'/>
- </target>
-
- <target name="flex.init" depends="flex.check" unless="flex.finished">
- <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
- <property name="flex.finished" value="true"/>
- </target>
-
- <target name="init">
- <tstamp />
- <mkdir dir="${dist}"/>
- </target>
-
- <target name="dist" depends="generate, flex.init, init">
- <mxmlc output="${swf.name}" file="${src}/CalculatorUI.as">
- <source-path path-element="${gen}" />
- <source-path path-element="${src}" />
- <source-path path-element="${thrift.src}" />
- </mxmlc>
- </target>
-
- <target name="generate">
- <!-- Generate the thrift gen-java source -->
- <exec executable="../../compiler/cpp/thrift" failonerror="true">
- <arg line="--gen as3 ../shared.thrift"/>
- </exec>
- <exec executable="../../compiler/cpp/thrift" failonerror="true">
- <arg line="--gen as3 ../tutorial.thrift"/>
- </exec>
- </target>
-
- <target name="clean">
- <delete dir="${gen}"/>
- <delete dir="${dist}" />
- </target>
-
-</project>
diff --git a/tutorial/as3/src/CalculatorUI.as b/tutorial/as3/src/CalculatorUI.as
deleted file mode 100644
index d996df5fa..000000000
--- a/tutorial/as3/src/CalculatorUI.as
+++ /dev/null
@@ -1,142 +0,0 @@
-package {
- import flash.display.Sprite;
- import flash.text.TextField;
- import flash.text.TextFieldType;
- import flash.events.MouseEvent;
- import flash.system.Security;
-
- import org.apache.thrift.transport.TSocket;
- import org.apache.thrift.transport.TTransport;
- import org.apache.thrift.protocol.TProtocol;
- import org.apache.thrift.protocol.TBinaryProtocol;
-
- /**
- * Simple interface and connection logic implementation for tutorial.
- */
- public class CalculatorUI extends Sprite {
- public static const BUTTON_PADDING:uint = 5;
-
- private var mCalculatorClient:Calculator; // we use calculator through interface
- private var mTransport:TTransport; // Transport, used to comunicate with server
-
- private var mAddButton:Sprite;
- private var mLeft:TextField;
- private var mRight:TextField;
- private var mResult:TextField;
-
- private var pingButton:Sprite;
-
- public function CalculatorUI() {
- buildInterface();
- initSecurity();
- initConnection();
- }
-
- private function initSecurity():void {
- Security.loadPolicyFile("xmlsocket://127.0.0.1:9092");
- }
-
- /**
- * Example of initializing connection.
- */
- private function initConnection():void {
- mTransport = new TSocket("127.0.0.1", 9090); // we connect to server
- mTransport.open();
- // initialize protocol:
- var protocol:TProtocol = new TBinaryProtocol(mTransport, false, false);
- mCalculatorClient = new CalculatorImpl(protocol); // finally, we create calculator client instance
- }
-
- private function onPingClick(me:MouseEvent):void {
- if(!mTransport.isOpen()) return;
- mCalculatorClient.ping(onPingError, onPingSuccess);
- }
-
- private function onPingError(error:Error):void {
- trace("Error, while requesting ping.");
- throw error;
- }
-
- private function onPingSuccess():void {
- trace("Ping returned successfully");
- }
-
- private function onAddClick(me:MouseEvent):void {
- if(!mTransport.isOpen()) return;
- var num1:Number = Number(mLeft.text);
- var num2:Number = Number(mRight.text);
- mResult.text = "Processing...";
- mCalculatorClient.add(num1, num2, onAddError, onAddSuccess);
- }
-
- private function onAddError(error:Error):void {
- trace("Error, while requesting add.");
- throw error;
- }
-
- private function onAddSuccess(res:Number):void {
- mResult.text = String(res);
- }
-
- private function buildInterface():void {
- addChild(pingButton = buildButton("PING"));
- pingButton.x = (stage.stageWidth - pingButton.width) / 2;
- pingButton.y = 10;
- pingButton.addEventListener(MouseEvent.CLICK, onPingClick);
-
- var top:Number = pingButton.y + pingButton.height + 20;
- addChild(mLeft = buildDigitInput());
- mLeft.x = 15;
- mLeft.y = top + BUTTON_PADDING;
- addChild(mRight = buildDigitInput());
- mRight.x = mLeft.x + mLeft.width + 15;
- mRight.y = top + BUTTON_PADDING;
- addChild(mAddButton = buildButton("ADD"));
- mAddButton.x = mRight.x + mRight.width + 15;
- mAddButton.y = top;
- mAddButton.addEventListener(MouseEvent.CLICK, onAddClick);
- addChild(mResult = buildDigitInput());
- mResult.x = mAddButton.x + mAddButton.width + 15;
- mResult.y = top + BUTTON_PADDING;
- }
-
- /**
- * Simple digit-only input field.
- */
- private function buildDigitInput():TextField {
- var textField:TextField = new TextField;
- textField.width = 75;
- textField.height = 20;
- textField.restrict = "0987654321.";
- textField.type = TextFieldType.INPUT;
- textField.background = true;
- textField.backgroundColor = 0xaaaaff;
- textField.textColor = 0xffff00;
- return textField;
- }
-
- /**
- * Simple button drawing.
- */
- private function buildButton(text:String):Sprite {
- var button:Sprite = new Sprite;
- var textField:TextField = new TextField;
- textField.width = 4000;
- textField.text = text;
- textField.textColor = 0xffff00;
- textField.width = textField.textWidth + 4;
- textField.height = textField.textHeight + 4;
- textField.mouseEnabled = false;
- button.graphics.beginFill(0x0000ff);
- button.graphics.lineStyle(0, 0x000000);
- button.graphics.drawRoundRect(0, 0, textField.width + BUTTON_PADDING * 2,
- textField.height + BUTTON_PADDING * 2, BUTTON_PADDING);
- button.graphics.endFill();
- button.addChild(textField);
- textField.x = BUTTON_PADDING;
- textField.y = BUTTON_PADDING;
- button.useHandCursor = button.buttonMode = true;
- return button;
- }
- }
-}