0

Say I want to create a library.swf file that will contain most of the definitions for images, sprites and (most importantly) code for custom components, that will be used by other sub projects by only linking the library.swf asset without actually importing anything in the resulting SWF file.

Here is the naive way I tried with Adobe Animate:

  1. Create library project.
  2. Create scripts needed.
  3. Add scripts to project files without specifying main script of the main scene.

Expectedly, last step caused troubles because nowhere in the application I see a way to add scripts. The most promising is Library tab where I can add New Symbol..., but I would think I don't need to create MoveClip for every script I want to add.

In the meanwhile I was trying to find a way I could use this library in other projects, which I believe must be done by importing assets, but the same problem again - I can't find a way to import/reference some SWF file from which I can import packages.

Do I need some other IDE, say FlashDevelop, or is there a way inside Adobe Animate I totally missed?

lolbas
  • 794
  • 1
  • 9
  • 34
  • Probably, this: https://helpx.adobe.com/animate/using/sharing-library-assets-across-files.html – Organis Aug 23 '20 at 23:05
  • @Organis I've tried the approach from the link and it doesn't seem to work for sharing scripts :/ – lolbas Aug 23 '20 at 23:28
  • Why? Where did it go wrong? – Organis Aug 23 '20 at 23:36
  • @Organis so I add new symbol, choose MovieClip, save file to `Common/SomeClass.as`. The class does not extend MovieClip cuz that's not what I need. I add code, save it again, export to SWF. But when I reopen this script, it is empty dummy script that extends MovieClip. And when I look via JPEXS decompiler, the script is in the root, and not in Common package, but this might be due to `Name` field during creation where I can't supply full path – lolbas Aug 24 '20 at 00:04
  • You cannot add an item to the Library and **NOT** extend **MovieClip** or **Sprite**. In order to add other classes to the project, you need to, for example, **import** them in the first frame of main timeline (and maybe refer them, I don't remember). – Organis Aug 24 '20 at 00:25
  • @Organis not even a `Shape`? Or a `SimpleButton`? – Vesper Aug 24 '20 at 06:44
  • **Shape** is not an item you can put to the **Library** it exists only at runtime. **SimpleButton**... maybe. **Sound** (you export audio by subclassing it), **BitmapData** (raster images), **Font** (embedded text fonts). – Organis Aug 24 '20 at 08:22
  • @Organis "You cannot add an item to the Library and NOT extend MovieClip" - what I assumed :( So for a symbol I extend MovieClip, but whenever I save the script to a certain location other than root, `Edit Class` option will always open new file, but not the one I saved. Do I have to save all scripts at root level? – lolbas Aug 24 '20 at 09:00
  • You can save your AS3 classes to the multiple places, but you need to understand how packages work in order to do it properly: https://www.h3xed.com/programming/actionscript-3-beginner-introduction-to-package-and-classes – Organis Aug 24 '20 at 09:57
  • @Organis yea, I use packages that are named the same as the folder path, but the app still does not see scripts. I didn't setup document class, I think it might cause issues, but I don't need document class in a library – lolbas Aug 24 '20 at 10:08
  • Main document class should not be in the **Library** anyway. Then, in the **Library**, do you link AS3 classes via their full name, like **my.good.package.ClassName** or just **ClassName**? – Organis Aug 24 '20 at 10:12
  • @Organis `Linkage`. It put _ClassName_ there by default even if I chose directory during creation, and I tried putting path with slashes there. And I was wondering what was it for. Awesome, this problem is solved! But now the follow up which I believe still falls under main question: how do I import use this library as an asset in other projects? – lolbas Aug 24 '20 at 10:25
  • Once you actually **CAN** buld the SWF with all classes/assets you want, you can get back to the first link I provided. It explains how to use RSL-linked assets. – Organis Aug 24 '20 at 10:35
  • @Organis I followed through that article and I believe sharing at author-time is the thing I am looking for: shared asset is only stored in library, target file only links library file and does not copies shared assets in a resulting SWF. Actually, I initially looked for a ways that result in ImportAsset2 tag being added to the SWF (as described [here](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#%5B%7B%22num%22%3A2887%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C52%2C529%2C0%5D)) – lolbas Aug 24 '20 at 12:43
  • Then you need to change library linkage type from RSL to Embed or Import, I don't remember exactly. Then Flash will add the external resources to the project it builds. – Organis Aug 24 '20 at 12:49
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/220366/discussion-between-lolbas-and-organis). – lolbas Aug 24 '20 at 15:03
  • @lolbas **not clear**... Are you trying to have a `library.swf` which contains a `myfunction()` that you later want to call from any other second project as long as that 2nd project simply loads `library.swf`? So 2nd project can have code like `myValue = theLibrarySWF.myfunction();`? Is that what you want to achieve? Running functions that exists in some loaded external SWF? – VC.One Sep 01 '20 at 13:21
  • @VC.One hey, my more [recent](https://stackoverflow.com/q/63641147) question has better details, but to answer your question: more like `library.swf` defines `BaseWindow` class which I can then use in 2nd project like `class CustomWindow extends BaseWindow` – lolbas Sep 01 '20 at 20:45

0 Answers0