-1

I have to create Flash application with AS3 and use functions in DYLIB.

Let say the function name is Open();

Is it possible? And how do I add the DYLIB into my AS3 project?

EDIT

Ok as I can see from the comment, I need to wrap the DYLIB. I am not sure how to do it. Can anyone help ?

njz
  • 47
  • 8
  • 1
    I see you like asking questions "can A technology use library in B technology". Maybe it's time for you to actually explain what your goal is? What is that you are trying to achieve? – Organis Sep 28 '17 at 04:13
  • I have a library to test. So what I need to do is to create a sample which in this case, Flash application and have to use the functions in our library. – njz Sep 28 '17 at 06:54
  • i am not sure how to call the library. is it by using import? or include? – njz Sep 28 '17 at 09:33
  • 1
    No AS3 is not Objective-C or C++. Flash is multi-platform so mostly generic code is supported (you can't use OS specific files like `.dll` (Win) or `.dylib` (Mac). Better to put your `function Open()` code in a command line application and just run that (as external **process**) with arguments like `myCommLineApp -o` where _myCommLineApp_ code itself checks the executing args, if `-o` exists then do `Open();`... – VC.One Sep 28 '17 at 15:18
  • You can use native extensions to wrap native code and make it available to AS3. The process is quite simple, a couple of wrapper classes and package the native code as an ANE (similar to a SWC). You can read more here: https://www.adobe.com/devnet/air/articles/extending-air.html – Michael Sep 28 '17 at 23:32
  • @Michael which ANE should i use for this? – njz Oct 02 '17 at 01:45
  • Unless the dylib you are looking to use has been created by someone you'll need to create your own ane to wrap the dylib. – Michael Oct 02 '17 at 03:01
  • i tried to find the way to wrap the dylib. but i don't really find it. – njz Oct 05 '17 at 04:44
  • Hi @Michael how to wrap the dylib? – njz Oct 17 '17 at 01:33
  • Hi, You need to create an ANE that uses the library to provide the AS3 interface and then use AIR 27 to package and sign the lib by placing it in the Frameworks directory. Have you created an ANE before? Perhaps start with a simple ANE going through the documentation above then we can elaborate on using dynamic libraries. – Michael Oct 17 '17 at 01:47
  • @Michael I have not create any ANE before. This is totally new for me – njz Oct 17 '17 at 01:54
  • 1
    Probably worth working through a few tutorials then. Start with some basic ANE functionality then come back once you've figured out using a static lib I'll show you the additional steps to get a dynamic lib to work. – Michael Oct 17 '17 at 05:10

1 Answers1

1

To get a dynamic library to work with AIR you must create an ANE (AIR Native Extension) that uses the dylib. The ANE you create should expose parts of the library that you require as AS3 functions.

There are many tutorials available for creating ANEs, start with:

Once you've created the ANE that accesses the dylib, when packaging your application you must go through a few additional steps to correctly sign the dynamic library.

  • make sure you are using AIR 27+
  • add a Frameworks directory to your application at the root level
  • ensure this directory is packaged with your application
  • place any dynamic libs and frameworks in this directory

These libraries will then be correctly signed with your application certificate.

Michael
  • 3,776
  • 1
  • 16
  • 27