Flash Architecture and "TypeError: Error #1009:"

396 Views Asked by At

This is an architecture question that I hope solves some of the issues that are popping up with a large-ish UI problem I'm working on.

Background: I'm building an in-game UI in Flash (using Flash CC) for use with Scaleform. I'm somewhere between nood and moderately knowledgeable; probably enough of the latter to be dangerous.

My current architecture is:

  • Parent: This will manage and create all instances of the UI. It has its own FLA/SWF file.
  • Component 1: This is one of the components of the parent, with its own FLA/SWF file
  • Component 2: This is another component of the parent, with its own FLA/SWF file
  • Shared HUD Assets: This contains common elements between all elements (its own FLA/SWF file); it exports all of its symbols, and these are imported into the libraries of the appropriate component
  • Shared Assets: This is common across all UI (buttons, background, etc.) It also exports/imports like the HUD assets

The intent here is to allow multiple types of components to be stored in each component file, with the HUD choosing which one to use and "assembling" the HUD. Artists would be able to work in the component and asset files without touching the larger HUD file and having to muck around in code.

Initially, I tried storing all of the assets in the main parent, but Flash is... a bit of a pain with managing imported symbols for multiple layouts. I'd end up with duplicate fonts, links that broke, etc.

Next, I tried creating instances using pure AS, i.e. "component = new component()" from imported AS files, but it appears I've run into issues with layouts created in the Flash IDE (and not done exclusively in AS) not being accessible to the parent. (I'm assuming this is an issue; it's possible I'm misreading some people experiencing similar issues on this site and others.)

Now, I'm decided loading the SWF files should address that issue, but I'm running into a number of "TypeError: Error #1009" in these loaded SWF files; specifically, a button (AnimatedToggleButton) that's referenced by another Scaleform component (ButtonBar). Both it and the ButtonBar are imported to the HUD component from Shared Assets, but AnimatedToggleButton is unused anywhere else. It's properly exporting and importing, and works from when compiled in the component SWF, but it comes up as a missing class/null in the parent when the SWF is loaded. I'm tried all of the usual tricks, waiting for the stage, etc.

Is this the right architecture for this sort of thing? And if it is, what's the deal with imported symbols? Do they not exist unless used?

1

There are 1 best solutions below

1
On

Do you have "Export in Frame 1" checked in the Symbol Properties?

If not, then yes, only symbols that appear on the stage will be exported and accessible to the parent SWF.