Use ActionScript 3 libraries within OpenLaszlo

Today i tried to integrate an ActionScript 3 within OpenLaszlo.
In detail i needed a JPEGEncoder that is integrated in the ActionScript 3 Library from Mike Chambers.

You can download the library here:
https://github.com/mikechambers/as3corelib

The integration is very easy. First of all navigate into your lps root folder, and create a folder named ‘flexlib’. Then download the ActionScript 3 Library and place the as3corelib.swc in it.

That’s all.
Now you are able to integrate as sample the JPGEncoder Library:

<?xml version="1.0" encoding="UTF-8" ?>
<canvas width="100%" height="100%">
	
	<switch>
		<unless property="$as3">
			<handler name="oninit">
			<![CDATA[
				Debug.error("ActionScript 3 required");
			]]>
			</handler>				
		</unless>
		<otherwise> 
		
			<passthrough>		
				import com.adobe.images.JPGEncoder;			
			</passthrough>

			...

		</otherwise>
	</switch>
		
</canvas>
    • cenkhan
    • May 12th, 2013

    Hi,

    First thanks for your efforts… Really.

    I haven’t been able to use actionscript 3 with openlaszlo, however. I am using openlaszlo 4.9.0, and I guess lps root folder is no longer there… And the as3corelib.swc is now as3corelib-master.

    So I was unable to use actionscript 3 with openlaszlo. Any help would be appreciated indeed, since I guess I tried all folders in openlaszlo application.

    Thanks in advance!

      • tdeuling
      • May 13th, 2013

      The lps-root folder means the folder where folders like demos, docs, tools and WEB-INF are located.
      What’s your error message?
      It’s too much time ago, and i can’t also remember what version of OL i had used for this example, but maybe you have to change the *.getDisplayObject() into a *.getMCRef()

      Best,
      Thomas

    • cenkhan
    • May 13th, 2013

    Sorry for late reply! Things got in the way.

    The error message in openlaszlo debugger is as follows:

    ERROR: ActionScript 3 required
    lzx> Debug.inspect(ActionScript 3 required)
    «LzError(31)#0» {
    constructor: LzError
    file: null
    length: 31
    line: null
    message: ‘ActionScript 3 required’
    }
    «LzError(31)#0| ActionScript 3 required»
    lzx>

    Thanks for your concern!

      • tdeuling
      • May 14th, 2013

      Hi,
      this message appears, when you try to run it with swf8 (that didn’t understand AS3).
      The examples require the swf9 or swf10 runtime.

    • cenkhan
    • May 13th, 2013

    And
    I placed as3corelib.swc in a folder named “flexlib” to the location you said without luck. And I could not find either *.getDisplayObject() or *.getMCRef()” expressions. Neither in your code, nor in the as3corelib.swf file.

    I know it has been a lot of while. Still, your assistance would be highly appreciated.

    • tdeuling
    • May 14th, 2013

    Ok, could you post a small example of yours?

    Or you try this small example:
    http://thomas.deuling.org/2011/05/take-webcam-snapshot-with-openlaszlo/

    Install the Adobe Debug Flash Player, run the small example and post the result (error) message here.

    Good Luck

    • cenkhan
    • May 16th, 2013

    I did what you asked, tried your example on my localhost, and the debugger results are as follows. (Although I am not sure this is what you asked for)

    That example, I am also unable to run its demo on your web site. However, I can run the demo of, for example, : OpenLaszlo – ReadAndWriteFileReference, which is indeed what I need to run.

    Debugger results are as follows:

    [08:42:32.208] Unknown property ‘align’. Expression ignored. @ http://localhost:8080/lps-4.9.0/numuneler/webcamSnapshot/index.lzx

    [08:42:55.443] GET http://localhost:8080/lps-4.9.0/numuneler/webcamSnapshot/index.lzx [HTTP/1.1 304 Not Modified 46 ms]
    [08:42:56.862] GET http://localhost:8080/lps-4.9.0/lps/includes/console.css [HTTP/1.1 304 Not Modified 4 ms]
    [08:42:56.866] GET http://localhost:8080/lps-4.9.0/lps/includes/embed-compressed.js [HTTP/1.1 304 Not Modified 10 ms]
    [08:42:57.828] GET http://localhost:8080/lps-4.9.0/lps/includes/flash.js [HTTP/1.1 304 Not Modified 3 ms]
    [08:42:57.831] GET http://localhost:8080/lps-4.9.0/lps/admin/dev-console.html?lzr=swf8&lzappuid=index.lzx&appinfo=%3Cdata%3E%3Crequest+lps%3D%22%2Flps-4.9.0%22+url%3D%22index.lzx%22+relurl%3D%22numuneler%2FwebcamSnapshot%2Findex.lzx%22+fullpath%3D%22%2Flps-4.9.0%2Fnumuneler%2FwebcamSnapshot%2Findex.lzx%22+opt-url%3D%22index.lzo%22+unopt-url%3D%22index.lzx%22+query_args%3D%22%22+pocketpc%3D%22false%22+console-remote-debug%3D%22false%22+console-floating-window%3D%22false%22+appuid%3D%221368682794389%22+windows%3D%22false%22+opt-exists%3D%22false%22+%3E%3C%2Frequest%3E%3Cinfo+size%3D%22122710%22+debug%3D%22false%22+encoding%3D%22null%22+debug-exists%3D%22false%22+debug-up-to-date%3D%22false%22+nondebug-exists%3D%22true%22+nondebug-up-to-date%3D%22true%22+runtime%3D%22swf8%22+gzsize%3D%22122713%22+lfcsize%3D%22399424%22+gzlfcsize%3D%22119898%22+%2F%3E%3C%2Fdata%3E&runtimes=swf8,swf10,dhtml&appproxied=true [HTTP/1.1 304 Not Modified 5 ms]
    [08:42:58.631] GET http://localhost:8080/lps-4.9.0/numuneler/webcamSnapshot/index.lzx?lzt=swf [HTTP/1.1 304 Not Modified 45 ms]
    [08:42:59.368] GET http://localhost:8080/lps-4.9.0/lps/admin/dev-console.lzx.swf?lzr=swf8 [HTTP/1.1 304 Not Modified 3 ms]

      • tdeuling
      • May 16th, 2013

      Hi,
      i’m currently not sure from where/what debugger comes your output 😉

      1. Run your application with index.lzx?debug=true and (important!) &lzr=swf9 or &lzr=swf10
      I read something about swf8 in your post. swf8 uses ActionScript2 not ActionScript3!
      After that, you get the debugger (like this: http://www.openlaszlo.org/lps4.9/docs/developers/debugging.html#d0e127305)
      Post here the result from this debugger.

      2. Use the Adobe Debug-Player. You can download it here:
      http://www.adobe.com/support/flashplayer/downloads.html
      After a successful installation, the content-debugger will throws a window each time a ActionScript-Error happens.
      You can try it, by coding a script with a typing error by yourself.
      Post this error messages too.

    • cenkhan
    • May 16th, 2013

    Thank you very much!

    Webcam snapshot program only froze, but readwritefilereference worked like a charm! That was what I needed.

    The only thing I needed was to run it, I guess, to work using swf10.

    You are doing excellent job here. Can’t thank you enough.