Converting a Flex custom component to a module - apache-flex

How to take an existing custom component in Flex and convert it into a module?
EDIT: What should be done in the mxml where this custom component is used? Should it be replaced with a to load the module? If yes, how to deal with code that uses instances of the components?

Change the root mxml tag to <mx:Module... then in the properties of the project click on the "Flex Modules" button and add it in there.
Edit: This is assuming your modules are in the same project. I prefer to create new projects per module as it makes development easier with multiple developers. So what I do is create a new project, change the root to <mx:Module..., in the properties of the module project I disable it from creating the html wrapper, then in my main project I just load up the module swf's based on what menu item was clicked

You would need to place a ModuleLoader in place of the custom component like
<mx:ModuleLoader id="moduleLoader" width="100%" height="100%"/>
And load the Module using the url.
moduleLoader.unloadModule();
moduleLoader.url = "path\to\module.swf";
moduleLoader.loadModule();
You can keep the above code in a function and load modules.
If your module will be used in the same project only, you can create a new MXML Module that can be optimized for the project from FlexBuilder

Related

How can I see custom components in QtDesigner?

I am developing a Qt Quick 2 Application using QML to define my components.
I would like to create a folder in the project where to put common components (such as customized buttons or labels), and specifically I would like to see this components in the Qt Designer view, in order to be able to drag-drop those elements while designing new views.
I see that the Qt Designer view only shows to you the components located at the same path of the qml that you are currently developing, but I haven't found a way to display components located in other paths.
The project tree should be something like this:
RootFolder
CommonComponents
Views
where the qmls developed in the Views folder will use components defined in the CommonComponents folder.
Does anyone know how to configure the project or the QtDesigner in order to achieve this goal?
Thanks

Using mx components in an "actionscript project" in Flash Builder

In Flash builder, I want to create an "Actionscript Project" that uses the mx datagrid component. Unfortunately the mx/spark components don't seem to be available unless your project is a "flex project". Is there a way around this? (I really don't like using that mxml mark-up, and just want to write pure code)
thanks!
In ActionScript Build Path, you have to manually add SWC libraries outside Flex library as shown below (add additional libraries as per your requirement):

Flex - how to switch to another SWC theme at run time?

My goal is to have more themes for my application and if possible, bundle them with the application itself, not load them at runtime using IStyleManager.loadStyleDeclarations().
Using the theme command-line option, you can have more than one "compile-time theme" bundled with your application according to docs:
theme filename [...] Specifies a list of theme files to use with this application. Theme files can be SWC files with CSS files inside them or CSS files.
However, I wasn't able to find an example how to actually do that (use the += syntax on command line?) and switch between those themes at runtime. What API should I use?
Using the theme command-line option, you can have more than one
"compile-time theme" bundled with your application according to docs:
Yes, You can add additional themes using the += in your command line.
I do exactly this for the Flextras mobile demos; including both the generic Spark theme with the Mobile theme to create the app.
However, both themes will be attempted to be used. I believe the second takes precedence. That means for every class where you want to use the "other theme" you have to specify that theme be used manually. This could get pretty complex very quickly; and you'll have to re-create a lot of spark skins in your application. I've done some work for a client around this who wanted to use our mobile DropDownList in both their normal application and in a mobile application from the same code base. I think the appropriate skin is conditionally applied at runtime using CSS; however we had to create a skin for the "non-mobile use" that explicitly specified the non-mobile skins for the individual elements (Such as the scroll bars)

how to use available skins in flex

How to use the skins shown on various sites e.g
flex skin site
into my flex project. Please help.
Take a look at the source for one of the samples.
Start here to load the first sample.
Then right click and select "View Source" from the context menu, to bring up the source.
You'll see this line of code in the main application file:
<mx:Style source="AeonGraphical.css" />
And that is how you include a css file in a Flex application.
Depending on the content of the CSS file; Flex may pick up the design automatically. Or you may have to specify a styleName on individual components.

How can I export part of a Flex Application to a SWF?

I have a Flex App that allows you to dynamically build an animation. It has a UI and a display of the resulting animation, which is a custom Class extending UIComponent. Is there some way to allow users to save/export the dynamically generated Component to a SWF, for reuse in other Flash/Flex Apps?
You can easily export a screenshot, but i don't think you can save a swf.
see this thread:
http://www.actionscript.org/forums/showthread.php3?t=145846
You can export the component (or components) in a SWC design-time library or an RSL run-time library to share between applications.

Resources