Do unused imports in Flash Builder 4 affect RUNTIME performance? - apache-flex

I have not found any links that referred to the unused imports in Flash Builder. There were, however, a plethora of links and comments on this subject for the more popular languages.
I assume that ALL compilers optimize unused imports in the same manner but need to be sure before I pass this information on to my superior.
So...DO UNUSED IMPORTS AFFECT RUNTIME PERFORMANCE IN FLASH BUILDER PROJECTS???
Please provide references!
Thanks in advance!

If the classes are not used in your code, the import statement will be ignored by the compiler and the classes will be NOT included in your compiled application. So the unused imports will have no effect on a compiled app at all.
I can't think of a reference but it was always like that in FB. You can test it yourself though - take an empty application, include some custom component to it and compile. Check the swf filesize. Then remove the component but leave the import in. Compile again and you will see that the filesize was reduced (this component was not included in the app).

Related

Is there a way to import component-specific scss file from VMware Clarity?

I'm trying to create React Components with VMWare Clarity styles. Is there a way to import component-specific .scss instead of importing clr-ui.min.css?
It is currently non-trivial to isolate styles for Clarity on a per-component basis. There may be a few options for you, which all should be considered carefully. I'm not familiar enough with React build tooling to know how well these may work.
Use a tool like https://github.com/uncss/uncss that can remove unused CSS from your bundles.
Build your own version of Clarity that imports only what you need, but know that this is unsupported unless you follow the themes documentation https://vmware.github.io/clarity/documentation/v0.12/themes. In the future, we plan to make this easier but its a major overhaul.
Copy our SCSS files into your project, but this means you lose upgradability for Clarity in the future.

The meaning of "External" linking mode in Flex Builder

There are three modes to link an SWC library to a flex application: "Merged into code", "External" and "RSL". I understand what is "RSL", but I don't understand what is "External".
"RSL" works just fine for me, without any code changes. However, External doesn't work for me. Although my application starts, the classes in the SWC set to External are never found.
What is the meaning of "External" if it is not "RSL" ? How do I make use of that ?
Thank you,
Boris
Defining a class as External allows the Flex compiler to link to a particular class at compile time but does not cause it to be included in the generated SWF.
The general use for External classes is where you have multiple modules that use a shared library. It would be redundant to include the shared class definitions in every single module and the External keyword allows you to control how these classes are compiled into your libraries.
More information is available at the following locations:
http://web.archive.org/web/20101007120528/http://www.wannaknowflex.com/2010/05/flex-linkage-difference-between-rsl-and-external/
http://www.flexafterdark.com/docs/Flex-Libraries
(external-library-path and load-externs compiler information):
http://www.newtriks.com/?p=802

Can't find compiled resource bundles

I am using Adobe Flash Builder 4.
I've run into this issue with my latest project, but I was able to re-create it with an almost empty project.
Here is what I've done.
Created a new Flex Project
Created a locale/en_US folder within this project.
Added a class that extends SparkDownloadProgressBar. All this class does is attempt to create a Label.
When I try to debug this application, I get the following error.
Error: Could not find compiled resource bundle 'components' for locale 'en_US'.
at mx.resources::ResourceManagerImpl/installCompiledResourceBundle()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:340]
at mx.resources::ResourceManagerImpl/installCompiledResourceBundles()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:269]
at mx.resources::ResourceManagerImpl/processInfo()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:387]
at mx.resources::ResourceManagerImpl()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:122]
at mx.resources::ResourceManager$/getInstance()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManager.as:111]
at mx.core::UIComponent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:3728]
at spark.components.supportClasses::TextBase()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\supportClasses\TextBase.as:154]
at spark.components::Label()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\Label.as:384]
at Preloader()[C:\SVN\Games\Social\Test\src\Preloader.as:21]
at mx.preloaders::Preloader/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\preloaders\Preloader.as:253]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:1925]
at mx.managers::SystemManager/initHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2419]
The Flex Compiler/Additional Compiler Arguments section does contain "-locale en_US", but I do not want to just remove this as I am planning to have this load different property files based on the localization region at run-time and how I understand it, I will need to add each locale that I am planning to use on the compile argument line.
I am at a loss as to how to attack this problem. If you need anymore information from me to help with this, I will be more than happy to provide it. Thanks ahead of time for the help!
This might be caused by the fact, that Preloader loads the actual framework, so you can't use the Flex's classes until it loads. Use standard TextField for it and it should work fine.

FLEX components: updating import statements to move the component into another folder

I've just imported a Flex component into my project.
I have a theory question about importing.
all the imports statements in the component source files started with "com.subFolder.etc", but I have preferred to move the component folders into "componentName" and to replace all import statements as "componentName.com.subFolder.etc"
Is this ok ? Everything works perfectly, but I was wondering if the method is correct.
thanks
You can put the components anywhere you like, however you want to organize them. People will site best practices and theory but if you know where everything is and you tell the compiler where they are:
import componentName.com.subFolder.componentToBeUsed;
Everything will compile and run just fine.
Usually you will see code and components broken up in a domain model.
So you'll have:
com.yoursite.views
com.yoursite.events
com.someothersite.renderers
Which correspond to:
/com/yoursite/views
/com/yoursite/events
Basically all of your code living in folders within /com/yoursite/
and:
/com/someothersite/renderers
being a custom renderer you imported from someothersite.com to use in your application.
In the end, for the compiler and the flash player I don't think it matters where you put things as long as your happy and understand it all...and of course 6 months from now when you come back to look at this code!
It's totally correct, yes.
Note that Flex Builder (if you're using it) can automatically replace your import statements/class name when you rename a directory or a .mxml/.as file.
I never tried moving a complete structure, though, but I would't be surprised if it worked too.

Flex graphic assets: SWF or SWC?

Which is a better format to store graphic assets for a Flex application, SWF or SWC?
Are there any real differences, and if so what are they?
Assets in a seperate SWF are loaded and included at runtime.
Assets in a SWC are loaded and included / compiled at compile time.
You can also directly embed assets within the main app SWF at compile time (check out the Embed meta data).
Of course, you can also load individual assets (such as a PNG) directly at runtime.
As far as which is better, it really depends on what you are trying to do, and how the assets are used.
mike
SWC is what you use when you're looking for a library to compile into your app. You have access to the classes and can import individual parts. SWF is more likely what you're looking for when embedding graphics.
Here's the docs you might be interested in:
http://livedocs.adobe.com/flex/3/html/help.html?content=layoutperformance_06.html#223998
I've been having good success with SVG for images, but there's some caveats since Flex only implements a subset of the features.
I have no real reason for doing this so it may be incorrect but I usually create SWF's for things that need to be loaded during runtime and SWC's for things that need to be available for design time.
A SWC is simply a SWF and some metadata wrapped into a zip file. Other than the fact that runtime loading of SWC isn't supported, I don't think there are any major differences between using the two formats.

Resources