[Edit: Short version - how do you properly handle namespace collisions in SWC files if one SWC has fewer classes from that namespace than another?]
I have a rather large Flash application which I'm building in Flash Builder (because coding/debugging in the Flash IDE is... not good) and I've got a ton of external SWC files which I'm linking in to my application. This has worked well so far - the file size is on the large side, but it's a lot simpler than loading in SWFs, especially since I am extending most of the classes in each SWC and adding custom code that way (it's a very design-heavy app.) The problem I'm having is when I have Flash Components, like ComboBox or TextInput, in more than one SWC. Whichever SWC was compiled last will work fine, but the others will fail with errors like the following:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip#1f21adc1 to fl.controls.TextInput.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at com.company.design.login::LoginForm()
at com.company.view::Login()[/Users/ken/Workspace/src/com/company/view/Login.as:22]
at com.company.view::Main/showLogin()[/Users/ken/Workspace/src/com/company/view/Main.as:209]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.company.view::Navigation/handleUIClick()[/Users/ken/Workspace/src/com/company/view/Navigation.as:88]
I've been researching components, ComponentShim, etc. but I'm running up against a brick wall. I thought it might be the fact that some of the components had their skins modified in the source FLA, so I tried replacing them with the default skins, but that didn't seem to help. How can I ensure that I have the components imported and available to all my classes, yet still be able to skin them and include them in my various FLAs? (I am never creating new instances of them, they are all laid out by my designer.)
I dunno if this will help you, but I had a similar problem with an asset in a SWC library that was the visual representation for a class in my main project. What I ended up doing was having the visual asset be a Flash-created class that extended the class in my project rather than having the same name.
For example, my asset and the class were both com.blah.TitleBackground. To fix the issue I made the visual asset have teh class of com.blah.TitleBackgroundAsset and set the base class for the component to com.blah.TitleBackground. That fixed this particular issue for me. I still have more to wade through, but your post sparked the idea for the solution to get around the name conflicts.
I can't find the detailed fix (apparently, the work email I used at the time was trashing older messages without my knowledge!) but the short answer is to create one FLA that has all the components you want to use in it, set those components (and the ComponentShim) to 'Export for Runtime Sharing'. Then, in your other FLAs, whenever you want a component, drag it from the components FLA library (it should show up in your main library with 'Import for Runtime Sharing' turned on.) Make sure you don't have a ComponentShim in your main library. You'll need the compiled component SWF file in the same folder as your FLAs.
What this does is keep all the component code, including skins, in one central place, so when you compile (be it as a SWF or a SWC, though this problem mainly crops up when using SWCs) there are no conflicts.
Related
I'm working on a bot in actionscript for a flash game, with some success. My actionscript basically loads the game, finds the functions it needs and calls it to do stuff. For example, ExternalLoadedGame.Game.Action.MoveNorth() to take a step up.
However, some functions are defined as protected, and I can only get access if I can extend that class, but when I try to do that, my compiler tells me that the class is not Compile time consistent and it doesn't work. And if I copy the definition, the game functions don't accept my version of the class, even though it's literally they share literally the same class definition.
I need to specifically override some of the class functions that are called by the game, without access to modify the game files.
Is there any way to extend, make public, or anything similar without modifying the game's SWF file beforehand?
I have a big actionscript project with several external libraries added to dependencies tab. To optimize compilation time I decided to create a module that will compile all these libraries to a single swc. And that is something I've encounter problem with as IntelliJ seems to ignore linkage settings for these libraries. I set linkage to 'include' so that my swc will aggregate all the code from external libraries but instead it looks like I always end up with 'merged' linkage mode.
If my swc-module has no additional code, then IntelliJ will refuse to compile it at all because it says that there's nothing to compile. If I create a dummy class that will access some classes from external libraries then it will compile an swc but with only mentioned classes. That's exactly what 'merged' linkage mode is.
I don't know if it is me doing something wrong or it is a bug in IntelliJ but it's definitely a problem. So I decided to start with a question on StackOverflow.
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?
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.
Is there any way possible to say, have A.swf use only certain items from B.swf, without having to load the entire swf as a child first? What i'm trying to do is have A as lite as possible and pull some items from time to time from B without having to cache the entire file in flash memory somehow. I've looked at other similar questions but none seem to really answer or fit this exact problem.
Before anyone asks, yes I do know how to use loader, loadercontext, and create instances of classes from the library. This is more of a methodology question rather than a "how to" question.
Only idea I can come up with, is to export all of the children as individual swf objects and then have A request B to compose itself of the seperated items that get requested by A. Would this be efficient?
I don't think you can do what you want to do, however since the assets are strictly graphical in nature, it doesn't seem inefficient to just export them as individual assets and load them when you need them. ( In fact it seems very efficient to me... )
I haven't tried it, but to save time you could probably automate the export process with jsfl. ( Jsfl lets you script the Flash IDE itself, to automate tasks that you would otherwise have to do manually. ) Take a look at this Stack Overflow answer here:
Generating individual SWF's with classes from a fla with a large library
That example shows how to batch export swfs out of the library.
Note than in Flash CS6 you can export a MovieClip from the library by right clicking and selecting export, but unfortunately it doesn't let you export a group all at once.
A swf is a compiled package, and is not meant to be split into parts. One solution would be to pull all of the common elements out of A and B into a swc (a compiled Flash library, not meant to be run). You can then include the swc in the compilation of A and B.
Unless you will be creating lots of files with only a few common elements, I don't see why you would need to export each of the children as individual swf files.
When I compile the same project with ant many times it gives a different sizes for each compilation
I added the rsl and more option to mxml it works fine ,but the size is still changed
Please any idea to unify the size
This is not really possible, unless you do some, quite involved post-processing. Below is the list of things I know to change the size between compiles, but it may not be exhaustive:
When you compile pure AS3 project or a project that uses framework:
Resources you embed on variables have their class names generated using the current date in the name.
Flex compiler generates a tag of obscure purpose (can be removed manually, but persists in release builds), which seem to contain a GUID and a compilation time or something similar. It is usually found at the very beginning of the SWF file, somewhere after the rectangle of the SWF dimensions.
In a project that uses framework:
All code generation is suspect to generating inconsistent names, particularly, all bindings will certainly produce different assembly upon each compile. Styles and some other rarely used metadata will cause this too.
Specifically for spark skins, which come as sources rather then compiled libraries - some of them embed resources in a bad way, so you would probably need to compile them into a library and plug it into a project, removing the sources from the source path.
All in all, if you are using pure AS3 project, your task is difficult, but doable (will require following certain conventions and some post-build script that unzips the SWF, purges the compiler-added extra tag and zips the SWF back. But if it is a SWF based on the framework - I'd say the effort isn't worth it, just accept it cannot be done.