Flex Study Notes (2)

Source: Internet
Author: User

Conversion error encountered during learning

Typeerror: Error #1034: forced conversion type failed: MX. Managers: dragmanagerimpl @ 7833851 cannot be converted to MX. Managers. idragmanager.

Repost the detailed solution of others and the root cause of the problem

Triggered by loading and uninstalling the flex ModuleDragmanagerA moduleloader is declared in the main application to load the module, and two buttons are placed to control repeated loading and unloading. Press the first button to load the module, and then press the other button to uninstall the module, load the load method using moduleloader, uninstall the unloadmodule () method, and place a list in the module. During the test, it is found that when the module is reloaded, that is to say, after executing the unloadmodule method once and then clicking the first button to reload the module, the above error will occur if you click any row in the list. The solution is simple, add the following two sentences to the main application:
Import MX. Managers. dragmanager;
Private var dragmanager: dragmanager;
Another solution:

This is shared by the module.CodeProblem (shared code ),
When using managers in a module (such as popupmanager, dragmanager, and historymanager,
The manager method is static, and the entire applicationProgramCreates a singleton for this Manager interface,
However, the module only uses this Singleton in its own application domain. When multiple modules use the same singleton and
When the application is not used, this empty object reference problem occurs: first, the module introducing a manager cannot compare the singleton of the Manager interface with its

This module is shared by other modules. When other modules call the manager method, the application will no longer create instances for this Manager interface, and this module will not be able to reference instances of this Manager interface, there is a Null Object Reference problem, you can refer to the flex source code.

By default, historymanagementenabled = of accordion and tabnavigator
True; while historymanagementenabled of viewstack is false;
Therefore, when using tabnavigator and accordion, you must pay attention to the historymanager sharing code. In addition, when only one module uses historymanager, this problem also occurs when the module is loaded after it is uninstalled, indicating that the second loading is equivalent to a new module.

One solution:
Introduce the relevant manager in main application. You can declare the reference of the manager in main application, as shown in:
Import MX. Managers. historymanager;
VaR historymanager: historymanager;
Other managers are similar.
You can also load the shared code as a module to the application domain of main applicaiton. For details, refer to Alex.
Harui PPT:
Http://blogs.adobe.com/aharui/presentations/The module presentation is described in detail below.

The second answer is similar:

Hello following code in your main application

Import MX. Managers .*;
Private VaR _ dragmanager: dragmanager;
Private VaR _ historymanager: historymanager;
Private VaR _ popupmanager: popupmanager;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.