You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/06/02 19:28:11 UTC

[royale-asjs] branch develop updated: BE0012: make code be loaded from txt file

This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new b7c86be  BE0012: make code be loaded from txt file
b7c86be is described below

commit b7c86be4ab6527ff5f2d2a26a5fde1a2bdf391e2
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Sun Jun 2 21:28:04 2019 +0200

    BE0012: make code be loaded from txt file
---
 .../pom.xml                                        | 14 ++++++++
 .../src/main/resources/as3code.txt                 | 38 ++++++++++++++++++++++
 ...rnal_javascript_libraries_in_Apache_Royale.mxml | 17 +++++++---
 3 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml
index f08f3dd..523d606 100644
--- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml
+++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml
@@ -53,6 +53,20 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.royale.framework</groupId>
+      <artifactId>Network</artifactId>
+      <version>0.9.6-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>swf</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.royale.framework</groupId>
+      <artifactId>Network</artifactId>
+      <version>0.9.6-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>js</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.royale.framework</groupId>
       <artifactId>Jewel</artifactId>
       <version>0.9.6-SNAPSHOT</version>
       <type>swc</type>
diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/as3code.txt b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/as3code.txt
new file mode 100644
index 0000000..fb2787c
--- /dev/null
+++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/as3code.txt
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale
+{
+	public class WelcomeToActionScript
+	{
+		public function WelcomeToActionScript()
+		{
+			var message:String = "Hello world";
+			sayHi(message, 3);
+		}
+
+		private function sayHi(message:String, times:int):void
+		{
+			for (var i:int = 0; i < times; i++)
+			{
+				// prints message to debug console
+				trace(message);
+			}
+		}
+	}
+}
\ No newline at end of file
diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml
index f74ba29..13185a6 100644
--- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml
+++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml
@@ -20,26 +20,33 @@
 <j:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:j="library://ns.apache.org/royale/jewel"
                xmlns:js="library://ns.apache.org/royale/basic"
-               xmlns:html="library://ns.apache.org/royale/html">
+               xmlns:html="library://ns.apache.org/royale/html"
+               initialize="codeTextLoader.send();">
 
     <fx:Script>
 		<![CDATA[
             import utils.HighlightCode;
 
-            public var _hljs:hljs;
-            
+            public var code_txt:String;
+
             public function highLightContent():void
             {
-                sourceCodeMXMLText.text = "public function hello(){}";
-            
                 COMPILE::JS
                 {
                     var highlightCode:HighlightCode = new HighlightCode();
                     highlightCode.highlightBlock(sourceCodeMXMLText.element);
                 }
             }
+
+            public function onComplete():void
+            {
+                code_txt = codeTextLoader.data;
+                sourceCodeMXMLText.text = code_txt;
+            }
 		]]>
 	</fx:Script>
+
+    <js:HTTPService id="codeTextLoader" url="as3code.txt" complete="onComplete()"/>
     
     <j:initialView>
         <j:View>