The Artima Developer Community
Sponsored Link

Web Buzz Forum
Including Styles & Resources in Multi-Modules Flex Application

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chee Seng Chua

Posts: 62
Nickname: quai83
Registered: Nov, 2006

Chee Seng Chua is Senior Application Developer for KZEN Solutions Berhad
Including Styles & Resources in Multi-Modules Flex Application Posted: Aug 6, 2010 4:55 AM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Chee Seng Chua.
Original Post: Including Styles & Resources in Multi-Modules Flex Application
Feed Title: Chee Seng Tech Blog
Feed URL: http://chuacheeseng.blogspot.com/atom.xml
Feed Description: When you think you are superior, you are being an idiot...
Latest Web Buzz Posts
Latest Web Buzz Posts by Chee Seng Chua
Latest Posts From Chee Seng Tech Blog

Advertisement
I have been developing KZLite http://www.kzlite.com which handle modularization with LoaderInfo class. The purpose of the modularization is simple, a module (a swf file which contains multiple class definition) will be loaded only when necessary. We need that as we have a lot of modules in HRMS software.

One of the confusing bumper when loading external swf with LoaderInfo is that control's styles and resource bundles information is not loaded in the main application. For example, my main application use RSL for the flex framework, the RSL will load class definition for ComboBox, DateField, but not their styles and resource bundles information (such as the format string), unless you used the particular component in the main application itself. This is because when compiling the main application, the Flex compiler will find and include only styles and resource bundles information for controls that are used in the main application. However, in case where a control is used in a module but not in the main application (e.g. my main application is just a place holder to load module, and my module may use a DateField control), it will cause a lot of funny runtime errors, something like 'One of the properties is invalid' or 'cannot operate on null' etc.

To solve this, I usually have a IncludeClasses.as in my main application that include all control classes that my other modules will use. The following is my example IncludeClasses.as : -


package
{
import mx.charts.BarChart;
import mx.charts.PieChart;
import mx.controls.Button;
import mx.controls.CheckBox;
import mx.controls.ColorPicker;
import mx.controls.ComboBox;
import mx.controls.DataGrid;
import mx.controls.DateField;
import mx.controls.HSlider;
import mx.controls.HorizontalList;
import mx.controls.Image;
import mx.controls.LinkButton;
import mx.controls.List;
import mx.controls.MenuBar;
import mx.controls.NumericStepper;
import mx.controls.ProgressBar;
import mx.controls.RadioButton;
import mx.controls.TextArea;
import mx.controls.TextInput;
import mx.controls.TileList;
import mx.controls.Tree;
import mx.controls.VSlider;

internal class IncludeClasses
{
internal var button:Button;
internal var checkBox:CheckBox;
internal var colorPicker:ColorPicker;
internal var comboBox:ComboBox;
internal var dataGrid:DataGrid;
internal var dateField:DateField;
internal var linkButton:LinkButton;
internal var horizontalList:HorizontalList;
internal var hSlider:HSlider;
internal var image:Image;
internal var progressBar:ProgressBar;
internal var list:List;
internal var menuBar:MenuBar;
internal var numericStepper:NumericStepper;
internal var radioButton:RadioButton;
internal var textArea:TextArea;
internal var textInput:TextInput;
internal var tileList:TileList;
internal var tree:Tree;
internal var vSlider:VSlider;

internal var pieChart:PieChart;
internal var barChart:BarChart;

public function IncludeClasses()
{

}
}
}


And in the init() of the Application, add in this line:-

new IncludeClasses();


This will make the Flex compiler to think that those classes are in use and include their styles and resource bundle information.

Read: Including Styles & Resources in Multi-Modules Flex Application

Topic: Fly DS 110i: Dual SIM, Multimedia, Long battery life Mobile Phone Previous Topic   Next Topic Topic: JailbreakMe PDF Exploit to be Patched in iOS 4.0.2, Buy iPhone 4 in next 4 Days!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use