6 Replies Latest reply on Jan 15, 2009 12:52 AM by TheKoelnKalk

    Modules loaded multiple times (very weird case)

    TheKoelnKalk
      Hi,

      I have a flex app with nested modules. The root is the main application that consumes one module, and that module consumes many other modules (3 levels so to say).

      What now happens is, that when the main application is loaded that one module it will be loaded (or instantiated) multiple times. Interesting here is that the modules is as much loaded as the amount of 3rd level modules it consumes.

      I am checking the whole stuff for lots of hours, tripple checked everything not to accidentally have the parentDocuments re-instantiated or something but now I am totally lost.

      This problem causes e.g. everything to be computed at nearly the same time, e.g. the same images get loaded over and over again (like 10 times in a row) wich causes weird conflicts and strange app behaviour, especially when it comes to httpservice requests (Images disappearing, data is "lost", etc.).

      I wish I could explain it better but I cannot even explain that bevaviour properly in my own language :D

      Would be nice if someone could provide me with an idea!

      Regards,
      Markus
        • 1. Re: Modules loaded multiple times (very weird case)
          rtalton Level 4
          Use debug and put a breakpoint in your main app where it instantiates the first "module". You will have to trace down every call to module to see what is going wrong.
          • 2. Re: Modules loaded multiple times (very weird case)
            Level 7

            "TheKoelnKalk" <webforumsuser@macromedia.com> wrote in message
            news:gkkik3$es6$1@forums.macromedia.com...
            > Hi,
            >
            > I have a flex app with nested modules. The root is the main application
            > that
            > consumes one module, and that module consumes many other modules (3 levels
            > so
            > to say).
            >
            > What now happens is, that when the main application is loaded that one
            > module
            > it will be loaded (or instantiated) multiple times. Interesting here is
            > that
            > the modules is as much loaded as the amount of 3rd level modules it
            > consumes.
            >
            > I am checking the whole stuff for lots of hours, tripple checked
            > everything
            > not to accidentally have the parentDocuments re-instantiated or something
            > but
            > now I am totally lost.
            >
            > This problem causes e.g. everything to be computed at nearly the same
            > time,
            > e.g. the same images get loaded over and over again (like 10 times in a
            > row)
            > wich causes weird conflicts and strange app behaviour, especially when it
            > comes
            > to httpservice requests (Images disappearing, data is "lost", etc.).
            >
            > I wish I could explain it better but I cannot even explain that bevaviour
            > properly in my own language :D
            >
            > Would be nice if someone could provide me with an idea!

            You may find Q8 provides some insight:
            http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf


            • 3. Re: Modules loaded multiple times (very weird case)
              TheKoelnKalk Level 1
              sure, I read through all this before.

              however, I found out that this issue belong to the state.

              When I enter a certain state in my application it seems that the enterstate event fires a couple of times wich leads to the issue that all the code within this state is running multiple times.

              anyone knows about this problem?
              • 4. Re: Modules loaded multiple times (very weird case)
                TheKoelnKalk Level 1
                holy cow!

                Its all different than I thought.

                I use this to create instances of my modules lazily:

                self[this.choosenTemplate].createComponentsFromDescriptors(false);
                self[this.choosenTemplate].validateNow();

                this it not within a loop or something, but as I found out using the creationComplete even in the mxml tag, the creation is done multiple times.

                So one call cause to instantiate that module a couple of time. And what is still interesting: It creates the module as much of the amount of sub-modules it includes oO

                Any ideas?
                • 5. Re: Modules loaded multiple times (very weird case)
                  TheKoelnKalk Level 1
                  I got it

                  if you set this (as I had before)
                  createComponentsFromDescriptors()

                  it seems to recursively create all sub components although in the docs it is said the default would be "false".

                  holy cow again...
                  • 6. Re: Modules loaded multiple times (very weird case)
                    TheKoelnKalk Level 1
                    Ok I tracked down everything now and it seems that "somehow" flex re-creates even the main application when doing this

                    this[this.choosenTemplate].createComponentsFromDescriptors(true);

                    could it be that flex follows even the backreferences on its path down to all component, back to the main app and then creates the components again? shouldnt this lead to an infinte loop then?

                    however, when I set it to "false" nothing is created at all except the root element : (