From 50f8c42af57ad82cffefb05e07ef4e984c4de1c7 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Wed, 18 Nov 2015 10:45:48 +0100 Subject: [PATCH] as3 run flash modified --- libsrc/ffdec_lib/testdata/run_as3/RunMain.as | 59 +++++++++++--------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/libsrc/ffdec_lib/testdata/run_as3/RunMain.as b/libsrc/ffdec_lib/testdata/run_as3/RunMain.as index 39de9aae4..218074ace 100644 --- a/libsrc/ffdec_lib/testdata/run_as3/RunMain.as +++ b/libsrc/ffdec_lib/testdata/run_as3/RunMain.as @@ -1,21 +1,24 @@ -package { - +package +{ + import flash.display.*; import flash.text.TextField; import flash.events.MouseEvent; import flash.external.ExternalInterface; import flash.system.fscommand; - - public class RunMain extends MovieClip { - + + public class RunMain extends MovieClip + { + private var myTextBox:TextField; - - public function RunMain() { - myTextBox = new TextField(); + + public function RunMain() + { + myTextBox = new TextField(); myTextBox.text = ""; myTextBox.width = 400; myTextBox.multiline = true; - addChild(myTextBox); + addChild(myTextBox); var rectangleShape:Shape = new Shape(); rectangleShape.graphics.beginFill(0xFF0000); @@ -39,30 +42,36 @@ simpleButton.y = 100; simpleButton.addEventListener(MouseEvent.CLICK, this.clickListener); addChild(simpleButton); - - ExternalInterface.addCallback("testFunc", testFunction); - - var result; - try { - result = testFunction(); - } catch (e) { - result = e.toString(); + + if (ExternalInterface.available) + { + ExternalInterface.addCallback("testFunc", testFunction); } - + + var result = testFunction(); + myText.text = result; fscommand("run", result); } - - function testFunction() { - try { + + function testFunction() + { + try + { var result = Run.run(); return "Result:" + result + " Type:" + typeof(result); - } catch (ex) { + } + catch (ex) + { return "Error:" + ex; } } - function clickListener(e:MouseEvent) { - myTextBox.text = testFunction(); + function clickListener(e:MouseEvent) + { + var result = testFunction(); + myTextBox.text = result; + + fscommand("run", result); } } -} +} \ No newline at end of file