Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:35:11+00:00 2026-05-23T22:35:11+00:00

Ok, modules in Flex are popular but I have no idea why documentation and

  • 0

Ok, modules in Flex are popular but I have no idea why documentation and examples on the different uses of Flex modules can be so scarce.

Anyway, for this question, I will take the classic Employee/Department example. I have a main.mxml that contains an mx:TabNavigator. Each tab is loaded by an s:ModuleLoader.

Tables: Employees {empID,empName,deptID}, Deparments {deptID,deptName}

The Tab Navigator contains only one tab (for our example) called Employee. I have an Employee.mxml module. In that module, I have a datagrid that is populated with Employee details. I use the getEmployees($deptID) function. This function, as you may guess, returns me an array of Employees who work in a particular department.

Outside the TabNavigator, I have a departmentDropDownList that is populated with departments.deptName.

My objective is to load the Employee module when I select a particular department from the DropDownList. I have a changeHandler for the DropDownList that can give me the deptID.

protected function departmentDropDownList_changeHandler(event:IndexChangeEvent):void
{
MyDeptID=departmentDropDownList.selectedItem.deptID;
//var ichild:*=employeeModule.child as IModuleInfo;
}

Now, the million dollar question is: How do I pass this deptID to the Employees module. The latter has an employee_creationCompleteHandler that calls getEmployees(deptID):

protected function EmployeesDg_creationCompleteHandler(event:FlexEvent):void
// I only need to get the deptID from the departmentDropDownList outside the Employee module.
// If I could create a global variable deptID, that would be great!
 getEmployeessResult.token=employeeService.getEmployeess(deptID);
}

I have attempted to use [Bindable] variables but without success.

I would appreciate your suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:35:12+00:00Added an answer on May 23, 2026 at 10:35 pm

    You can’t really guarantee that the deptID will be set when creationComplete runs–it sounds like you’re waiting for a server result–so this is probably not the best way to handle it.

    One of the things you need to be careful of is directly referencing the full Module Class from the main Application, because the point of modules is that you should not compile in the module Class into the main Class (to reduce file size/load times).

    So what you might want to do is create an Interface. This creates a “contract” between the main application and the Module without carrying all the implementation code with it. That might look something like this

    public interface IEmployeeModule {
        function set deptID(value:int):void;
    }
    

    Then, your Module might have code that’s something like this:

    protected var _deptID:int;
    public function set deptID(value:int):void {
        _deptID = value;
        var token:AsyncToken=employeeService.getEmployeess(deptID); 
        token.deptID = value;//in case department id changes, you can determine if you still care
    }
    

    Note that, though global variables seem like a wondermous idea when your project is small, they are a very bad habit to get into. It can be almost impossible to repair a project that starts out with these and then grows to the point that no one can figure out exactly which of the hundreds or thousands of Classes that have access to a variable are changing it in the wrong way at the wrong time.

    You ESPECIALLY don’t want to use global variables with Modules, as they can cause really bad problems when the modules start fighting over the definition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are IDs attributes shared between different modules in Flex ? i.e. I have a
I have a Flex application that can load modules as necessary. When the first
I have flex application consisting of several modules which is configured using maven. I'm
I have Maven modules that produce a Flex application as an SWF file. I
hopefully someone can help me with this headache I have. I'm currently running Drupal
I have a maven project with flex-mojos 3.1.0. Can I have a module with
I'm creating a Flex 4 application which contains different modules in it. The main
I have a Flex/Java web application that uses Maven as a build tool. Currently,
I have just started looking into using Modules in Flex and would like to
We have a rather complicated multi-module Maven project. There are Flex modules, GWT modules,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.