1 Reply Latest reply on Aug 17, 2012 1:29 AM by thejustinwalsh

    Can I use Native Extensions in HTML/JS applications?

    thejustinwalsh

      Digging through the docs, it looks to be pretty easy if i want to import some custom actionscript code using a script tag like so...

       

      <script src="lib/myClasses.swf" type="application/x-shockwave-flash"></script>

       

      Can i use native extensions in a similar manner, or even at all in an HTML app?

      It should be technichly possile for my swf library to use code that relies on a native extension, so can i include the swf add the extension to the application descriptor and debug / package appropriately?

        • 1. Re: Can I use Native Extensions in HTML/JS applications?
          thejustinwalsh Level 1

          I just tried to use a native extension in an HTML AIR app and this is what it told me...

           

          Error #2113: Provided parameter LoaderContext.SecurityDomain is from a dissallowed domain

           

          How did I even get this far you ask?  Well...

          • First I decided I would try and load the OpenCV native extension, it's compiled already and I'm on OS X, so it seemed like a perfect test.
          • In Flash Builder I already have a project that I was using to generate modules for my HTML app, so I simply added the OpenCVExtension.ane by clicking on the `Add SWC...` button under the ActionScript Build Path Properties menu, put the file filter on `*.ane` and selected the OpenCVExtension.ane
          • I built a quick class that I called OpenCVService and added a few lines of code to it in hopes to catch some useful info...
          • Back in my HTML for my app, I then added my OpenCVService.swf into a script tag so that it would be available on the window.runtime property from JS
          • Next, i modified my application descriptor by changing my supportedProfiles to extendedDesktop, and also added the extensions tag, with the extensionID set to be.aboutme.nativeExtensions.opencv.OpenCV
          • I jumped into terminal and ran the unzip command on the OpenCVExtension.ane so that it is sitting in a folder with the same name, i did this ofcourse because adl needs the extension in directory format
          • Finally, I ran adl in the terminal with a command that looks like this: /Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adl -extdir ext application.xml .

           

          And there we have it, broken.  So, I wasn't satisfied with broken, and I dug up this bug Attempting to create an ExtensionContext from a Javascript-based app causes a SecurityDomain error. That sounds like my exact issue! I downloaded the recommended attachment, ANELoadTest2.zip and tried to verify that it would work, as the bug suggested to do in the notes.  And well... The native extension bundled with the test, is for WINDOWS, not MAC, and the bug was specifically filed against a mac version of the runtime.  So, still not fixed.