Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial version of actionscript file, with makefile. Also using

git-tools =).
  • Loading branch information...
commit 423a1e861ad44943b36e8dd102bff655fad3226b 0 parents
@jfly authored
3  .gitmodules
@@ -0,0 +1,3 @@
+[submodule "git-tools"]
+ path = git-tools
+ url = git@github.com:jfly/git-tools.git
17 Makefile
@@ -0,0 +1,17 @@
+all: git-hooks swf/HTTPGet.swf
+
+run: all
+ ( cd webroot; python -m SimpleHTTPServer )
+
+lint:
+ python git-tools/lint.py
+
+git-hooks:
+ python git-tools/setupGitHooks.py
+
+clean:
+ rm -rf swf
+
+
+swf/HTTPGet.swf: src/HTTPGet.as
+ mxmlc -benchmark=True -creator=jfly -static-link-runtime-shared-libraries=true -output=$@ $^
1  README
@@ -0,0 +1 @@
+After cloning, run "make". HTTPGet.swf should be created in the swf/ directory. This will only succeed if you have the Flex sdk installed, and the mxmlc binary is on you PATH.
1  git-tools
@@ -0,0 +1 @@
+Subproject commit 11fdb9011f46b6f7e10ad63a3509219c355967f2
83 src/HTTPGet.as
@@ -0,0 +1,83 @@
+package {
+ import flash.text.*;
+ import flash.external.*;
+ import mx.core.*;
+ import mx.utils.*;
+ import mx.events.*;
+ import flash.utils.Timer;
+ import flash.ui.*;
+ import flash.events.*;
+ import flash.display.Sprite;
+ import flash.display.LoaderInfo;
+ import flash.system.Security;
+ import flash.system.SecurityPanel;
+
+ public class HTTPGet extends Sprite {
+
+ public static function log(msg:String):void {
+ // TODO - come up with something that works on firefox...
+ //ExternalInterface.call("function(msg) { if(typeof(console) != 'undefined' && console.log) { console.log(msg); } else { alert(msg); } }", msg);
+ ExternalInterface.call("console.log", msg);
+ }
+ public static function callJs(functionName:String, ...args):void {
+ // Debugging js is easier if our js code doesn't have
+ // to run in the context of the flash applet. I imagine
+ // things will also be a bit faster.
+ // Since this is nonblocking, we can't read a return
+ // value from js.
+ ExternalInterface.call("function(args) { setTimeout(function() { " + functionName + ".apply(null, args); }, 0); }", args);
+ }
+ public static function assert(expression:Boolean):void {
+ if(!expression) {
+ throw new Error("Assertion failed!");
+ }
+ }
+
+ private static var updateCallback:String;
+ private static var errorCallback:String;
+
+ public function HTTPGet() {
+ try {
+ var font:TextFormat = new TextFormat();
+ font.font = "Arial";
+ font.size = 40;
+
+ var micState:UITextField = new UITextField();
+ micState.y += 20;
+ micState.width = 500; // TODO - magic number
+ micState.wordWrap = true;
+ micState.autoSize = TextFieldAutoSize.LEFT;
+ micState.setTextFormat(font);
+ addChild(micState);
+
+ var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
+ updateCallback = params.updateCallback;
+ errorCallback = params.errorCallback;
+
+ ExternalInterface.addCallback("get", function(url:String):String {
+ return "TODO";
+ });
+ ExternalInterface.addCallback("ping", function():Boolean {
+ return true;
+ });
+ } catch(e:Error) {
+ handleError(this, e);
+ }
+ }
+
+ public static function handleError(source:Object, e:Error):void {
+ try {
+ var objError:Object = {};
+ objError.message = e.message;
+ objError.stackTrace = e.getStackTrace();
+ objError.source = source.toString();
+ callJs(errorCallback, objError);
+ } catch(ee:Error) {
+ var msg:String = "Error calling " + errorCallback + ".";
+ msg += " " + e.message;
+ log(msg);
+ log(' ' + ee.message);
+ }
+ }
+ }
+}
BIN  swf/HTTPGet.swf
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.